(t *testing.T)
| 375 | } |
| 376 | |
| 377 | func TestMaxProposalBlockSize(t *testing.T) { |
| 378 | cfg, err := config.ResetTestRoot("node_create_proposal") |
| 379 | require.NoError(t, err) |
| 380 | defer os.RemoveAll(cfg.RootDir) |
| 381 | cc := abciclient.NewLocalCreator(kvstore.NewApplication()) |
| 382 | proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics()) |
| 383 | err = proxyApp.Start() |
| 384 | require.Nil(t, err) |
| 385 | defer proxyApp.Stop() //nolint:errcheck // ignore for tests |
| 386 | |
| 387 | logger := log.TestingLogger() |
| 388 | |
| 389 | state, stateDB, _ := state(types.MaxVotesCount, int64(1)) |
| 390 | stateStore := sm.NewStore(stateDB) |
| 391 | blockStore := store.NewBlockStore(dbm.NewMemDB()) |
| 392 | const maxBytes int64 = 1024 * 1024 * 2 |
| 393 | state.ConsensusParams.Block.MaxBytes = maxBytes |
| 394 | proposerAddr, _ := state.Validators.GetByIndex(0) |
| 395 | |
| 396 | // Make Mempool |
| 397 | mp := mempoolv0.NewCListMempool( |
| 398 | cfg.Mempool, |
| 399 | proxyApp.Mempool(), |
| 400 | state.LastBlockHeight, |
| 401 | mempoolv0.WithMetrics(mempool.NopMetrics()), |
| 402 | mempoolv0.WithPreCheck(sm.TxPreCheck(state)), |
| 403 | mempoolv0.WithPostCheck(sm.TxPostCheck(state)), |
| 404 | ) |
| 405 | mp.SetLogger(logger) |
| 406 | |
| 407 | // fill the mempool with one txs just below the maximum size |
| 408 | txLength := int(types.MaxDataBytesNoEvidence(maxBytes, types.MaxVotesCount)) |
| 409 | tx := tmrand.Bytes(txLength - 6) // to account for the varint |
| 410 | err = mp.CheckTx(context.Background(), tx, nil, mempool.TxInfo{}) |
| 411 | assert.NoError(t, err) |
| 412 | // now produce more txs than what a normal block can hold with 10 smaller txs |
| 413 | // At the end of the test, only the single big tx should be added |
| 414 | for i := 0; i < 10; i++ { |
| 415 | tx := tmrand.Bytes(10) |
| 416 | err = mp.CheckTx(context.Background(), tx, nil, mempool.TxInfo{}) |
| 417 | assert.NoError(t, err) |
| 418 | } |
| 419 | |
| 420 | blockExec := sm.NewBlockExecutor( |
| 421 | stateStore, |
| 422 | logger, |
| 423 | proxyApp.Consensus(), |
| 424 | mp, |
| 425 | sm.EmptyEvidencePool{}, |
| 426 | blockStore, |
| 427 | ) |
| 428 | |
| 429 | blockID := types.BlockID{ |
| 430 | Hash: tmhash.Sum([]byte("blockID_hash")), |
| 431 | PartSetHeader: types.PartSetHeader{ |
| 432 | Total: math.MaxInt32, |
| 433 | Hash: tmhash.Sum([]byte("blockID_part_set_header_hash")), |
| 434 | }, |
nothing calls this directly
no test coverage detected
searching dependent graphs…