create a proposal block using real and full mempool and evidence pool and validate it.
(t *testing.T)
| 219 | // create a proposal block using real and full |
| 220 | // mempool and evidence pool and validate it. |
| 221 | func 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{}) |
nothing calls this directly
no test coverage detected
searching dependent graphs…