Skip to content

Commit

Permalink
v2/consortium_test: do not insert inserted blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco4203 committed Oct 23, 2024
1 parent d7f7646 commit 2e6654a
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions consensus/consortium/v2/consortium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,7 @@ func testSystemTransactionOrder(t *testing.T, scheme string) {
}

func TestIsPeriodBlock(t *testing.T) {
//testIsPeriodBlock(t, rawdb.PathScheme)
testIsPeriodBlock(t, rawdb.PathScheme)
testIsPeriodBlock(t, rawdb.HashScheme)
}

Expand Down Expand Up @@ -2292,17 +2292,25 @@ func testIsPeriodBlock(t *testing.T, scheme string) {
if c.IsPeriodBlock(chain, header, nil) {
t.Error("wrong period block")
}

newBs := make(types.Blocks, 0)
for i := 0; i < 210; i++ {
callback := func(i int, bg *core.BlockGen) {
if i == 0 {
bg.OffsetTime(int64(dayInSeconds))
}
}
block, _ := core.GenerateChain(&chainConfig, bs[len(bs)-1], ethash.NewFaker(), db, 1, callback, true)
bs = append(bs, block...)
if i == 0 {
block, _ := core.GenerateChain(&chainConfig, bs[len(bs)-1], ethash.NewFaker(), db, 1, callback, true)
newBs = append(newBs, block...)
bs = append(bs, block...)
} else {
block, _ := core.GenerateChain(&chainConfig, newBs[len(newBs)-1], ethash.NewFaker(), db, 1, callback, true)
newBs = append(newBs, block...)
bs = append(bs, block...)
}
}
if _, err := chain.InsertChain(bs[:], nil); err != nil {
// only insert newly generated blocks
if _, err := chain.InsertChain(newBs[:], nil); err != nil {
panic(err)
}

Expand Down Expand Up @@ -2330,8 +2338,7 @@ Will disable this test firstly for further investigation.
*/
func TestIsTrippEffective(t *testing.T) {
testIsTrippEffective(t, rawdb.HashScheme)
// testIsTrippEffective(t, rawdb.PathScheme)

testIsTrippEffective(t, rawdb.PathScheme)
}

func testIsTrippEffective(t *testing.T, scheme string) {
Expand Down Expand Up @@ -2408,16 +2415,25 @@ func testIsTrippEffective(t *testing.T, scheme string) {
t.Error("fail test Tripp effective")
}

newBs := make(types.Blocks, 0)
for i := 0; i < 210; i++ {
callback := func(i int, bg *core.BlockGen) {
if i == 0 {
bg.OffsetTime(int64(dayInSeconds))
}
}
block, _ := core.GenerateChain(&chainConfig, bs[len(bs)-1], ethash.NewFaker(), db, 1, callback, true)
bs = append(bs, block...)
if i == 0 {
block, _ := core.GenerateChain(&chainConfig, bs[len(bs)-1], ethash.NewFaker(), db, 1, callback, true)
newBs = append(newBs, block...)
bs = append(bs, block...)
} else {
block, _ := core.GenerateChain(&chainConfig, newBs[len(newBs)-1], ethash.NewFaker(), db, 1, callback, true)
newBs = append(newBs, block...)
bs = append(bs, block...)
}
}
if _, err := chain.InsertChain(bs[:], nil); err != nil {
// only insert newly generated blocks
if _, err := chain.InsertChain(newBs[:], nil); err != nil {
panic(err)
}

Expand Down

0 comments on commit 2e6654a

Please sign in to comment.