Skip to content

Commit

Permalink
add multiple consumer chains in integration tests (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek authored Nov 15, 2022
1 parent 33137b3 commit fb83bb7
Show file tree
Hide file tree
Showing 10 changed files with 937 additions and 128 deletions.
4 changes: 3 additions & 1 deletion tests/integration/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ func (tr TestRun) submitParamChangeProposal(
`--chain-id`, string(tr.chainConfigs[action.chain].chainId),
`--home`, tr.getValidatorHome(action.chain, action.from),
`--node`, tr.getValidatorNode(action.chain, action.from),
`--gas`, "900000",
`--keyring-backend`, `test`,
`-b`, `block`,
`-y`,
Expand Down Expand Up @@ -405,6 +406,7 @@ func (tr TestRun) voteGovProposal(
`--home`, tr.getValidatorHome(action.chain, val),
`--node`, tr.getValidatorNode(action.chain, val),
`--keyring-backend`, `test`,
`--gas`, "900000",
`-b`, `block`,
`-y`,
).CombinedOutput()
Expand Down Expand Up @@ -549,7 +551,6 @@ type addIbcConnectionAction struct {
chainB chainID
clientA uint
clientB uint
order string
}

func (tr TestRun) addIbcConnection(
Expand Down Expand Up @@ -832,6 +833,7 @@ func (tr TestRun) unbondTokens(
`--chain-id`, string(tr.chainConfigs[action.chain].chainId),
`--home`, tr.getValidatorHome(action.chain, action.sender),
`--node`, tr.getValidatorNode(action.chain, action.sender),
`--gas`, "900000",
`--keyring-backend`, `test`,
`-b`, `block`,
`-y`,
Expand Down
58 changes: 34 additions & 24 deletions tests/integration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ func getDefaultValidators() map[validatorID]ValidatorConfig {
}
}

func DoubleSignTestRun() TestRun {
func DefaultTestRun() TestRun {
return TestRun{
name: "double-sign",
name: "default",
containerConfig: ContainerConfig{
containerName: "interchain-security-ds-container",
instanceName: "interchain-security-ds-instance",
containerName: "interchain-security-container",
instanceName: "interchain-security-instance",
ccvVersion: "1",
now: time.Now(),
},
Expand All @@ -109,8 +109,7 @@ func DoubleSignTestRun() TestRun {
".app_state.slashing.params.signed_blocks_window = \"2\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"2s\" | " +
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " +
".app_state.slashing.params.slash_fraction_double_sign = \"0.100000000000000000\"",
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"",
},
chainID("consu"): {
chainId: chainID("consu"),
Expand All @@ -127,12 +126,12 @@ func DoubleSignTestRun() TestRun {
}
}

func DefaultTestRun() TestRun {
func DemocracyTestRun() TestRun {
return TestRun{
name: "default",
name: "democracy",
containerConfig: ContainerConfig{
containerName: "interchain-security-container",
instanceName: "interchain-security-instance",
containerName: "interchain-security-democ-container",
instanceName: "interchain-security-democ-instance",
ccvVersion: "1",
now: time.Now(),
},
Expand All @@ -151,12 +150,13 @@ func DefaultTestRun() TestRun {
".app_state.slashing.params.downtime_jail_duration = \"2s\" | " +
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"",
},
chainID("consu"): {
chainId: chainID("consu"),
binaryName: "interchain-security-cd",
ipPrefix: "7.7.8",
chainID("democ"): {
chainId: chainID("democ"),
binaryName: "interchain-security-cdd",
ipPrefix: "7.7.9",
votingWaitTime: 10,
genesisChanges: ".app_state.gov.voting_params.voting_period = \"10s\" | " +
genesisChanges: ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"10\" | " +
".app_state.gov.voting_params.voting_period = \"10s\" | " +
".app_state.slashing.params.signed_blocks_window = \"2\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"2s\" | " +
Expand All @@ -166,12 +166,12 @@ func DefaultTestRun() TestRun {
}
}

func DemocracyTestRun() TestRun {
func MultiConsumerTestRun() TestRun {
return TestRun{
name: "democracy",
name: "multi-consumer",
containerConfig: ContainerConfig{
containerName: "interchain-security-democ-container",
instanceName: "interchain-security-democ-instance",
containerName: "interchain-security-multic-container",
instanceName: "interchain-security-multic-instance",
ccvVersion: "1",
now: time.Now(),
},
Expand All @@ -190,13 +190,23 @@ func DemocracyTestRun() TestRun {
".app_state.slashing.params.downtime_jail_duration = \"2s\" | " +
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"",
},
chainID("democ"): {
chainId: chainID("democ"),
binaryName: "interchain-security-cdd",
chainID("consu"): {
chainId: chainID("consu"),
binaryName: "interchain-security-cd",
ipPrefix: "7.7.8",
votingWaitTime: 10,
genesisChanges: ".app_state.gov.voting_params.voting_period = \"10s\" | " +
".app_state.slashing.params.signed_blocks_window = \"2\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"2s\" | " +
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"",
},
chainID("densu"): {
chainId: chainID("densu"),
binaryName: "interchain-security-cd",
ipPrefix: "7.7.9",
votingWaitTime: 10,
genesisChanges: ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"10\" | " +
".app_state.gov.voting_params.voting_period = \"10s\" | " +
genesisChanges: ".app_state.gov.voting_params.voting_period = \"10s\" | " +
".app_state.slashing.params.signed_blocks_window = \"2\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"2s\" | " +
Expand Down
13 changes: 7 additions & 6 deletions tests/integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func main() {
dmc.ValidateStringLiterals()
dmc.startDocker()

ds := DoubleSignTestRun()
ds.SetLocalSDKPath(*localSdkPath)
ds.ValidateStringLiterals()
ds.startDocker()
mul := MultiConsumerTestRun()
mul.SetLocalSDKPath(*localSdkPath)
mul.ValidateStringLiterals()
mul.startDocker()

wg.Add(1)
go tr.ExecuteSteps(&wg, happyPathSteps)
Expand All @@ -49,7 +49,7 @@ func main() {
go dmc.ExecuteSteps(&wg, democracySteps)

wg.Add(1)
go ds.ExecuteSteps(&wg, doubleSignProviderSteps)
go mul.ExecuteSteps(&wg, multipleConsumers)

wg.Wait()
fmt.Printf("TOTAL TIME ELAPSED: %v\n", time.Since(start))
Expand Down Expand Up @@ -108,7 +108,8 @@ func (tr *TestRun) runStep(step Step, verbose bool) {

// Check state
if !reflect.DeepEqual(actualState, modelState) {
fmt.Println("action", reflect.TypeOf(step.action).Name())
fmt.Printf("=============== %s FAILED ===============\n", tr.name)
fmt.Println("FAILED action", reflect.TypeOf(step.action).Name())
pretty.Print("actual state", actualState)
pretty.Print("model state", modelState)
log.Fatal(`actual state (-) not equal to model state (+): ` + pretty.Compare(actualState, modelState))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

// stepsDelegate tests basic delegation and resulting validator power changes.
// stepsDelegate tests basic delegation and resulting validator power changes
func stepsDelegate(consumerName string) []Step {
return []Step{
{
Expand Down Expand Up @@ -80,8 +80,8 @@ func stepsDelegate(consumerName string) []Step {
}
}

// stepsDelegate tests validatod unbonding, redelegation and resulting validator power changes.
func stepsUnbondRedelegate(consumerName string) []Step {
// stepsDelegate tests unbonding and resulting validator power changes.
func stepsUnbond(consumerName string) []Step {
return []Step{
{
action: unbondTokensAction{
Expand Down Expand Up @@ -124,6 +124,12 @@ func stepsUnbondRedelegate(consumerName string) []Step {
},
},
},
}
}

// stepsRedelegate tests redelegation and resulting validator power changes.
func stepsRedelegate(consumerName string) []Step {
return []Step{
{
action: redelegateTokensAction{
chain: chainID("provi"),
Expand Down
19 changes: 13 additions & 6 deletions tests/integration/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,28 @@ func concatSteps(steps ...[]Step) []Step {
}

var happyPathSteps = concatSteps(
stepsStartChains("consu", false),
stepsStartChains([]string{"consu"}, false),
stepsDelegate("consu"),
stepsUnbondRedelegate("consu"),
stepsUnbond("consu"),
stepsRedelegate("consu"),
stepsDowntime("consu"),
stepsStopChain("consu"),
)

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

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

0 comments on commit fb83bb7

Please sign in to comment.