Skip to content

Commit

Permalink
Make StartChain take sovereign chain name as input
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed May 22, 2023
1 parent d312b8f commit 9f7274a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
12 changes: 8 additions & 4 deletions tests/e2e/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func concatSteps(steps ...[]Step) []Step {
}

var happyPathSteps = concatSteps(
stepsStartChains([]string{"consu"}, false),
stepsStartChains("provi", []string{"consu"}, false),
stepsDelegate("consu"),
stepsAssignConsumerKeyOnStartedChain("consu", "bob"),
stepsUnbond("consu"),
Expand All @@ -31,26 +31,30 @@ var happyPathSteps = concatSteps(
)

var slashThrottleSteps = concatSteps(
stepsStartChains([]string{"consu"}, false),
stepsStartChains("provi", []string{"consu"}, false),
stepsDelegate("consu"),
stepsThrottledDowntime("consu"),
stepsStopChain("consu", 2),
)

var democracySteps = concatSteps(
// democracySteps requires a transfer channel
stepsStartChains([]string{"democ"}, true),
stepsStartChains("provi", []string{"democ"}, true),
// delegation needs to happen so the first VSC packet can be delivered
stepsDelegate("democ"),
stepsDemocracy("democ"),
)

var multipleConsumers = concatSteps(
stepsStartChains([]string{"consu", "densu"}, false),
stepsStartChains("provi", []string{"consu", "densu"}, false),
stepsMultiConsumerDelegate("consu", "densu"),
stepsMultiConsumerUnbond("consu", "densu"),
stepsMultiConsumerRedelegate("consu", "densu"),
stepsMultiConsumerDowntimeFromConsumer("consu", "densu"),
stepsMultiConsumerDowntimeFromProvider("consu", "densu"),
stepsMultiConsumerDoubleSign("consu", "densu"), // double sign on one of the chains
)

var sovereignToConsumerSteps = concatSteps(
stepStartSovereignChain("sove"),
)
32 changes: 16 additions & 16 deletions tests/e2e/steps_start_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import (
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
)

func stepStartProviderChain() []Step {
func stepStartSovereignChain(chainName string) []Step {
return []Step{
{
action: StartChainAction{
chain: chainID("provi"),
chain: chainID(chainName),
validators: []StartChainValidator{
{id: validatorID("bob"), stake: 500000000, allocation: 10000000000},
{id: validatorID("alice"), stake: 500000000, allocation: 10000000000},
{id: validatorID("carol"), stake: 500000000, allocation: 10000000000},
},
},
state: State{
chainID("provi"): ChainState{
chainID(chainName): ChainState{
ValBalances: &map[validatorID]uint{
validatorID("alice"): 9500000000,
validatorID("bob"): 9500000000,
Expand All @@ -28,19 +28,19 @@ func stepStartProviderChain() []Step {
}
}

func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint, setupTransferChans bool) []Step {
func stepsStartConsumerChain(providerName, consumerName string, proposalIndex, chainIndex uint, setupTransferChans bool) []Step {
s := []Step{
{
action: submitConsumerAdditionProposalAction{
chain: chainID("provi"),
chain: chainID(providerName),
from: validatorID("alice"),
deposit: 10000001,
consumerChain: chainID(consumerName),
spawnTime: 0,
initialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
},
state: State{
chainID("provi"): ChainState{
chainID(providerName): ChainState{
ValBalances: &map[validatorID]uint{
validatorID("alice"): 9489999999,
validatorID("bob"): 9500000000,
Expand Down Expand Up @@ -115,13 +115,13 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
},
{
action: voteGovProposalAction{
chain: chainID("provi"),
chain: chainID(providerName),
from: []validatorID{validatorID("alice"), validatorID("bob"), validatorID("carol")},
vote: []string{"yes", "yes", "yes"},
propNumber: proposalIndex,
},
state: State{
chainID("provi"): ChainState{
chainID(providerName): ChainState{
Proposals: &map[uint]Proposal{
proposalIndex: ConsumerAdditionProposal{
Deposit: 10000001,
Expand All @@ -141,7 +141,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
{
action: startConsumerChainAction{
consumerChain: chainID(consumerName),
providerChain: chainID("provi"),
providerChain: chainID(providerName),
validators: []StartChainValidator{
{id: validatorID("bob"), stake: 500000000, allocation: 10000000000},
{id: validatorID("alice"), stake: 500000000, allocation: 10000000000},
Expand All @@ -155,7 +155,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
genesisChanges: ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"",
},
state: State{
chainID("provi"): ChainState{
chainID(providerName): ChainState{
ValBalances: &map[validatorID]uint{
validatorID("alice"): 9500000000,
validatorID("bob"): 9500000000,
Expand All @@ -174,7 +174,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
{
action: addIbcConnectionAction{
chainA: chainID(consumerName),
chainB: chainID("provi"),
chainB: chainID(providerName),
clientA: 0,
clientB: chainIndex,
},
Expand All @@ -183,7 +183,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
{
action: addIbcChannelAction{
chainA: chainID(consumerName),
chainB: chainID("provi"),
chainB: chainID(providerName),
connectionA: 0,
portA: "consumer", // TODO: check port mapping
portB: "provider",
Expand All @@ -198,7 +198,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
s = append(s, Step{
action: transferChannelCompleteAction{
chainA: chainID(consumerName),
chainB: chainID("provi"),
chainB: chainID(providerName),
connectionA: 0,
portA: "transfer",
portB: "transfer",
Expand All @@ -214,10 +214,10 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint

// starts provider and consumer chains specified in consumerNames
// setupTransferChans will establish a channel for fee transfers between consumer and provider
func stepsStartChains(consumerNames []string, setupTransferChans bool) []Step {
s := stepStartProviderChain()
func stepsStartChains(providerName string, consumerNames []string, setupTransferChans bool) []Step {
s := stepStartSovereignChain(providerName)
for i, consumerName := range consumerNames {
s = append(s, stepsStartConsumerChain(consumerName, uint(i+1), uint(i), setupTransferChans)...)
s = append(s, stepsStartConsumerChain(providerName, consumerName, uint(i+1), uint(i), setupTransferChans)...)
}

return s
Expand Down

0 comments on commit 9f7274a

Please sign in to comment.