Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove newBs by only using bs[399:] here

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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason this still previously passed for Hash Scheme 🤔

if _, err := chain.InsertChain(newBs[:], nil); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly

panic(err)
}

Expand Down