create a proposal block using real and full mempool and evidence pool and validate it.
(t *testing.T)
| 223 | // create a proposal block using real and full |
| 224 | // mempool and evidence pool and validate it. |
| 225 | func TestCreateProposalBlock(t *testing.T) { |
| 226 | config := cfg.ResetTestRoot("node_create_proposal") |
| 227 | defer os.RemoveAll(config.RootDir) |
| 228 | cc := proxy.NewLocalClientCreator(kvstore.NewApplication(cfg.GetDefaultDBDir())) |
| 229 | proxyApp := proxy.NewAppConns(cc) |
| 230 | err := proxyApp.Start() |
| 231 | require.Nil(t, err) |
| 232 | defer proxyApp.Stop() //nolint:errcheck // ignore for tests |
| 233 | |
| 234 | logger := log.TestingLogger() |
| 235 | |
| 236 | var height int64 = 1 |
| 237 | state, stateDB, privVals := state(1, height) |
| 238 | stateStore := sm.NewStore(stateDB, sm.StoreOptions{ |
| 239 | DiscardABCIResponses: false, |
| 240 | }) |
| 241 | maxBytes := 16384 |
| 242 | var partSize uint32 = 256 |
| 243 | maxEvidenceBytes := int64(maxBytes / 2) |
| 244 | state.ConsensusParams.Block.MaxBytes = int64(maxBytes) |
| 245 | state.ConsensusParams.Evidence.MaxBytes = maxEvidenceBytes |
| 246 | proposerAddr, _ := state.Validators.GetByIndex(0) |
| 247 | |
| 248 | // Make Mempool |
| 249 | memplMetrics := mempl.NopMetrics() |
| 250 | var mempool mempl.Mempool |
| 251 | |
| 252 | switch config.Mempool.Version { |
| 253 | case cfg.MempoolV0: |
| 254 | mempool = mempoolv0.NewCListMempool(config.Mempool, |
| 255 | proxyApp.Mempool(), |
| 256 | state.LastBlockHeight, |
| 257 | mempoolv0.WithMetrics(memplMetrics), |
| 258 | mempoolv0.WithPreCheck(sm.TxPreCheck(state)), |
| 259 | mempoolv0.WithPostCheck(sm.TxPostCheck(state))) |
| 260 | case cfg.MempoolV1: |
| 261 | mempool = mempoolv1.NewTxMempool(logger, |
| 262 | config.Mempool, |
| 263 | proxyApp.Mempool(), |
| 264 | state.LastBlockHeight, |
| 265 | mempoolv1.WithMetrics(memplMetrics), |
| 266 | mempoolv1.WithPreCheck(sm.TxPreCheck(state)), |
| 267 | mempoolv1.WithPostCheck(sm.TxPostCheck(state)), |
| 268 | ) |
| 269 | } |
| 270 | |
| 271 | // Make EvidencePool |
| 272 | evidenceDB := dbm.NewMemDB() |
| 273 | blockStore := store.NewBlockStore(dbm.NewMemDB()) |
| 274 | evidencePool, err := evidence.NewPool(evidenceDB, stateStore, blockStore) |
| 275 | require.NoError(t, err) |
| 276 | evidencePool.SetLogger(logger) |
| 277 | |
| 278 | // fill the evidence pool with more evidence |
| 279 | // than can fit in a block |
| 280 | var currentBytes int64 |
| 281 | for currentBytes <= maxEvidenceBytes { |
| 282 | ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), privVals[0], "test-chain") |
nothing calls this directly
no test coverage detected