From 1d0c877e69e8fd2b68ad508432b2da3fb2ec8f80 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 2 Mar 2023 16:00:05 +0300 Subject: [PATCH 1/5] add verify allow list tests --- precompile/allowlist/allowlist_test.go | 10 ++- precompile/allowlist/config.go | 6 +- precompile/allowlist/config_test.go | 45 ++-------- precompile/allowlist/test_allowlist.go | 19 ---- precompile/allowlist/test_allowlist_config.go | 87 +++++++++++++++++++ precompile/testutils/test_config.go | 14 +++ 6 files changed, 117 insertions(+), 64 deletions(-) create mode 100644 precompile/allowlist/test_allowlist_config.go create mode 100644 precompile/testutils/test_config.go diff --git a/precompile/allowlist/allowlist_test.go b/precompile/allowlist/allowlist_test.go index f4c0f5fc21..4f0eeb3b51 100644 --- a/precompile/allowlist/allowlist_test.go +++ b/precompile/allowlist/allowlist_test.go @@ -22,14 +22,18 @@ var ( ) type dummyConfig struct { - *AllowListConfig + AllowListConfig } func (d *dummyConfig) Key() string { return "dummy" } func (d *dummyConfig) Timestamp() *big.Int { return common.Big0 } func (d *dummyConfig) IsDisabled() bool { return false } -func (d *dummyConfig) Equal(other precompileconfig.Config) bool { - return d.AllowListConfig.Equal(other.(*dummyConfig).AllowListConfig) +func (d *dummyConfig) Equal(cfg precompileconfig.Config) bool { + other, ok := (cfg).(*dummyConfig) + if !ok { + return false + } + return d.AllowListConfig.Equal(&other.AllowListConfig) } type dummyConfigurator struct{} diff --git a/precompile/allowlist/config.go b/precompile/allowlist/config.go index 90ef49a811..7c20841c78 100644 --- a/precompile/allowlist/config.go +++ b/precompile/allowlist/config.go @@ -58,7 +58,7 @@ func (c *AllowListConfig) Verify() error { // check for duplicates in enabled list for _, enabledAddr := range c.EnabledAddresses { if _, ok := addressMap[enabledAddr]; ok { - return fmt.Errorf("duplicate address %s in enabled list", enabledAddr) + return fmt.Errorf("duplicate address in enabled list: %s", enabledAddr) } addressMap[enabledAddr] = EnabledRole } @@ -67,9 +67,9 @@ func (c *AllowListConfig) Verify() error { for _, adminAddr := range c.AdminAddresses { if role, ok := addressMap[adminAddr]; ok { if role == AdminRole { - return fmt.Errorf("duplicate address %s in admin list", adminAddr) + return fmt.Errorf("duplicate address in admin list: %s", adminAddr) } else { - return fmt.Errorf("cannot set address %s as both admin and enabled", adminAddr) + return fmt.Errorf("cannot set address as both admin and enabled: %s", adminAddr) } } addressMap[adminAddr] = AdminRole diff --git a/precompile/allowlist/config_test.go b/precompile/allowlist/config_test.go index bc3a3d9d26..2091384c5f 100644 --- a/precompile/allowlist/config_test.go +++ b/precompile/allowlist/config_test.go @@ -6,51 +6,18 @@ package allowlist import ( "testing" + "github.com/ava-labs/subnet-evm/precompile/modules" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" ) func TestVerifyAllowlistAllowList(t *testing.T) { - admins := []common.Address{{1}} - enableds := []common.Address{{2}} - tests := []struct { - name string - config AllowListConfig - expectedError string - }{ - { - name: "invalid allow list config in allowlist", - config: AllowListConfig{admins, admins}, - expectedError: "cannot set address", - }, - { - name: "nil member allow list config in allowlist", - config: AllowListConfig{nil, nil}, - expectedError: "", - }, - { - name: "empty member allow list config in allowlist", - config: AllowListConfig{[]common.Address{}, []common.Address{}}, - expectedError: "", - }, - { - name: "valid allow list config in allowlist", - config: AllowListConfig{admins, enableds}, - expectedError: "", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - err := tt.config.Verify() - if tt.expectedError == "" { - require.NoError(err) - } else { - require.ErrorContains(err, tt.expectedError) - } - }) + dummyModule := modules.Module{ + Address: dummyAddr, + Contract: CreateAllowListPrecompile(dummyAddr), + Configurator: &dummyConfigurator{}, } + VerifyPrecompileWithAllowListTests(t, dummyModule, nil) } func TestEqualAllowListAllowList(t *testing.T) { diff --git a/precompile/allowlist/test_allowlist.go b/precompile/allowlist/test_allowlist.go index 78158e55ee..233ade3f65 100644 --- a/precompile/allowlist/test_allowlist.go +++ b/precompile/allowlist/test_allowlist.go @@ -4,12 +4,10 @@ package allowlist import ( - "encoding/json" "testing" "github.com/ava-labs/subnet-evm/precompile/contract" "github.com/ava-labs/subnet-evm/precompile/modules" - "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ava-labs/subnet-evm/vmerrs" "github.com/ethereum/go-ethereum/common" @@ -22,23 +20,6 @@ var ( TestNoRoleAddr = common.HexToAddress("0x0000000000000000000000000000000000000033") ) -// mkConfigWithAllowList creates a new config with the correct type for [module] -// by marshalling [cfg] to JSON and then unmarshalling it into the config. -func mkConfigWithAllowList(module modules.Module, cfg *AllowListConfig) precompileconfig.Config { - jsonBytes, err := json.Marshal(cfg) - if err != nil { - panic(err) - } - - moduleCfg := module.MakeConfig() - err = json.Unmarshal(jsonBytes, moduleCfg) - if err != nil { - panic(err) - } - - return moduleCfg -} - func AllowListTests(module modules.Module) map[string]testutils.PrecompileTest { contractAddress := module.Address return map[string]testutils.PrecompileTest{ diff --git a/precompile/allowlist/test_allowlist_config.go b/precompile/allowlist/test_allowlist_config.go new file mode 100644 index 0000000000..d38702b30e --- /dev/null +++ b/precompile/allowlist/test_allowlist_config.go @@ -0,0 +1,87 @@ +// (c) 2019-2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package allowlist + +import ( + "encoding/json" + "testing" + + "github.com/ava-labs/subnet-evm/precompile/modules" + "github.com/ava-labs/subnet-evm/precompile/precompileconfig" + "github.com/ava-labs/subnet-evm/precompile/testutils" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/require" +) + +// mkConfigWithAllowList creates a new config with the correct type for [module] +// by marshalling [cfg] to JSON and then unmarshalling it into the config. +func mkConfigWithAllowList(module modules.Module, cfg *AllowListConfig) precompileconfig.Config { + jsonBytes, err := json.Marshal(cfg) + if err != nil { + panic(err) + } + + moduleCfg := module.MakeConfig() + err = json.Unmarshal(jsonBytes, moduleCfg) + if err != nil { + panic(err) + } + + return moduleCfg +} + +func AllowListConfigVerifyTests(module modules.Module) map[string]testutils.ConfigVerifyTest { + return map[string]testutils.ConfigVerifyTest{ + "invalid allow list config with duplicate admins in allowlist": { + Config: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{TestAdminAddr, TestAdminAddr}, nil}), + ExpectedError: "duplicate address in admin list", + }, + "invalid allow list config with duplicate enableds in allowlist": { + Config: mkConfigWithAllowList(module, &AllowListConfig{nil, []common.Address{TestEnabledAddr, TestEnabledAddr}}), + ExpectedError: "duplicate address in enabled list", + }, + "invalid allow list config with same admin and enabled in allowlist": { + Config: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{TestAdminAddr}, []common.Address{TestAdminAddr}}), + ExpectedError: "cannot set address as both admin and enabled", + }, + "nil member allow list config in allowlist": { + Config: mkConfigWithAllowList(module, &AllowListConfig{nil, nil}), + ExpectedError: "", + }, + "empty member allow list config in allowlist": { + Config: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{}, []common.Address{}}), + ExpectedError: "", + }, + "valid allow list config in allowlist": { + Config: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{TestAdminAddr}, []common.Address{TestEnabledAddr}}), + ExpectedError: "", + }, + } +} + +func VerifyPrecompileWithAllowListTests(t *testing.T, module modules.Module, verifyTests map[string]testutils.ConfigVerifyTest) { + t.Helper() + tests := AllowListConfigVerifyTests(module) + // Add the contract specific tests to the map of tests to run. + for name, test := range verifyTests { + if _, exists := tests[name]; exists { + t.Fatalf("duplicate test name: %s", name) + } + tests[name] = test + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + t.Helper() + require := require.New(t) + + err := test.Config.Verify() + if test.ExpectedError == "" { + require.NoError(err) + } else { + require.ErrorContains(err, test.ExpectedError) + } + }) + } +} diff --git a/precompile/testutils/test_config.go b/precompile/testutils/test_config.go new file mode 100644 index 0000000000..9d58f65fd5 --- /dev/null +++ b/precompile/testutils/test_config.go @@ -0,0 +1,14 @@ +// (c) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package testutils + +import ( + "github.com/ava-labs/subnet-evm/precompile/precompileconfig" +) + +// PrecompileConfigTest is a test case for precompile configs +type ConfigVerifyTest struct { + Config precompileconfig.Config + ExpectedError string +} From bea4567fd048cb7ffb1b7177c382ca80ebece10d Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 2 Mar 2023 16:17:26 +0300 Subject: [PATCH 2/5] use new verify allow list suite in precompiles --- .../deployerallowlist/config_test.go | 26 +---------- .../contracts/feemanager/config_test.go | 37 ++++----------- .../contracts/nativeminter/config_test.go | 46 ++++++------------- .../contracts/rewardmanager/config_test.go | 31 +++---------- .../contracts/txallowlist/config_test.go | 42 +---------------- 5 files changed, 32 insertions(+), 150 deletions(-) diff --git a/precompile/contracts/deployerallowlist/config_test.go b/precompile/contracts/deployerallowlist/config_test.go index caa3d8995a..6d30525599 100644 --- a/precompile/contracts/deployerallowlist/config_test.go +++ b/precompile/contracts/deployerallowlist/config_test.go @@ -7,36 +7,14 @@ import ( "math/big" "testing" + "github.com/ava-labs/subnet-evm/precompile/allowlist" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" ) func TestVerifyContractDeployerConfig(t *testing.T) { - admins := []common.Address{{1}} - tests := []struct { - name string - config precompileconfig.Config - ExpectedError string - }{ - { - name: "invalid allow list config in deployer allowlist", - config: NewConfig(big.NewInt(3), admins, admins), - ExpectedError: "cannot set address", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - err := tt.config.Verify() - if tt.ExpectedError == "" { - require.NoError(err) - } else { - require.ErrorContains(err, tt.ExpectedError) - } - }) - } + allowlist.VerifyPrecompileWithAllowListTests(t, Module, nil) } func TestEqualContractDeployerAllowListConfig(t *testing.T) { diff --git a/precompile/contracts/feemanager/config_test.go b/precompile/contracts/feemanager/config_test.go index 4b5654d5d9..e27e3abe1b 100644 --- a/precompile/contracts/feemanager/config_test.go +++ b/precompile/contracts/feemanager/config_test.go @@ -8,7 +8,9 @@ import ( "testing" "github.com/ava-labs/subnet-evm/commontype" + "github.com/ava-labs/subnet-evm/precompile/allowlist" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" + "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" ) @@ -30,39 +32,16 @@ func TestVerifyFeeManagerConfig(t *testing.T) { admins := []common.Address{{1}} invalidFeeConfig := validFeeConfig invalidFeeConfig.GasLimit = big.NewInt(0) - tests := []struct { - name string - config precompileconfig.Config - ExpectedError string - }{ - { - name: "invalid allow list config in fee manager allowlist", - config: NewConfig(big.NewInt(3), admins, admins, nil), - ExpectedError: "cannot set address", - }, - { - name: "invalid initial fee manager config", - config: NewConfig(big.NewInt(3), admins, nil, &invalidFeeConfig), + tests := map[string]testutils.ConfigVerifyTest{ + "invalid initial fee manager config": { + Config: NewConfig(big.NewInt(3), admins, nil, &invalidFeeConfig), ExpectedError: "gasLimit = 0 cannot be less than or equal to 0", - }, - { - name: "nil initial fee manager config", - config: NewConfig(big.NewInt(3), admins, nil, &commontype.FeeConfig{}), + }, "nil initial fee manager config": { + Config: NewConfig(big.NewInt(3), admins, nil, &commontype.FeeConfig{}), ExpectedError: "gasLimit cannot be nil", }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - err := tt.config.Verify() - if tt.ExpectedError == "" { - require.NoError(err) - } else { - require.ErrorContains(err, tt.ExpectedError) - } - }) - } + allowlist.VerifyPrecompileWithAllowListTests(t, Module, tests) } func TestEqualFeeManagerConfig(t *testing.T) { diff --git a/precompile/contracts/nativeminter/config_test.go b/precompile/contracts/nativeminter/config_test.go index 1927a93b9b..026c58a9c5 100644 --- a/precompile/contracts/nativeminter/config_test.go +++ b/precompile/contracts/nativeminter/config_test.go @@ -7,7 +7,9 @@ import ( "math/big" "testing" + "github.com/ava-labs/subnet-evm/precompile/allowlist" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" + "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/stretchr/testify/require" @@ -16,38 +18,29 @@ import ( func TestVerifyContractNativeMinterConfig(t *testing.T) { admins := []common.Address{{1}} enableds := []common.Address{{2}} - tests := []struct { - name string - config precompileconfig.Config - ExpectedError string - }{ - { - name: "invalid allow list config in native minter allowlist", - config: NewConfig(big.NewInt(3), admins, admins, nil), + tests := map[string]testutils.ConfigVerifyTest{ + "invalid allow list config in native minter allowlist": { + Config: NewConfig(big.NewInt(3), admins, admins, nil), ExpectedError: "cannot set address", }, - { - name: "duplicate admins in config in native minter allowlist", - config: NewConfig(big.NewInt(3), append(admins, admins[0]), enableds, nil), + "duplicate admins in config in native minter allowlist": { + Config: NewConfig(big.NewInt(3), append(admins, admins[0]), enableds, nil), ExpectedError: "duplicate address", }, - { - name: "duplicate enableds in config in native minter allowlist", - config: NewConfig(big.NewInt(3), admins, append(enableds, enableds[0]), nil), + "duplicate enableds in config in native minter allowlist": { + Config: NewConfig(big.NewInt(3), admins, append(enableds, enableds[0]), nil), ExpectedError: "duplicate address", }, - { - name: "nil amount in native minter config", - config: NewConfig(big.NewInt(3), admins, nil, + "nil amount in native minter config": { + Config: NewConfig(big.NewInt(3), admins, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(123), common.HexToAddress("0x02"): nil, }), ExpectedError: "initial mint cannot contain nil", }, - { - name: "negative amount in native minter config", - config: NewConfig(big.NewInt(3), admins, nil, + "negative amount in native minter config": { + Config: NewConfig(big.NewInt(3), admins, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(123), common.HexToAddress("0x02"): math.NewHexOrDecimal256(-1), @@ -55,18 +48,7 @@ func TestVerifyContractNativeMinterConfig(t *testing.T) { ExpectedError: "initial mint cannot contain invalid amount", }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - err := tt.config.Verify() - if tt.ExpectedError == "" { - require.NoError(err) - } else { - require.ErrorContains(err, tt.ExpectedError) - } - }) - } + allowlist.VerifyPrecompileWithAllowListTests(t, Module, tests) } func TestEqualContractNativeMinterConfig(t *testing.T) { diff --git a/precompile/contracts/rewardmanager/config_test.go b/precompile/contracts/rewardmanager/config_test.go index c78dec4c6f..80902d3309 100644 --- a/precompile/contracts/rewardmanager/config_test.go +++ b/precompile/contracts/rewardmanager/config_test.go @@ -7,7 +7,9 @@ import ( "math/big" "testing" + "github.com/ava-labs/subnet-evm/precompile/allowlist" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" + "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" ) @@ -15,37 +17,16 @@ import ( func TestVerifyRewardManagerConfig(t *testing.T) { admins := []common.Address{{1}} enableds := []common.Address{{2}} - tests := []struct { - name string - config precompileconfig.Config - ExpectedError string - }{ - { - name: "duplicate enableds in config in reward manager allowlist", - config: NewConfig(big.NewInt(3), admins, append(enableds, enableds[0]), nil), - ExpectedError: "duplicate address", - }, - { - name: "both reward mechanisms should not be activated at the same time in reward manager", - config: NewConfig(big.NewInt(3), admins, enableds, &InitialRewardConfig{ + tests := map[string]testutils.ConfigVerifyTest{ + "both reward mechanisms should not be activated at the same time in reward manager": { + Config: NewConfig(big.NewInt(3), admins, enableds, &InitialRewardConfig{ AllowFeeRecipients: true, RewardAddress: common.HexToAddress("0x01"), }), ExpectedError: ErrCannotEnableBothRewards.Error(), }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - err := tt.config.Verify() - if tt.ExpectedError == "" { - require.NoError(err) - } else { - require.ErrorContains(err, tt.ExpectedError) - } - }) - } + allowlist.VerifyPrecompileWithAllowListTests(t, Module, tests) } func TestEqualRewardManagerConfig(t *testing.T) { diff --git a/precompile/contracts/txallowlist/config_test.go b/precompile/contracts/txallowlist/config_test.go index 54ab46ac34..4a7375862c 100644 --- a/precompile/contracts/txallowlist/config_test.go +++ b/precompile/contracts/txallowlist/config_test.go @@ -7,52 +7,14 @@ import ( "math/big" "testing" + "github.com/ava-labs/subnet-evm/precompile/allowlist" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" ) func TestVerifyTxAllowlistConfig(t *testing.T) { - admins := []common.Address{{1}} - enableds := []common.Address{{2}} - tests := []struct { - name string - config precompileconfig.Config - ExpectedError string - }{ - { - name: "invalid allow list config in tx allowlist", - config: NewConfig(big.NewInt(3), admins, admins), - ExpectedError: "cannot set address", - }, - { - name: "nil member allow list config in tx allowlist", - config: NewConfig(big.NewInt(3), nil, nil), - ExpectedError: "", - }, - { - name: "empty member allow list config in tx allowlist", - config: NewConfig(big.NewInt(3), []common.Address{}, []common.Address{}), - ExpectedError: "", - }, - { - name: "valid allow list config in tx allowlist", - config: NewConfig(big.NewInt(3), admins, enableds), - ExpectedError: "", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - err := tt.config.Verify() - if tt.ExpectedError == "" { - require.NoError(err) - } else { - require.ErrorContains(err, tt.ExpectedError) - } - }) - } + allowlist.VerifyPrecompileWithAllowListTests(t, Module, nil) } func TestEqualTxAllowListConfig(t *testing.T) { From 2a03da6b4d9eefe088334b3d733aad045cc399f6 Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 2 Mar 2023 17:32:42 +0300 Subject: [PATCH 3/5] add equal test suite --- precompile/allowlist/config_test.go | 46 ++--------- precompile/allowlist/test_allowlist_config.go | 46 +++++++++++ .../deployerallowlist/config_test.go | 69 +++++----------- .../contracts/feemanager/config_test.go | 82 +++++++------------ .../contracts/nativeminter/config_test.go | 80 +++++++----------- .../contracts/rewardmanager/config_test.go | 79 +++++++----------- .../contracts/txallowlist/config_test.go | 63 +++++--------- precompile/testutils/test_config.go | 9 +- 8 files changed, 188 insertions(+), 286 deletions(-) diff --git a/precompile/allowlist/config_test.go b/precompile/allowlist/config_test.go index 2091384c5f..47e63e9edf 100644 --- a/precompile/allowlist/config_test.go +++ b/precompile/allowlist/config_test.go @@ -7,8 +7,6 @@ import ( "testing" "github.com/ava-labs/subnet-evm/precompile/modules" - "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" ) func TestVerifyAllowlistAllowList(t *testing.T) { @@ -21,44 +19,10 @@ func TestVerifyAllowlistAllowList(t *testing.T) { } func TestEqualAllowListAllowList(t *testing.T) { - admins := []common.Address{{1}} - enableds := []common.Address{{2}} - tests := []struct { - name string - config *AllowListConfig - other *AllowListConfig - expected bool - }{ - { - name: "non-nil config and nil other", - config: &AllowListConfig{admins, enableds}, - other: nil, - expected: false, - }, - { - name: "different admin", - config: &AllowListConfig{admins, enableds}, - other: &AllowListConfig{[]common.Address{{3}}, enableds}, - expected: false, - }, - { - name: "different enabled", - config: &AllowListConfig{admins, enableds}, - other: &AllowListConfig{admins, []common.Address{{3}}}, - expected: false, - }, - { - name: "same config", - config: &AllowListConfig{admins, enableds}, - other: &AllowListConfig{admins, enableds}, - expected: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - require.Equal(tt.expected, tt.config.Equal(tt.other)) - }) + dummyModule := modules.Module{ + Address: dummyAddr, + Contract: CreateAllowListPrecompile(dummyAddr), + Configurator: &dummyConfigurator{}, } + EqualPrecompileWithAllowListTests(t, dummyModule, nil) } diff --git a/precompile/allowlist/test_allowlist_config.go b/precompile/allowlist/test_allowlist_config.go index d38702b30e..d1dc909768 100644 --- a/precompile/allowlist/test_allowlist_config.go +++ b/precompile/allowlist/test_allowlist_config.go @@ -60,6 +60,31 @@ func AllowListConfigVerifyTests(module modules.Module) map[string]testutils.Conf } } +func AllowListConfigEqualTests(module modules.Module) map[string]testutils.ConfigEqualTest { + return map[string]testutils.ConfigEqualTest{ + "allowlist non-nil config and nil other": { + Config: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{TestAdminAddr}, []common.Address{TestEnabledAddr}}), + Other: nil, + Expected: false, + }, + "allowlist different admin": { + Config: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{TestAdminAddr}, []common.Address{TestEnabledAddr}}), + Other: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{{3}}, []common.Address{TestEnabledAddr}}), + Expected: false, + }, + "allowlist different enabled": { + Config: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{TestAdminAddr}, []common.Address{TestEnabledAddr}}), + Other: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{module.Address}, []common.Address{{3}}}), + Expected: false, + }, + "allowlist same config": { + Config: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{TestAdminAddr}, []common.Address{TestEnabledAddr}}), + Other: mkConfigWithAllowList(module, &AllowListConfig{[]common.Address{TestAdminAddr}, []common.Address{TestEnabledAddr}}), + Expected: true, + }, + } +} + func VerifyPrecompileWithAllowListTests(t *testing.T, module modules.Module, verifyTests map[string]testutils.ConfigVerifyTest) { t.Helper() tests := AllowListConfigVerifyTests(module) @@ -85,3 +110,24 @@ func VerifyPrecompileWithAllowListTests(t *testing.T, module modules.Module, ver }) } } + +func EqualPrecompileWithAllowListTests(t *testing.T, module modules.Module, equalTests map[string]testutils.ConfigEqualTest) { + t.Helper() + tests := AllowListConfigEqualTests(module) + // Add the contract specific tests to the map of tests to run. + for name, test := range equalTests { + if _, exists := tests[name]; exists { + t.Fatalf("duplicate test name: %s", name) + } + tests[name] = test + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + t.Helper() + require := require.New(t) + + require.Equal(test.Expected, test.Config.Equal(test.Other)) + }) + } +} diff --git a/precompile/contracts/deployerallowlist/config_test.go b/precompile/contracts/deployerallowlist/config_test.go index 6d30525599..318531d02b 100644 --- a/precompile/contracts/deployerallowlist/config_test.go +++ b/precompile/contracts/deployerallowlist/config_test.go @@ -9,8 +9,8 @@ import ( "github.com/ava-labs/subnet-evm/precompile/allowlist" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" + "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" ) func TestVerifyContractDeployerConfig(t *testing.T) { @@ -18,56 +18,29 @@ func TestVerifyContractDeployerConfig(t *testing.T) { } func TestEqualContractDeployerAllowListConfig(t *testing.T) { - admins := []common.Address{{1}} - enableds := []common.Address{{2}} - tests := []struct { - name string - config precompileconfig.Config - other precompileconfig.Config - expected bool - }{ - { - name: "non-nil config and nil other", - config: NewConfig(big.NewInt(3), admins, enableds), - other: nil, - expected: false, + admins := []common.Address{allowlist.TestAdminAddr} + enableds := []common.Address{allowlist.TestEnabledAddr} + tests := map[string]testutils.ConfigEqualTest{ + "non-nil config and nil other": { + Config: NewConfig(big.NewInt(3), admins, enableds), + Other: nil, + Expected: false, }, - { - name: "different type", - config: NewConfig(big.NewInt(3), admins, enableds), - other: precompileconfig.NewNoopStatefulPrecompileConfig(), - expected: false, + "different type": { + Config: NewConfig(nil, nil, nil), + Other: precompileconfig.NewNoopStatefulPrecompileConfig(), + Expected: false, }, - { - name: "different admin", - config: NewConfig(big.NewInt(3), admins, enableds), - other: NewConfig(big.NewInt(3), []common.Address{{3}}, enableds), - expected: false, + "different timestamp": { + Config: NewConfig(big.NewInt(3), admins, enableds), + Other: NewConfig(big.NewInt(4), admins, enableds), + Expected: false, }, - { - name: "different enabled", - config: NewConfig(big.NewInt(3), admins, enableds), - other: NewConfig(big.NewInt(3), admins, []common.Address{{3}}), - expected: false, + "same config": { + Config: NewConfig(big.NewInt(3), admins, enableds), + Other: NewConfig(big.NewInt(3), admins, enableds), + Expected: true, }, - { - name: "different timestamp", - config: NewConfig(big.NewInt(3), admins, enableds), - other: NewConfig(big.NewInt(4), admins, enableds), - expected: false, - }, - { - name: "same config", - config: NewConfig(big.NewInt(3), admins, enableds), - other: NewConfig(big.NewInt(3), admins, enableds), - expected: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - require.Equal(tt.expected, tt.config.Equal(tt.other)) - }) } + allowlist.EqualPrecompileWithAllowListTests(t, Module, tests) } diff --git a/precompile/contracts/feemanager/config_test.go b/precompile/contracts/feemanager/config_test.go index e27e3abe1b..13d3e2dfe1 100644 --- a/precompile/contracts/feemanager/config_test.go +++ b/precompile/contracts/feemanager/config_test.go @@ -12,7 +12,6 @@ import ( "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" ) var validFeeConfig = commontype.FeeConfig{ @@ -29,7 +28,7 @@ var validFeeConfig = commontype.FeeConfig{ } func TestVerifyFeeManagerConfig(t *testing.T) { - admins := []common.Address{{1}} + admins := []common.Address{allowlist.TestAdminAddr} invalidFeeConfig := validFeeConfig invalidFeeConfig.GasLimit = big.NewInt(0) tests := map[string]testutils.ConfigVerifyTest{ @@ -45,67 +44,44 @@ func TestVerifyFeeManagerConfig(t *testing.T) { } func TestEqualFeeManagerConfig(t *testing.T) { - admins := []common.Address{{1}} - enableds := []common.Address{{2}} - tests := []struct { - name string - config precompileconfig.Config - other precompileconfig.Config - expected bool - }{ - { - name: "non-nil config and nil other", - config: NewConfig(big.NewInt(3), admins, enableds, nil), - other: nil, - expected: false, + admins := []common.Address{allowlist.TestAdminAddr} + enableds := []common.Address{allowlist.TestEnabledAddr} + tests := map[string]testutils.ConfigEqualTest{ + "non-nil config and nil other": { + Config: NewConfig(big.NewInt(3), admins, enableds, nil), + Other: nil, + Expected: false, }, - { - name: "different type", - config: NewConfig(big.NewInt(3), admins, enableds, nil), - other: precompileconfig.NewNoopStatefulPrecompileConfig(), - expected: false, + "different type": { + Config: NewConfig(big.NewInt(3), admins, enableds, nil), + Other: precompileconfig.NewNoopStatefulPrecompileConfig(), + Expected: false, }, - { - name: "different timestamp", - config: NewConfig(big.NewInt(3), admins, nil, nil), - other: NewConfig(big.NewInt(4), admins, nil, nil), - expected: false, + "different timestamp": { + Config: NewConfig(big.NewInt(3), admins, nil, nil), + Other: NewConfig(big.NewInt(4), admins, nil, nil), + Expected: false, }, - { - name: "different enabled", - config: NewConfig(big.NewInt(3), admins, nil, nil), - other: NewConfig(big.NewInt(3), admins, enableds, nil), - expected: false, + "non-nil initial config and nil initial config": { + Config: NewConfig(big.NewInt(3), admins, nil, &validFeeConfig), + Other: NewConfig(big.NewInt(3), admins, nil, nil), + Expected: false, }, - { - name: "non-nil initial config and nil initial config", - config: NewConfig(big.NewInt(3), admins, nil, &validFeeConfig), - other: NewConfig(big.NewInt(3), admins, nil, nil), - expected: false, - }, - { - name: "different initial config", - config: NewConfig(big.NewInt(3), admins, nil, &validFeeConfig), - other: NewConfig(big.NewInt(3), admins, nil, + "different initial config": { + Config: NewConfig(big.NewInt(3), admins, nil, &validFeeConfig), + Other: NewConfig(big.NewInt(3), admins, nil, func() *commontype.FeeConfig { c := validFeeConfig c.GasLimit = big.NewInt(123) return &c }()), - expected: false, + Expected: false, }, - { - name: "same config", - config: NewConfig(big.NewInt(3), admins, nil, &validFeeConfig), - other: NewConfig(big.NewInt(3), admins, nil, &validFeeConfig), - expected: true, + "same config": { + Config: NewConfig(big.NewInt(3), admins, nil, &validFeeConfig), + Other: NewConfig(big.NewInt(3), admins, nil, &validFeeConfig), + Expected: true, }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - require.Equal(tt.expected, tt.config.Equal(tt.other)) - }) - } + allowlist.EqualPrecompileWithAllowListTests(t, Module, tests) } diff --git a/precompile/contracts/nativeminter/config_test.go b/precompile/contracts/nativeminter/config_test.go index 026c58a9c5..6f8754e493 100644 --- a/precompile/contracts/nativeminter/config_test.go +++ b/precompile/contracts/nativeminter/config_test.go @@ -12,7 +12,6 @@ import ( "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" - "github.com/stretchr/testify/require" ) func TestVerifyContractNativeMinterConfig(t *testing.T) { @@ -52,80 +51,57 @@ func TestVerifyContractNativeMinterConfig(t *testing.T) { } func TestEqualContractNativeMinterConfig(t *testing.T) { - admins := []common.Address{{1}} - enableds := []common.Address{{2}} - tests := []struct { - name string - config precompileconfig.Config - other precompileconfig.Config - expected bool - }{ - { - name: "non-nil config and nil other", - config: NewConfig(big.NewInt(3), admins, enableds, nil), - other: nil, - expected: false, + admins := []common.Address{allowlist.TestAdminAddr} + enableds := []common.Address{allowlist.TestEnabledAddr} + tests := map[string]testutils.ConfigEqualTest{ + "non-nil config and nil other": { + Config: NewConfig(big.NewInt(3), admins, enableds, nil), + Other: nil, + Expected: false, }, - { - name: "different type", - config: NewConfig(big.NewInt(3), admins, enableds, nil), - other: precompileconfig.NewNoopStatefulPrecompileConfig(), - expected: false, + "different type": { + Config: NewConfig(big.NewInt(3), admins, enableds, nil), + Other: precompileconfig.NewNoopStatefulPrecompileConfig(), + Expected: false, }, - { - name: "different timestamps", - config: NewConfig(big.NewInt(3), admins, nil, nil), - other: NewConfig(big.NewInt(4), admins, nil, nil), - expected: false, + "different timestamps": { + Config: NewConfig(big.NewInt(3), admins, nil, nil), + Other: NewConfig(big.NewInt(4), admins, nil, nil), + Expected: false, }, - { - name: "different enabled", - config: NewConfig(big.NewInt(3), admins, nil, nil), - other: NewConfig(big.NewInt(3), admins, enableds, nil), - expected: false, - }, - { - name: "different initial mint amounts", - config: NewConfig(big.NewInt(3), admins, nil, + "different initial mint amounts": { + Config: NewConfig(big.NewInt(3), admins, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - other: NewConfig(big.NewInt(3), admins, nil, + Other: NewConfig(big.NewInt(3), admins, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(2), }), - expected: false, + Expected: false, }, - { - name: "different initial mint addresses", - config: NewConfig(big.NewInt(3), admins, nil, + "different initial mint addresses": { + Config: NewConfig(big.NewInt(3), admins, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - other: NewConfig(big.NewInt(3), admins, nil, + Other: NewConfig(big.NewInt(3), admins, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x02"): math.NewHexOrDecimal256(1), }), - expected: false, + Expected: false, }, - { - name: "same config", - config: NewConfig(big.NewInt(3), admins, nil, + "same config": { + Config: NewConfig(big.NewInt(3), admins, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - other: NewConfig(big.NewInt(3), admins, nil, + Other: NewConfig(big.NewInt(3), admins, nil, map[common.Address]*math.HexOrDecimal256{ common.HexToAddress("0x01"): math.NewHexOrDecimal256(1), }), - expected: true, + Expected: true, }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - require.Equal(tt.expected, tt.config.Equal(tt.other)) - }) - } + allowlist.EqualPrecompileWithAllowListTests(t, Module, tests) } diff --git a/precompile/contracts/rewardmanager/config_test.go b/precompile/contracts/rewardmanager/config_test.go index 80902d3309..cefe1fcc71 100644 --- a/precompile/contracts/rewardmanager/config_test.go +++ b/precompile/contracts/rewardmanager/config_test.go @@ -11,7 +11,6 @@ import ( "github.com/ava-labs/subnet-evm/precompile/precompileconfig" "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" ) func TestVerifyRewardManagerConfig(t *testing.T) { @@ -32,71 +31,53 @@ func TestVerifyRewardManagerConfig(t *testing.T) { func TestEqualRewardManagerConfig(t *testing.T) { admins := []common.Address{{1}} enableds := []common.Address{{2}} - tests := []struct { - name string - config precompileconfig.Config - other precompileconfig.Config - expected bool - }{ - { - name: "non-nil config and nil other", - config: NewConfig(big.NewInt(3), admins, enableds, nil), - other: nil, - expected: false, + tests := map[string]testutils.ConfigEqualTest{ + "non-nil config and nil other": { + Config: NewConfig(big.NewInt(3), admins, enableds, nil), + Other: nil, + Expected: false, }, - { - name: "different type", - config: NewConfig(big.NewInt(3), admins, enableds, nil), - other: precompileconfig.NewNoopStatefulPrecompileConfig(), - expected: false, + "different type": { + Config: NewConfig(big.NewInt(3), admins, enableds, nil), + Other: precompileconfig.NewNoopStatefulPrecompileConfig(), + Expected: false, }, - { - name: "different timestamp", - config: NewConfig(big.NewInt(3), admins, nil, nil), - other: NewConfig(big.NewInt(4), admins, nil, nil), - expected: false, + "different timestamp": { + Config: NewConfig(big.NewInt(3), admins, nil, nil), + Other: NewConfig(big.NewInt(4), admins, nil, nil), + Expected: false, }, - { - name: "different enabled", - config: NewConfig(big.NewInt(3), admins, nil, nil), - other: NewConfig(big.NewInt(3), admins, enableds, nil), - expected: false, + "different enabled": { + Config: NewConfig(big.NewInt(3), admins, nil, nil), + Other: NewConfig(big.NewInt(3), admins, enableds, nil), + Expected: false, }, - { - name: "non-nil initial config and nil initial config", - config: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ + "non-nil initial config and nil initial config": { + Config: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ AllowFeeRecipients: true, }), - other: NewConfig(big.NewInt(3), admins, nil, nil), - expected: false, + Other: NewConfig(big.NewInt(3), admins, nil, nil), + Expected: false, }, - { - name: "different initial config", - config: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ + "different initial config": { + Config: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), - other: NewConfig(big.NewInt(3), admins, nil, + Other: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ RewardAddress: common.HexToAddress("0x02"), }), - expected: false, + Expected: false, }, - { - name: "same config", - config: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ + "same config": { + Config: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), - other: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ + Other: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ RewardAddress: common.HexToAddress("0x01"), }), - expected: true, + Expected: true, }, } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - require.Equal(tt.expected, tt.config.Equal(tt.other)) - }) - } + allowlist.EqualPrecompileWithAllowListTests(t, Module, tests) } diff --git a/precompile/contracts/txallowlist/config_test.go b/precompile/contracts/txallowlist/config_test.go index 4a7375862c..672db2501e 100644 --- a/precompile/contracts/txallowlist/config_test.go +++ b/precompile/contracts/txallowlist/config_test.go @@ -9,8 +9,8 @@ import ( "github.com/ava-labs/subnet-evm/precompile/allowlist" "github.com/ava-labs/subnet-evm/precompile/precompileconfig" + "github.com/ava-labs/subnet-evm/precompile/testutils" "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" ) func TestVerifyTxAllowlistConfig(t *testing.T) { @@ -18,50 +18,29 @@ func TestVerifyTxAllowlistConfig(t *testing.T) { } func TestEqualTxAllowListConfig(t *testing.T) { - admins := []common.Address{{1}} - enableds := []common.Address{{2}} - tests := []struct { - name string - config precompileconfig.Config - other precompileconfig.Config - expected bool - }{ - { - name: "non-nil config and nil other", - config: NewConfig(big.NewInt(3), admins, enableds), - other: nil, - expected: false, + admins := []common.Address{allowlist.TestAdminAddr} + enableds := []common.Address{allowlist.TestEnabledAddr} + tests := map[string]testutils.ConfigEqualTest{ + "non-nil config and nil other": { + Config: NewConfig(big.NewInt(3), admins, enableds), + Other: nil, + Expected: false, }, - { - name: "different admin", - config: NewConfig(big.NewInt(3), admins, enableds), - other: NewConfig(big.NewInt(3), []common.Address{{3}}, enableds), - expected: false, + "different type": { + Config: NewConfig(nil, nil, nil), + Other: precompileconfig.NewNoopStatefulPrecompileConfig(), + Expected: false, }, - { - name: "different enabled", - config: NewConfig(big.NewInt(3), admins, enableds), - other: NewConfig(big.NewInt(3), admins, []common.Address{{3}}), - expected: false, + "different timestamp": { + Config: NewConfig(big.NewInt(3), admins, enableds), + Other: NewConfig(big.NewInt(4), admins, enableds), + Expected: false, }, - { - name: "different timestamp", - config: NewConfig(big.NewInt(3), admins, enableds), - other: NewConfig(big.NewInt(4), admins, enableds), - expected: false, + "same config": { + Config: NewConfig(big.NewInt(3), admins, enableds), + Other: NewConfig(big.NewInt(3), admins, enableds), + Expected: true, }, - { - name: "same config", - config: NewConfig(big.NewInt(3), admins, enableds), - other: NewConfig(big.NewInt(3), admins, enableds), - expected: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require := require.New(t) - - require.Equal(tt.expected, tt.config.Equal(tt.other)) - }) } + allowlist.EqualPrecompileWithAllowListTests(t, Module, tests) } diff --git a/precompile/testutils/test_config.go b/precompile/testutils/test_config.go index 9d58f65fd5..ef0d656460 100644 --- a/precompile/testutils/test_config.go +++ b/precompile/testutils/test_config.go @@ -7,8 +7,15 @@ import ( "github.com/ava-labs/subnet-evm/precompile/precompileconfig" ) -// PrecompileConfigTest is a test case for precompile configs +// ConfigVerifyTest is a test case for verifying a config type ConfigVerifyTest struct { Config precompileconfig.Config ExpectedError string } + +// ConfigEqualTest is a test case for comparing two configs +type ConfigEqualTest struct { + Config precompileconfig.Config + Other precompileconfig.Config + Expected bool +} From 921fd575581d1aef0f0d6489edae204fd544649f Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Thu, 2 Mar 2023 19:45:20 +0300 Subject: [PATCH 4/5] nits --- precompile/allowlist/config_test.go | 2 +- precompile/contracts/feemanager/config_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/precompile/allowlist/config_test.go b/precompile/allowlist/config_test.go index 47e63e9edf..a01b25bad5 100644 --- a/precompile/allowlist/config_test.go +++ b/precompile/allowlist/config_test.go @@ -18,7 +18,7 @@ func TestVerifyAllowlistAllowList(t *testing.T) { VerifyPrecompileWithAllowListTests(t, dummyModule, nil) } -func TestEqualAllowListAllowList(t *testing.T) { +func TestEqualAllowList(t *testing.T) { dummyModule := modules.Module{ Address: dummyAddr, Contract: CreateAllowListPrecompile(dummyAddr), diff --git a/precompile/contracts/feemanager/config_test.go b/precompile/contracts/feemanager/config_test.go index 13d3e2dfe1..0f3b7bca33 100644 --- a/precompile/contracts/feemanager/config_test.go +++ b/precompile/contracts/feemanager/config_test.go @@ -35,7 +35,8 @@ func TestVerifyFeeManagerConfig(t *testing.T) { "invalid initial fee manager config": { Config: NewConfig(big.NewInt(3), admins, nil, &invalidFeeConfig), ExpectedError: "gasLimit = 0 cannot be less than or equal to 0", - }, "nil initial fee manager config": { + }, + "nil initial fee manager config": { Config: NewConfig(big.NewInt(3), admins, nil, &commontype.FeeConfig{}), ExpectedError: "gasLimit cannot be nil", }, From 67f5b056e237519509684237f30bff298edffcab Mon Sep 17 00:00:00 2001 From: Ceyhun Onur Date: Wed, 22 Mar 2023 13:17:17 +0300 Subject: [PATCH 5/5] nits --- precompile/allowlist/config_test.go | 22 ++++++++----------- .../contracts/rewardmanager/config_test.go | 5 ----- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/precompile/allowlist/config_test.go b/precompile/allowlist/config_test.go index a01b25bad5..a4dbaeec71 100644 --- a/precompile/allowlist/config_test.go +++ b/precompile/allowlist/config_test.go @@ -9,20 +9,16 @@ import ( "github.com/ava-labs/subnet-evm/precompile/modules" ) -func TestVerifyAllowlistAllowList(t *testing.T) { - dummyModule := modules.Module{ - Address: dummyAddr, - Contract: CreateAllowListPrecompile(dummyAddr), - Configurator: &dummyConfigurator{}, - } - VerifyPrecompileWithAllowListTests(t, dummyModule, nil) +var testModule = modules.Module{ + Address: dummyAddr, + Contract: CreateAllowListPrecompile(dummyAddr), + Configurator: &dummyConfigurator{}, +} + +func TestVerifyAllowlist(t *testing.T) { + VerifyPrecompileWithAllowListTests(t, testModule, nil) } func TestEqualAllowList(t *testing.T) { - dummyModule := modules.Module{ - Address: dummyAddr, - Contract: CreateAllowListPrecompile(dummyAddr), - Configurator: &dummyConfigurator{}, - } - EqualPrecompileWithAllowListTests(t, dummyModule, nil) + EqualPrecompileWithAllowListTests(t, testModule, nil) } diff --git a/precompile/contracts/rewardmanager/config_test.go b/precompile/contracts/rewardmanager/config_test.go index cefe1fcc71..2c3b3ab154 100644 --- a/precompile/contracts/rewardmanager/config_test.go +++ b/precompile/contracts/rewardmanager/config_test.go @@ -47,11 +47,6 @@ func TestEqualRewardManagerConfig(t *testing.T) { Other: NewConfig(big.NewInt(4), admins, nil, nil), Expected: false, }, - "different enabled": { - Config: NewConfig(big.NewInt(3), admins, nil, nil), - Other: NewConfig(big.NewInt(3), admins, enableds, nil), - Expected: false, - }, "non-nil initial config and nil initial config": { Config: NewConfig(big.NewInt(3), admins, nil, &InitialRewardConfig{ AllowFeeRecipients: true,