Skip to content

Commit

Permalink
test requirePrimaryNetworkSigners explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
iansuvak committed Nov 20, 2024
1 parent b0e5071 commit 8dfb194
Showing 1 changed file with 58 additions and 8 deletions.
66 changes: 58 additions & 8 deletions relayer/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,21 @@ func TestEitherKMSOrAccountPrivateKey(t *testing.T) {
}
}

func TestGetWarpQuorum(t *testing.T) {
func TestGetWarpConfig(t *testing.T) {
blockchainID, err := ids.FromString("p433wpuXyJiDhyazPYyZMJeaoPSW76CBZ2x7wrVPLgvokotXz")
require.NoError(t, err)
subnetID, err := ids.FromString("2PsShLjrFFwR51DMcAh8pyuwzLn1Ym3zRhuXLTmLCR1STk2mL6")
require.NoError(t, err)

testCases := []struct {
name string
blockchainID ids.ID
subnetID ids.ID
chainConfig params.ChainConfigWithUpgradesJSON
getChainConfigCalls int
expectedError error
expectedQuorum WarpQuorum
name string
blockchainID ids.ID
subnetID ids.ID
chainConfig params.ChainConfigWithUpgradesJSON
getChainConfigCalls int
expectedError error
expectedQuorum WarpQuorum
expectedRequirePrimaryNeworkSigners bool
}{
{
name: "subnet genesis precompile",
Expand All @@ -276,6 +277,7 @@ func TestGetWarpQuorum(t *testing.T) {
QuorumNumerator: warp.WarpDefaultQuorumNumerator,
QuorumDenominator: warp.WarpQuorumDenominator,
},
expectedRequirePrimaryNeworkSigners: false,
},
{
name: "subnet genesis precompile non-default",
Expand All @@ -296,6 +298,7 @@ func TestGetWarpQuorum(t *testing.T) {
QuorumNumerator: 50,
QuorumDenominator: warp.WarpQuorumDenominator,
},
expectedRequirePrimaryNeworkSigners: false,
},
{
name: "subnet upgrade precompile",
Expand All @@ -318,6 +321,7 @@ func TestGetWarpQuorum(t *testing.T) {
QuorumNumerator: warp.WarpDefaultQuorumNumerator,
QuorumDenominator: warp.WarpQuorumDenominator,
},
expectedRequirePrimaryNeworkSigners: false,
},
{
name: "subnet upgrade precompile non-default",
Expand All @@ -340,6 +344,51 @@ func TestGetWarpQuorum(t *testing.T) {
QuorumNumerator: 50,
QuorumDenominator: warp.WarpQuorumDenominator,
},
expectedRequirePrimaryNeworkSigners: false,
},
{
name: "require primary network signers",
blockchainID: blockchainID,
subnetID: subnetID,
getChainConfigCalls: 1,
chainConfig: params.ChainConfigWithUpgradesJSON{
ChainConfig: params.ChainConfig{
GenesisPrecompiles: params.Precompiles{
warpConfigKey: &warp.Config{
QuorumNumerator: 0,
RequirePrimaryNetworkSigners: true,
},
},
},
},
expectedError: nil,
expectedQuorum: WarpQuorum{
QuorumNumerator: warp.WarpDefaultQuorumNumerator,
QuorumDenominator: warp.WarpQuorumDenominator,
},
expectedRequirePrimaryNeworkSigners: true,
},
{
name: "require primary network signers explicit false",
blockchainID: blockchainID,
subnetID: subnetID,
getChainConfigCalls: 1,
chainConfig: params.ChainConfigWithUpgradesJSON{
ChainConfig: params.ChainConfig{
GenesisPrecompiles: params.Precompiles{
warpConfigKey: &warp.Config{
QuorumNumerator: 0,
RequirePrimaryNetworkSigners: false,
},
},
},
},
expectedError: nil,
expectedQuorum: WarpQuorum{
QuorumNumerator: warp.WarpDefaultQuorumNumerator,
QuorumDenominator: warp.WarpQuorumDenominator,
},
expectedRequirePrimaryNeworkSigners: false,
},
}

Expand All @@ -357,6 +406,7 @@ func TestGetWarpQuorum(t *testing.T) {
require.Equal(t, testCase.expectedError, err)
quorum := calculateQuorum(warpConfig.QuorumNumerator)
require.Equal(t, testCase.expectedQuorum, quorum)
require.Equal(t, testCase.expectedRequirePrimaryNeworkSigners, warpConfig.RequirePrimaryNetworkSigners)
})
}
}
Expand Down

0 comments on commit 8dfb194

Please sign in to comment.