Skip to content

Commit c5a4054

Browse files
committed
fix reorg side even test case
1 parent 4ca35d7 commit c5a4054

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

core/blockchain_test.go

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,16 +1309,16 @@ func TestReorgSideEvent(t *testing.T) {
13091309
blockchain, _ := NewBlockChain(db, nil, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
13101310
defer blockchain.Stop()
13111311

1312-
chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 3, func(i int, gen *BlockGen) {})
1312+
chain, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 11, func(i int, gen *BlockGen) {})
13131313
if _, err := blockchain.InsertChain(chain); err != nil {
13141314
t.Fatalf("failed to insert chain: %v", err)
13151315
}
13161316

1317-
replacementBlocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 4, func(i int, gen *BlockGen) {
1317+
replacementBlocks, _ := GenerateChain(gspec.Config, genesis, ethash.NewFaker(), db, 11, func(i int, gen *BlockGen) {
13181318
tx, err := types.SignTx(types.NewContractCreation(gen.TxNonce(addr1), new(big.Int), 1000000, gen.header.BaseFee, nil), signer, key1)
1319-
if i == 2 {
1320-
gen.OffsetTime(-9)
1321-
}
1319+
1320+
gen.OffsetTime(-9)
1321+
13221322
if err != nil {
13231323
t.Fatalf("failed to create tx: %v", err)
13241324
}
@@ -1330,20 +1330,37 @@ func TestReorgSideEvent(t *testing.T) {
13301330
t.Fatalf("failed to insert chain: %v", err)
13311331
}
13321332

1333-
// first two block of the secondary chain are for a brief moment considered
1333+
// first 10 blocks of the secondary chain are for a brief moment considered
13341334
// side chains because up to that point the first one is considered the
13351335
// heavier chain.
13361336
expectedSideHashes := map[common.Hash]bool{
13371337
replacementBlocks[0].Hash(): true,
13381338
replacementBlocks[1].Hash(): true,
1339-
chain[0].Hash(): true,
1340-
chain[1].Hash(): true,
1341-
chain[2].Hash(): true,
1339+
replacementBlocks[2].Hash(): true,
1340+
replacementBlocks[3].Hash(): true,
1341+
replacementBlocks[4].Hash(): true,
1342+
replacementBlocks[5].Hash(): true,
1343+
replacementBlocks[6].Hash(): true,
1344+
replacementBlocks[7].Hash(): true,
1345+
replacementBlocks[8].Hash(): true,
1346+
replacementBlocks[9].Hash(): true,
1347+
1348+
chain[0].Hash(): true,
1349+
chain[1].Hash(): true,
1350+
chain[2].Hash(): true,
1351+
chain[3].Hash(): true,
1352+
chain[4].Hash(): true,
1353+
chain[5].Hash(): true,
1354+
chain[6].Hash(): true,
1355+
chain[7].Hash(): true,
1356+
chain[8].Hash(): true,
1357+
chain[9].Hash(): true,
1358+
chain[10].Hash(): true,
13421359
}
13431360

13441361
i := 0
13451362

1346-
const timeoutDura = 10 * time.Second
1363+
const timeoutDura = 100 * time.Second
13471364
timeout := time.NewTimer(timeoutDura)
13481365
done:
13491366
for {

0 commit comments

Comments
 (0)