From 5e0cca02df911070acb154c567c04bffdb159dbc Mon Sep 17 00:00:00 2001 From: meows Date: Thu, 2 Nov 2023 09:37:17 -0600 Subject: [PATCH 1/2] core/forkid: implement GatherForks test for time-based forks This should have been tested already, but was overlooked. Tests are passing. Date: 2023-11-02 09:37:17-06:00 Signed-off-by: meows --- core/forkid/forkid_test.go | 40 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/core/forkid/forkid_test.go b/core/forkid/forkid_test.go index 680e10b41a..e299d6d284 100644 --- a/core/forkid/forkid_test.go +++ b/core/forkid/forkid_test.go @@ -483,29 +483,34 @@ func TestEncoding(t *testing.T) { func TestGatherForks(t *testing.T) { cases := []struct { - name string - config ctypes.ChainConfigurator - wantNs []uint64 + name string + config ctypes.ChainConfigurator + blockForks []uint64 + timeForks []uint64 }{ { "classic", params.ClassicChainConfig, []uint64{1150000, 2500000, 3000000, 5000000, 5900000, 8772000, 9573000, 10500839, 11_700_000, 13_189_133, 14_525_000}, + []uint64{}, }, { "mainnet", params.MainnetChainConfig, []uint64{1150000, 1920000, 2463000, 2675000, 4370000, 7280000, 9069000, 9200000, 12_244_000, 12_965_000, 13_773_000, 15050000}, + []uint64{1681338455 /* ShanghaiTime */}, }, { "mordor", params.MordorChainConfig, []uint64{301_243, 999_983, 2_520_000, 3_985_893, 5_520_000, 9_957_000}, + []uint64{}, }, { "mintme", params.MintMeChainConfig, []uint64{252_500}, + []uint64{}, }, } sliceContains := func(sl []uint64, u uint64) bool { @@ -516,20 +521,25 @@ func TestGatherForks(t *testing.T) { } return false } - for _, c := range cases { - blockForks, _ := gatherForks(c.config) - if len(blockForks) != len(c.wantNs) { - for _, n := range c.wantNs { - if !sliceContains(blockForks, n) { - t.Errorf("config=%s missing wanted fork at block number: %d", c.name, n) - } - } - for _, n := range blockForks { - if !sliceContains(c.wantNs, n) { - t.Errorf("config=%s gathered unwanted fork at block number: %d", c.name, n) - } + slicesEquivalent := func(sl1, sl2 []uint64) bool { + if len(sl1) != len(sl2) { + return false + } + for _, s := range sl1 { + if !sliceContains(sl2, s) { + return false } } + return true + } + for _, c := range cases { + blockForks, timeForks := gatherForks(c.config) + if !slicesEquivalent(blockForks, c.blockForks) { + t.Errorf("config=%s block forks mismatch: have %v, want %v", c.name, blockForks, c.blockForks) + } + if !slicesEquivalent(timeForks, c.timeForks) { + t.Errorf("config=%s time forks mismatch: have %v, want %v", c.name, timeForks, c.timeForks) + } } } From 3de7c5542cf8cfe2c1ff26fe4c88b73580bd7399 Mon Sep 17 00:00:00 2001 From: meows Date: Thu, 2 Nov 2023 09:40:23 -0600 Subject: [PATCH 2/2] core/forkid: add GatherForks test cases for goerli, sepolia Being default-availble networks, they should have tests. Date: 2023-11-02 09:40:23-06:00 Signed-off-by: meows --- core/forkid/forkid_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/forkid/forkid_test.go b/core/forkid/forkid_test.go index e299d6d284..5a709b9026 100644 --- a/core/forkid/forkid_test.go +++ b/core/forkid/forkid_test.go @@ -500,6 +500,18 @@ func TestGatherForks(t *testing.T) { []uint64{1150000, 1920000, 2463000, 2675000, 4370000, 7280000, 9069000, 9200000, 12_244_000, 12_965_000, 13_773_000, 15050000}, []uint64{1681338455 /* ShanghaiTime */}, }, + { + "goerli", + params.GoerliChainConfig, + []uint64{1_561_651, 4_460_644, 5_062_605}, + []uint64{1678832736 /* ShanghaiTime */}, + }, + { + "sepolia", + params.SepoliaChainConfig, + []uint64{1735371 /* Merge NetSplit */}, + []uint64{1677557088 /* ShanghaiTime */}, + }, { "mordor", params.MordorChainConfig,