Skip to content

Commit

Permalink
add AccountPrefix to ChainConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoke committed Jan 19, 2024
1 parent 1c00063 commit 7a8a5d5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
18 changes: 2 additions & 16 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,17 +737,10 @@ func (tr TestConfig) addChainToGorelayer(
ChainId := tr.chainConfigs[action.Chain].ChainId
rpcAddr := "http://" + queryNodeIP + ":26658"

var accountPrefix string
if ChainId == ChainID("provi") {
accountPrefix = "cosmos"
} else {
accountPrefix = "consumer"
}

chainConfig := fmt.Sprintf(gorelayerChainConfigTemplate,
ChainId,
rpcAddr,
accountPrefix,
tr.chainConfigs[action.Chain].AccountPrefix,
)

//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
Expand Down Expand Up @@ -786,15 +779,8 @@ func (tr TestConfig) addChainToHermes(
grpcAddr := "tcp://" + queryNodeIP + ":9091"
wsAddr := "ws://" + queryNodeIP + ":26658/websocket"

var accountPrefix string
if ChainId == ChainID("provi") {
accountPrefix = "cosmos"
} else {
accountPrefix = "consumer"
}

chainConfig := fmt.Sprintf(hermesChainConfigTemplate,
accountPrefix,
tr.chainConfigs[action.Chain].AccountPrefix,
grpcAddr,
ChainId,
keyName,
Expand Down
45 changes: 32 additions & 13 deletions tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import (
"time"
)

var (
ProviderAccountPrefix = "cosmos"
ConsumerAccountPrefix = "consumer"
)

// TODO: Determine if user defined type (wrapping a primitive string) is desired in long run
type (
ChainID string
Expand All @@ -18,22 +23,22 @@ type ValidatorConfig struct {
// Seed phrase to generate a secp256k1 key used by the validator on the provider
Mnemonic string
// Validator account address on provider marshaled to string using Bech32
// with Bech32Prefix = "cosmos"
// with Bech32Prefix = ProviderAccountPrefix
DelAddress string
// Validator account address on provider marshaled to string using Bech32
// with Bech32Prefix = "consumer"
// with Bech32Prefix = ConsumerAccountPrefix
DelAddressOnConsumer string
// Validator operator address on provider marshaled to string using Bech32
// with Bech32Prefix = "cosmos"
// with Bech32Prefix = ProviderAccountPrefix
ValoperAddress string
// Validator operator address on provider marshaled to string using Bech32
// with Bech32Prefix = "consumer"
// with Bech32Prefix = ConsumerAccountPrefix
ValoperAddressOnConsumer string
// Validator consensus address on provider marshaled to string using Bech32
// with Bech32Prefix = "cosmos". It matches the PrivValidatorKey below.
// with Bech32Prefix = ProviderAccountPrefix. It matches the PrivValidatorKey below.
ValconsAddress string
// Validator consensus address on provider marshaled to string using Bech32
// with Bech32Prefix = "consumer".
// with Bech32Prefix = ConsumerAccountPrefix.
ValconsAddressOnConsumer string
// Key used for consensus on provider
PrivValidatorKey string
Expand All @@ -47,22 +52,22 @@ type ValidatorConfig struct {
// Seed phrase to generate a secp256k1 key used by the validator on the consumer
ConsumerMnemonic string
// Validator account address on consumer marshaled to string using Bech32
// with Bech32Prefix = "consumer"
ConsumerDelAddress string // Consumer delegator address - Bech32Prefix = "consumer"
// with Bech32Prefix = ConsumerAccountPrefix
ConsumerDelAddress string
// Validator account address on consumer marshaled to string using Bech32
// with Bech32Prefix = "cosmos"
// with Bech32Prefix = ProviderAccountPrefix
ConsumerDelAddressOnProvider string
// Validator operator address on consumer marshaled to string using Bech32
// with Bech32Prefix = "consumer"
// with Bech32Prefix = ConsumerAccountPrefix
ConsumerValoperAddress string
// Validator operator address on consumer marshaled to string using Bech32
// with Bech32Prefix = "cosmos"
// with Bech32Prefix = ProviderAccountPrefix
ConsumerValoperAddressOnProvider string
// Validator consensus address on consumer marshaled to string using Bech32
// with Bech32Prefix = "consumer". It matches the PrivValidatorKey below.
// with Bech32Prefix = ConsumerAccountPrefix. It matches the PrivValidatorKey below.
ConsumerValconsAddress string
// Validator consensus address on consumer marshaled to string using Bech32
// with Bech32Prefix = "cosmos".
// with Bech32Prefix = ProviderAccountPrefix.
ConsumerValconsAddressOnProvider string
ConsumerValPubKey string
// Key used for consensus on consumer
Expand All @@ -75,6 +80,8 @@ type ValidatorConfig struct {
// the set of strings defined above to a set of viable chains
type ChainConfig struct {
ChainId ChainID
// The account prefix configured on the chain. For example, on the Hub, this is "cosmos"
AccountPrefix string
// Must be unique per chain
IpPrefix string
VotingWaitTime uint
Expand Down Expand Up @@ -217,6 +224,7 @@ func SlashThrottleTestConfig() TestConfig {
chainConfigs: map[ChainID]ChainConfig{
ChainID("provi"): {
ChainId: ChainID("provi"),
AccountPrefix: ProviderAccountPrefix,
BinaryName: "interchain-security-pd",
IpPrefix: "7.7.7",
VotingWaitTime: 20,
Expand All @@ -232,6 +240,7 @@ func SlashThrottleTestConfig() TestConfig {
},
ChainID("consu"): {
ChainId: ChainID("consu"),
AccountPrefix: ConsumerAccountPrefix,
BinaryName: "interchain-security-cd",
IpPrefix: "7.7.8",
VotingWaitTime: 20,
Expand Down Expand Up @@ -263,6 +272,7 @@ func DefaultTestConfig() TestConfig {
chainConfigs: map[ChainID]ChainConfig{
ChainID("provi"): {
ChainId: ChainID("provi"),
AccountPrefix: ProviderAccountPrefix,
BinaryName: "interchain-security-pd",
IpPrefix: "7.7.7",
VotingWaitTime: 20,
Expand All @@ -278,6 +288,7 @@ func DefaultTestConfig() TestConfig {
},
ChainID("consu"): {
ChainId: ChainID("consu"),
AccountPrefix: ConsumerAccountPrefix,
BinaryName: "interchain-security-cd",
IpPrefix: "7.7.8",
VotingWaitTime: 20,
Expand Down Expand Up @@ -321,6 +332,7 @@ func DemocracyTestConfig(allowReward bool) TestConfig {
chainConfigs: map[ChainID]ChainConfig{
ChainID("provi"): {
ChainId: ChainID("provi"),
AccountPrefix: ProviderAccountPrefix,
BinaryName: "interchain-security-pd",
IpPrefix: "7.7.7",
VotingWaitTime: 20,
Expand All @@ -335,6 +347,7 @@ func DemocracyTestConfig(allowReward bool) TestConfig {
},
ChainID("democ"): {
ChainId: ChainID("democ"),
AccountPrefix: ConsumerAccountPrefix,
BinaryName: "interchain-security-cdd",
IpPrefix: "7.7.9",
VotingWaitTime: 20,
Expand All @@ -361,6 +374,7 @@ func MultiConsumerTestConfig() TestConfig {
chainConfigs: map[ChainID]ChainConfig{
ChainID("provi"): {
ChainId: ChainID("provi"),
AccountPrefix: ProviderAccountPrefix,
BinaryName: "interchain-security-pd",
IpPrefix: "7.7.7",
VotingWaitTime: 20,
Expand All @@ -375,6 +389,7 @@ func MultiConsumerTestConfig() TestConfig {
},
ChainID("consu"): {
ChainId: ChainID("consu"),
AccountPrefix: ConsumerAccountPrefix,
BinaryName: "interchain-security-cd",
IpPrefix: "7.7.8",
VotingWaitTime: 20,
Expand All @@ -386,6 +401,7 @@ func MultiConsumerTestConfig() TestConfig {
},
ChainID("densu"): {
ChainId: ChainID("densu"),
AccountPrefix: ConsumerAccountPrefix,
BinaryName: "interchain-security-cd",
IpPrefix: "7.7.9",
VotingWaitTime: 20,
Expand Down Expand Up @@ -416,6 +432,7 @@ func ChangeoverTestConfig() TestConfig {
chainConfigs: map[ChainID]ChainConfig{
ChainID("provi"): {
ChainId: ChainID("provi"),
AccountPrefix: ProviderAccountPrefix,
BinaryName: "interchain-security-pd",
IpPrefix: "7.7.7",
VotingWaitTime: 20,
Expand All @@ -431,6 +448,7 @@ func ChangeoverTestConfig() TestConfig {
},
ChainID("sover"): {
ChainId: ChainID("sover"),
AccountPrefix: ConsumerAccountPrefix,
BinaryName: "interchain-security-sd",
UpgradeBinary: "interchain-security-cdd",
IpPrefix: "7.7.8",
Expand Down Expand Up @@ -514,6 +532,7 @@ func ConsumerMisbehaviourTestConfig() TestConfig {
chainConfigs: map[ChainID]ChainConfig{
ChainID("provi"): {
ChainId: ChainID("provi"),
AccountPrefix: ProviderAccountPrefix,
BinaryName: "interchain-security-pd",
IpPrefix: "7.7.7",
VotingWaitTime: 20,
Expand Down

0 comments on commit 7a8a5d5

Please sign in to comment.