MCPcopy Create free account
hub / github.com/tendermint/tendermint / TestCreateProposalBlock

Function TestCreateProposalBlock

node/node_test.go:221–312  ·  view source on GitHub ↗

create a proposal block using real and full mempool and evidence pool and validate it.

(t *testing.T)

Source from the content-addressed store, hash-verified

219// create a proposal block using real and full
220// mempool and evidence pool and validate it.
221func TestCreateProposalBlock(t *testing.T) {
222 cfg, err := config.ResetTestRoot("node_create_proposal")
223 require.NoError(t, err)
224 defer os.RemoveAll(cfg.RootDir)
225 cc := abciclient.NewLocalCreator(kvstore.NewApplication())
226 proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
227 err = proxyApp.Start()
228 require.Nil(t, err)
229 defer proxyApp.Stop() //nolint:errcheck // ignore for tests
230
231 logger := log.TestingLogger()
232
233 const height int64 = 1
234 state, stateDB, privVals := state(1, height)
235 stateStore := sm.NewStore(stateDB)
236 maxBytes := 16384
237 const partSize uint32 = 256
238 maxEvidenceBytes := int64(maxBytes / 2)
239 state.ConsensusParams.Block.MaxBytes = int64(maxBytes)
240 state.ConsensusParams.Evidence.MaxBytes = maxEvidenceBytes
241 proposerAddr, _ := state.Validators.GetByIndex(0)
242
243 mp := mempoolv0.NewCListMempool(
244 cfg.Mempool,
245 proxyApp.Mempool(),
246 state.LastBlockHeight,
247 mempoolv0.WithMetrics(mempool.NopMetrics()),
248 mempoolv0.WithPreCheck(sm.TxPreCheck(state)),
249 mempoolv0.WithPostCheck(sm.TxPostCheck(state)),
250 )
251 mp.SetLogger(logger)
252
253 // Make EvidencePool
254 evidenceDB := dbm.NewMemDB()
255 blockStore := store.NewBlockStore(dbm.NewMemDB())
256 evidencePool, err := evidence.NewPool(logger, evidenceDB, stateStore, blockStore)
257 require.NoError(t, err)
258
259 // fill the evidence pool with more evidence
260 // than can fit in a block
261 var currentBytes int64
262 for currentBytes <= maxEvidenceBytes {
263 ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), privVals[0], "test-chain")
264 currentBytes += int64(len(ev.Bytes()))
265 evidencePool.ReportConflictingVotes(ev.VoteA, ev.VoteB)
266 }
267
268 evList, size := evidencePool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
269 require.Less(t, size, state.ConsensusParams.Evidence.MaxBytes+1)
270 evData := &types.EvidenceData{Evidence: evList}
271 require.EqualValues(t, size, evData.ByteSize())
272
273 // fill the mempool with more txs
274 // than can fit in a block
275 txLength := 100
276 for i := 0; i <= maxBytes/txLength; i++ {
277 tx := tmrand.Bytes(txLength)
278 err := mp.CheckTx(context.Background(), tx, nil, mempool.TxInfo{})

Callers

nothing calls this directly

Calls 15

MempoolMethod · 0.95
SetLoggerMethod · 0.95
PendingEvidenceMethod · 0.95
ByteSizeMethod · 0.95
CheckTxMethod · 0.95
ConsensusMethod · 0.95
CreateProposalBlockMethod · 0.95
ValidateBlockMethod · 0.95
ResetTestRootFunction · 0.92
NewApplicationFunction · 0.92
NewAppConnsFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…