mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
81 lines
2.7 KiB
Go
81 lines
2.7 KiB
Go
// (c) 2022 Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package rewardmanager
|
|
|
|
import (
|
|
"testing"
|
|
"github.com/luxfi/evm/precompile/allowlist"
|
|
"github.com/luxfi/evm/precompile/precompileconfig"
|
|
"github.com/luxfi/evm/precompile/testutils"
|
|
"github.com/luxfi/evm/utils"
|
|
"github.com/luxfi/geth/common"
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
func TestVerify(t *testing.T) {
|
|
admins := []common.Address{allowlist.TestAdminAddr}
|
|
enableds := []common.Address{allowlist.TestEnabledAddr}
|
|
managers := []common.Address{allowlist.TestManagerAddr}
|
|
tests := map[string]testutils.ConfigVerifyTest{
|
|
"both reward mechanisms should not be activated at the same time in reward manager": {
|
|
Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, &InitialRewardConfig{
|
|
AllowFeeRecipients: true,
|
|
RewardAddress: common.HexToAddress("0x01"),
|
|
}),
|
|
ExpectedError: ErrCannotEnableBothRewards.Error(),
|
|
},
|
|
}
|
|
allowlist.VerifyPrecompileWithAllowListTests(t, Module, tests)
|
|
}
|
|
|
|
func TestEqual(t *testing.T) {
|
|
admins := []common.Address{allowlist.TestAdminAddr}
|
|
enableds := []common.Address{allowlist.TestEnabledAddr}
|
|
managers := []common.Address{allowlist.TestManagerAddr}
|
|
tests := map[string]testutils.ConfigEqualTest{
|
|
"non-nil config and nil other": {
|
|
Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, nil),
|
|
Other: nil,
|
|
Expected: false,
|
|
},
|
|
"different type": {
|
|
Config: NewConfig(utils.NewUint64(3), admins, enableds, managers, nil),
|
|
Other: precompileconfig.NewMockConfig(gomock.NewController(t)),
|
|
Expected: false,
|
|
},
|
|
"different timestamp": {
|
|
Config: NewConfig(utils.NewUint64(3), admins, nil, nil, nil),
|
|
Other: NewConfig(utils.NewUint64(4), admins, nil, nil, nil),
|
|
Expected: false,
|
|
},
|
|
"non-nil initial config and nil initial config": {
|
|
Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &InitialRewardConfig{
|
|
AllowFeeRecipients: true,
|
|
}),
|
|
Other: NewConfig(utils.NewUint64(3), admins, nil, nil, nil),
|
|
Expected: false,
|
|
},
|
|
"different initial config": {
|
|
Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &InitialRewardConfig{
|
|
RewardAddress: common.HexToAddress("0x01"),
|
|
}),
|
|
Other: NewConfig(utils.NewUint64(3), admins, nil, nil,
|
|
&InitialRewardConfig{
|
|
RewardAddress: common.HexToAddress("0x02"),
|
|
}),
|
|
Expected: false,
|
|
},
|
|
"same config": {
|
|
Config: NewConfig(utils.NewUint64(3), admins, nil, nil, &InitialRewardConfig{
|
|
RewardAddress: common.HexToAddress("0x01"),
|
|
}),
|
|
Other: NewConfig(utils.NewUint64(3), admins, nil, nil, &InitialRewardConfig{
|
|
RewardAddress: common.HexToAddress("0x01"),
|
|
}),
|
|
Expected: true,
|
|
},
|
|
}
|
|
allowlist.EqualPrecompileWithAllowListTests(t, Module, tests)
|
|
}
|