-
Notifications
You must be signed in to change notification settings - Fork 4
feat: support Boho hardfork in genesis generator #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/params" | ||
| ) | ||
|
|
||
| func TestMakeGenerator_BohoBlockDefaultZero(t *testing.T) { | ||
| g := makeGenerator("test") | ||
|
|
||
| if g.Genesis.Config.BohoBlock == nil { | ||
| t.Fatal("BohoBlock should be set by default") | ||
| } | ||
| if g.Genesis.Config.BohoBlock.Int64() != 0 { | ||
| t.Errorf("BohoBlock = %d, want 0", g.Genesis.Config.BohoBlock.Int64()) | ||
| } | ||
| // Boho AnzeonConfig should be nil until setBohoConfig is called | ||
| if g.Genesis.Config.Boho != nil { | ||
| t.Error("Boho AnzeonConfig should be nil by default") | ||
| } | ||
| } | ||
|
|
||
| func TestSetBohoConfig_OverridesDefaultBlock(t *testing.T) { | ||
| g := makeGenerator("test") | ||
|
|
||
| // makeGenerator sets BohoBlock to 0 | ||
| if g.Genesis.Config.BohoBlock.Int64() != 0 { | ||
| t.Fatalf("precondition: BohoBlock should be 0, got %d", g.Genesis.Config.BohoBlock.Int64()) | ||
| } | ||
|
|
||
| // setBohoConfig should override to the user-specified value | ||
| g.setBohoConfig(500) | ||
| if got := g.Genesis.Config.BohoBlock.Int64(); got != 500 { | ||
| t.Errorf("BohoBlock = %d, want 500", got) | ||
| } | ||
| } | ||
|
|
||
| func TestSetBohoConfig_BlockNumber(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| block int | ||
| wantBlock int64 | ||
| }{ | ||
| {"genesis activation", 0, 0}, | ||
| {"delayed activation", 100, 100}, | ||
| {"large block number", 1000000, 1000000}, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| g := makeGenerator("test") | ||
| g.setBohoConfig(tt.block) | ||
|
|
||
| if g.Genesis.Config.BohoBlock == nil { | ||
| t.Fatal("BohoBlock should be set") | ||
| } | ||
| if got := g.Genesis.Config.BohoBlock.Int64(); got != tt.wantBlock { | ||
| t.Errorf("BohoBlock = %d, want %d", got, tt.wantBlock) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestSetBohoConfig_GovMinterV2(t *testing.T) { | ||
| g := makeGenerator("test") | ||
| g.setBohoConfig(0) | ||
|
|
||
| boho := g.Genesis.Config.Boho | ||
| if boho == nil { | ||
| t.Fatal("Boho config should be set") | ||
| } | ||
| if boho.SystemContracts == nil || boho.SystemContracts.GovMinter == nil { | ||
| t.Fatal("Boho GovMinter should not be nil") | ||
| } | ||
| if got := boho.SystemContracts.GovMinter.Address; got != params.DefaultGovMinterAddress { | ||
| t.Errorf("Boho GovMinter address = %v, want %v", got, params.DefaultGovMinterAddress) | ||
| } | ||
| if got := boho.SystemContracts.GovMinter.Version; got != "v2" { | ||
| t.Errorf("Boho GovMinter version = %q, want %q", got, "v2") | ||
| } | ||
| } | ||
|
|
||
| func TestSetBohoConfig_OnlyContainsGovMinter(t *testing.T) { | ||
| g := makeGenerator("test") | ||
| g.setBohoConfig(0) | ||
|
|
||
| boho := g.Genesis.Config.Boho | ||
| if boho.WBFT != nil { | ||
| t.Error("Boho should not contain WBFT config") | ||
| } | ||
| if boho.Init != nil { | ||
| t.Error("Boho should not contain Init config") | ||
| } | ||
| sc := boho.SystemContracts | ||
| if sc.GovValidator != nil { | ||
| t.Error("Boho should not override GovValidator") | ||
| } | ||
| if sc.NativeCoinAdapter != nil { | ||
| t.Error("Boho should not override NativeCoinAdapter") | ||
| } | ||
| if sc.GovMasterMinter != nil { | ||
| t.Error("Boho should not override GovMasterMinter") | ||
| } | ||
| if sc.GovCouncil != nil { | ||
| t.Error("Boho should not override GovCouncil") | ||
| } | ||
| } | ||
|
|
||
| func TestSetAnzeonConfigBase_GovMinterV1(t *testing.T) { | ||
| g := makeGenerator("test") | ||
|
|
||
| validators := []common.Address{ | ||
| common.HexToAddress("0x1111111111111111111111111111111111111111"), | ||
| } | ||
| blsKeys := []string{"0xaa" + strings.Repeat("bb", 47)} | ||
|
|
||
| g.setAnzeonConfigBase(validators, blsKeys, 1) | ||
|
|
||
| if g.Genesis.Config.Anzeon == nil { | ||
| t.Fatal("Anzeon config should be set") | ||
| } | ||
| if got := g.Genesis.Config.Anzeon.SystemContracts.GovMinter.Version; got != "v1" { | ||
| t.Errorf("Anzeon GovMinter version = %q, want %q", got, "v1") | ||
| } | ||
| // setAnzeonConfigBase should NOT set Boho config (that's setBohoConfig's job) | ||
| if g.Genesis.Config.Boho != nil { | ||
| t.Error("Boho AnzeonConfig should not be set by setAnzeonConfigBase") | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.