Skip to content

Commit

Permalink
Adapt e2e compatibility tests to permissisonless ICS changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Sep 10, 2024
1 parent c7171b2 commit 15c2d1f
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 161 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nightly-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
# Run compatibility tests for different consumer (-cv) and provider (-pv) versions.
# Combination of all provider versions with consumer versions are tested.
# For new versions to be tested add/modify -pc/-cv parameters.
run: go run ./tests/e2e/... --tc compatibility -pv latest -pv v4.3.1-lsm -pv v3.3.3-lsm -cv latest -cv v4.4.0 -cv v3.3.0
run: go run ./tests/e2e/... --tc compatibility -pv latest -cv latest -cv v5.2.0 -cv v4.4.0
happy-path-test:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ test-e2e-multi-consumer:
test-e2e-parallel:
go run ./tests/e2e/... --include-multi-consumer --parallel

# run E2E compatibility tests against latest release
# run E2E compatibility tests against consumer running latest release
test-e2e-compatibility-tests-latest:
go run ./tests/e2e/... --tc compatibility -pv $(LATEST_RELEASE)
go run ./tests/e2e/... --tc compatibility -cv $(LATEST_RELEASE)

# run full E2E tests in sequence (including multiconsumer) using latest tagged gaia
test-gaia-e2e:
Expand Down
73 changes: 38 additions & 35 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const (
V300 = "v3.0.0"
)

// type aliases
type (
AssignConsumerPubKeyAction = e2e.AssignConsumerPubKeyAction
)

type SendTokensAction struct {
Chain ChainID
From ValidatorID
Expand Down Expand Up @@ -1971,11 +1976,11 @@ func (tr Chain) relayPacketsHermes(
action RelayPacketsAction,
verbose bool,
) {
// Because `.app_state.provider.params.blocks_per_epoch` is set to 3 in the E2E tests, we wait 3 blocks
// Because `.app_state.provider.params.blocks_per_epoch` is set to 3 in the E2E tests, we wait 4 blocks
// before relaying the packets to guarantee that at least one epoch passes and hence any `VSCPacket`s get
// queued and are subsequently relayed.
tr.waitBlocks(action.ChainA, 3, 90*time.Second)
tr.waitBlocks(action.ChainB, 3, 90*time.Second)
tr.waitBlocks(action.ChainA, 4, 90*time.Second)
tr.waitBlocks(action.ChainB, 4, 90*time.Second)

// hermes clear packets ibc0 transfer channel-13
cmd := tr.target.ExecCommand("hermes", "clear", "packets",
Expand Down Expand Up @@ -2349,7 +2354,7 @@ type UnjailValidatorAction struct {
// Sends an unjail transaction to the provider chain
func (tr Chain) unjailValidator(action UnjailValidatorAction, verbose bool) {
// wait until downtime_jail_duration has elapsed, to make sure the validator can be unjailed
tr.WaitTime(61 * time.Second)
tr.WaitTime(65 * time.Second)

cmd := tr.target.ExecCommand(
tr.testConfig.chainConfigs[action.Provider].BinaryName,
Expand Down Expand Up @@ -2611,7 +2616,7 @@ func (tr Chain) invokeDoublesignSlash(
if err != nil {
log.Fatal(err, "\n", string(bz))
}
tr.waitBlocks("provi", 20, 4*time.Minute)
tr.waitBlocks("provi", 22, 4*time.Minute)
} else { // tr.useCometMock
validatorPrivateKeyAddress := tr.GetValidatorPrivateKeyAddress(action.Chain, action.Validator)

Expand Down Expand Up @@ -2701,18 +2706,7 @@ func (tr Chain) lightClientAttack(
tr.waitBlocks(chain, 1, 10*time.Second)
}

type AssignConsumerPubKeyAction struct {
Chain ChainID
Validator ValidatorID
ConsumerPubkey string
// ReconfigureNode will change keys the node uses and restart
ReconfigureNode bool
// executing the action should raise an error
ExpectError bool
ExpectedError string
}

func (tr Chain) assignConsumerPubKey(action AssignConsumerPubKeyAction, verbose bool) {
func (tr Chain) assignConsumerPubKey(action e2e.AssignConsumerPubKeyAction, verbose bool) {
valCfg := tr.testConfig.validatorConfigs[action.Validator]

// Note: to get error response reported back from this command '--gas auto' needs to be set.
Expand All @@ -2722,28 +2716,12 @@ func (tr Chain) assignConsumerPubKey(action AssignConsumerPubKeyAction, verbose
gas = "9000000"
}

assignKey := fmt.Sprintf(
`%s tx provider assign-consensus-key %s '%s' --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`,
tr.testConfig.chainConfigs[ChainID("provi")].BinaryName,
string(tr.testConfig.chainConfigs[action.Chain].ConsumerId),
action.ConsumerPubkey,
action.Validator,
tr.testConfig.chainConfigs[ChainID("provi")].ChainId,
bz, err := tr.target.AssignConsumerPubKey(action, gas,
tr.getValidatorHome(ChainID("provi"), action.Validator),
tr.getValidatorNode(ChainID("provi"), action.Validator),
gas,
)

cmd := tr.target.ExecCommand(
"/bin/bash", "-c",
assignKey,
verbose,
)

if verbose {
fmt.Println("assignConsumerPubKey cmd:", cmd.String())
}

bz, err := cmd.CombinedOutput()
if err != nil && !action.ExpectError {
log.Fatalf("unexpected error during key assignment - output: %s, err: %s", string(bz), err)
}
Expand Down Expand Up @@ -3112,3 +3090,28 @@ func (tr Chain) AdvanceTimeForChain(chain ChainID, duration time.Duration) {
// wait for 1 block of the chain to get a block with the advanced timestamp
tr.waitBlocks(chain, 1, time.Minute)
}

func (tr Commands) AssignConsumerPubKey(action e2e.AssignConsumerPubKeyAction, gas, home, node string, verbose bool) ([]byte, error) {
assignKey := fmt.Sprintf(
`%s tx provider assign-consensus-key %s '%s' --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`,
tr.chainConfigs[ChainID("provi")].BinaryName,
string(tr.chainConfigs[action.Chain].ConsumerId),
action.ConsumerPubkey,
action.Validator,
tr.chainConfigs[ChainID("provi")].ChainId,
home,
node,
gas,
)

cmd := tr.target.ExecCommand(
"/bin/bash", "-c",
assignKey,
)

if verbose {
fmt.Println("assignConsumerPubKey cmd:", cmd.String())
}

return cmd.CombinedOutput()
}
115 changes: 0 additions & 115 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,121 +43,6 @@ type Chain struct {
testConfig *TestConfig
}

func (tr Chain) GetChainState(chain ChainID, modelState ChainState) ChainState {
chainState := ChainState{}

if modelState.ValBalances != nil {
valBalances := tr.GetBalances(chain, *modelState.ValBalances)
chainState.ValBalances = &valBalances
}

if modelState.Proposals != nil {
proposals := tr.GetProposals(chain, *modelState.Proposals)
chainState.Proposals = &proposals
}

if modelState.ProposedConsumerChains != nil {
proposedConsumerChains := tr.GetProposedConsumerChains(chain)
chainState.ProposedConsumerChains = &proposedConsumerChains
}

if modelState.ValPowers != nil {
tr.waitBlocks(chain, 1, 10*time.Second)
powers := tr.GetValPowers(chain, *modelState.ValPowers)
chainState.ValPowers = &powers
}

if modelState.StakedTokens != nil {
representPowers := tr.GetStakedTokens(chain, *modelState.StakedTokens)
chainState.StakedTokens = &representPowers
}

if modelState.IBCTransferParams != nil {
params := tr.target.GetIBCTransferParams(chain)
chainState.IBCTransferParams = &params
}

if modelState.Rewards != nil {
rewards := tr.GetRewards(chain, *modelState.Rewards)
chainState.Rewards = &rewards
}

if modelState.ConsumerChains != nil {
chains := tr.target.GetConsumerChains(chain)
chainState.ConsumerChains = &chains
}

if modelState.AssignedKeys != nil {
assignedKeys := tr.GetConsumerAddresses(chain, *modelState.AssignedKeys)
chainState.AssignedKeys = &assignedKeys
}

if modelState.ProviderKeys != nil {
providerKeys := tr.GetProviderAddresses(chain, *modelState.ProviderKeys)
chainState.ProviderKeys = &providerKeys
}

if modelState.RegisteredConsumerRewardDenoms != nil {
registeredConsumerRewardDenoms := tr.target.GetRegisteredConsumerRewardDenoms(chain)
chainState.RegisteredConsumerRewardDenoms = &registeredConsumerRewardDenoms
}

if modelState.ClientsFrozenHeights != nil {
chainClientsFrozenHeights := map[string]clienttypes.Height{}
for id := range *modelState.ClientsFrozenHeights {
chainClientsFrozenHeights[id] = tr.GetClientFrozenHeight(chain, id)
}
chainState.ClientsFrozenHeights = &chainClientsFrozenHeights
}

if modelState.HasToValidate != nil {
hasToValidate := map[ValidatorID][]ChainID{}
for validatorId := range *modelState.HasToValidate {
hasToValidate[validatorId] = tr.target.GetHasToValidate(validatorId)
}
chainState.HasToValidate = &hasToValidate
}

if modelState.InflationRateChange != nil {
// get the inflation rate now
inflationRateNow := tr.target.GetInflationRate(chain)

// wait a block
tr.waitBlocks(chain, 1, 10*time.Second)

// get the new inflation rate
inflationRateAfter := tr.target.GetInflationRate(chain)

// calculate the change
inflationRateChange := inflationRateAfter - inflationRateNow
var inflationRateChangeDirection int
if inflationRateChange > 0 {
inflationRateChangeDirection = 1
} else if inflationRateChange < 0 {
inflationRateChangeDirection = -1
} else {
inflationRateChangeDirection = 0
}
chainState.InflationRateChange = &inflationRateChangeDirection
}

if modelState.ConsumerCommissionRates != nil {
consumerCommissionRates := tr.GetConsumerCommissionRates(chain, *modelState.ConsumerCommissionRates)
chainState.ConsumerCommissionRates = &consumerCommissionRates
}

if modelState.ConsumerPendingPacketQueueSize != nil {
pendingPacketQueueSize := tr.target.GetPendingPacketQueueSize(chain)
chainState.ConsumerPendingPacketQueueSize = &pendingPacketQueueSize
}

if *verbose {
log.Println("Done getting chain state:\n" + pretty.Sprint(chainState))
}

return chainState
}

func (tr Chain) waitBlocks(chain ChainID, blocks uint, timeout time.Duration) {
if tr.testConfig.useCometmock {
// call advance_blocks method on cometmock
Expand Down
Loading

0 comments on commit 15c2d1f

Please sign in to comment.