MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / TestMaxProposalBlockSize

Function TestMaxProposalBlockSize

node/node_test.go:332–403  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

330}
331
332func TestMaxProposalBlockSize(t *testing.T) {
333 config := cfg.ResetTestRoot("node_create_proposal")
334 defer os.RemoveAll(config.RootDir)
335 cc := proxy.NewLocalClientCreator(kvstore.NewApplication(cfg.GetDefaultDBDir()))
336 proxyApp := proxy.NewAppConns(cc)
337 err := proxyApp.Start()
338 require.Nil(t, err)
339 defer proxyApp.Stop() //nolint:errcheck // ignore for tests
340
341 logger := log.TestingLogger()
342
343 var height int64 = 1
344 state, stateDB, _ := state(1, height)
345 stateStore := sm.NewStore(stateDB, sm.StoreOptions{
346 DiscardABCIResponses: false,
347 })
348 var maxBytes int64 = 16384
349 var partSize uint32 = 256
350 state.ConsensusParams.Block.MaxBytes = maxBytes
351 proposerAddr, _ := state.Validators.GetByIndex(0)
352
353 // Make Mempool
354 memplMetrics := mempl.NopMetrics()
355 var mempool mempl.Mempool
356 switch config.Mempool.Version {
357 case cfg.MempoolV0:
358 mempool = mempoolv0.NewCListMempool(config.Mempool,
359 proxyApp.Mempool(),
360 state.LastBlockHeight,
361 mempoolv0.WithMetrics(memplMetrics),
362 mempoolv0.WithPreCheck(sm.TxPreCheck(state)),
363 mempoolv0.WithPostCheck(sm.TxPostCheck(state)))
364 case cfg.MempoolV1:
365 mempool = mempoolv1.NewTxMempool(logger,
366 config.Mempool,
367 proxyApp.Mempool(),
368 state.LastBlockHeight,
369 mempoolv1.WithMetrics(memplMetrics),
370 mempoolv1.WithPreCheck(sm.TxPreCheck(state)),
371 mempoolv1.WithPostCheck(sm.TxPostCheck(state)),
372 )
373 }
374
375 // fill the mempool with one txs just below the maximum size
376 txLength := int(types.MaxDataBytesNoEvidence(maxBytes, 1))
377 tx := tmrand.Bytes(txLength - 4) // to account for the varint
378 err = mempool.CheckTx(tx, nil, mempl.TxInfo{})
379 assert.NoError(t, err)
380
381 blockExec := sm.NewBlockExecutor(
382 stateStore,
383 logger,
384 proxyApp.Consensus(),
385 mempool,
386 sm.EmptyEvidencePool{},
387 )
388
389 commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)

Callers

nothing calls this directly

Calls 15

MempoolMethod · 0.95
CheckTxMethod · 0.95
ConsensusMethod · 0.95
CreateProposalBlockMethod · 0.95
NewLocalClientCreatorFunction · 0.92
NewApplicationFunction · 0.92
NewAppConnsFunction · 0.92
TestingLoggerFunction · 0.92
MaxDataBytesNoEvidenceFunction · 0.92
NewCommitFunction · 0.92
MakePartSetMethod · 0.80
stateFunction · 0.70

Tested by

no test coverage detected