Skip to content

Commit 3df7b71

Browse files
authored
test: adapt e2e compatibility tests (#2247)
* Adapt e2e compatibility tests to permissisonless ICS changes * udpate 'latest' version in Makefile * adapt relay delays + doublesigning waits
1 parent 27fc2b1 commit 3df7b71

File tree

7 files changed

+263
-165
lines changed

7 files changed

+263
-165
lines changed

.github/workflows/nightly-e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
# Run compatibility tests for different consumer (-cv) and provider (-pv) versions.
3737
# Combination of all provider versions with consumer versions are tested.
3838
# For new versions to be tested add/modify -pc/-cv parameters.
39-
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
39+
run: go run ./tests/e2e/... --tc compatibility -pv latest -cv latest -cv v5.2.0 -cv v4.4.0
4040
happy-path-test:
4141
runs-on: ubuntu-latest
4242
timeout-minutes: 20

Makefile

+3-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
44
COMMIT := $(shell git log -1 --format='%H')
55
# Fetch tags and get the latest ICS version by filtering tags by vX.Y.Z and vX.Y.Z-lsm
66
# using lazy set to only execute commands when variable is used
7-
# Note: v.5.0.0 is currently excluded from the list as it's a pre-release and will be added back once it's out of pre-release status
8-
LATEST_RELEASE ?= $(shell git fetch; git tag -l --sort -v:refname 'v*.?' 'v*.?'-lsm 'v*.??' 'v*.??'-lsm --no-contains v5.0.0 | head -n 1)
7+
LATEST_RELEASE ?= $(shell git fetch; git tag -l --sort -v:refname 'v*.?' 'v*.?'-lsm 'v*.??' 'v*.??'-lsm | head -n 1)
98

109
# don't override user values
1110
ifeq (,$(VERSION))
@@ -98,9 +97,9 @@ test-e2e-multi-consumer:
9897
test-e2e-parallel:
9998
go run ./tests/e2e/... --include-multi-consumer --parallel
10099

101-
# run E2E compatibility tests against latest release
100+
# run E2E compatibility tests against consumer running latest release
102101
test-e2e-compatibility-tests-latest:
103-
go run ./tests/e2e/... --tc compatibility -pv $(LATEST_RELEASE)
102+
go run ./tests/e2e/... --tc compatibility -cv $(LATEST_RELEASE)
104103

105104
# run full E2E tests in sequence (including multiconsumer) using latest tagged gaia
106105
test-gaia-e2e:

tests/e2e/actions.go

+40-37
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ const (
3737
V300 = "v3.0.0"
3838
)
3939

40+
// type aliases
41+
type (
42+
AssignConsumerPubKeyAction = e2e.AssignConsumerPubKeyAction
43+
)
44+
4045
type SendTokensAction struct {
4146
Chain ChainID
4247
From ValidatorID
@@ -1971,11 +1976,11 @@ func (tr Chain) relayPacketsHermes(
19711976
action RelayPacketsAction,
19721977
verbose bool,
19731978
) {
1974-
// Because `.app_state.provider.params.blocks_per_epoch` is set to 3 in the E2E tests, we wait 3 blocks
1979+
// Because `.app_state.provider.params.blocks_per_epoch` is set to 3 in the E2E tests, we wait 4 blocks
19751980
// before relaying the packets to guarantee that at least one epoch passes and hence any `VSCPacket`s get
19761981
// queued and are subsequently relayed.
1977-
tr.waitBlocks(action.ChainA, 3, 90*time.Second)
1978-
tr.waitBlocks(action.ChainB, 3, 90*time.Second)
1982+
tr.waitBlocks(action.ChainA, 4, 90*time.Second)
1983+
tr.waitBlocks(action.ChainB, 4, 90*time.Second)
19791984

19801985
// hermes clear packets ibc0 transfer channel-13
19811986
cmd := tr.target.ExecCommand("hermes", "clear", "packets",
@@ -1992,8 +1997,8 @@ func (tr Chain) relayPacketsHermes(
19921997
log.Fatal(err, "\n", string(bz))
19931998
}
19941999

1995-
tr.waitBlocks(action.ChainA, 1, 30*time.Second)
1996-
tr.waitBlocks(action.ChainB, 1, 30*time.Second)
2000+
tr.waitBlocks(action.ChainA, 2, 30*time.Second)
2001+
tr.waitBlocks(action.ChainB, 2, 30*time.Second)
19972002
}
19982003

19992004
type RelayRewardPacketsToProviderAction struct {
@@ -2349,7 +2354,7 @@ type UnjailValidatorAction struct {
23492354
// Sends an unjail transaction to the provider chain
23502355
func (tr Chain) unjailValidator(action UnjailValidatorAction, verbose bool) {
23512356
// wait until downtime_jail_duration has elapsed, to make sure the validator can be unjailed
2352-
tr.WaitTime(61 * time.Second)
2357+
tr.WaitTime(65 * time.Second)
23532358

23542359
cmd := tr.target.ExecCommand(
23552360
tr.testConfig.chainConfigs[action.Provider].BinaryName,
@@ -2611,7 +2616,7 @@ func (tr Chain) invokeDoublesignSlash(
26112616
if err != nil {
26122617
log.Fatal(err, "\n", string(bz))
26132618
}
2614-
tr.waitBlocks("provi", 20, 4*time.Minute)
2619+
tr.waitBlocks("provi", 25, 4*time.Minute)
26152620
} else { // tr.useCometMock
26162621
validatorPrivateKeyAddress := tr.GetValidatorPrivateKeyAddress(action.Chain, action.Validator)
26172622

@@ -2701,18 +2706,7 @@ func (tr Chain) lightClientAttack(
27012706
tr.waitBlocks(chain, 1, 10*time.Second)
27022707
}
27032708

2704-
type AssignConsumerPubKeyAction struct {
2705-
Chain ChainID
2706-
Validator ValidatorID
2707-
ConsumerPubkey string
2708-
// ReconfigureNode will change keys the node uses and restart
2709-
ReconfigureNode bool
2710-
// executing the action should raise an error
2711-
ExpectError bool
2712-
ExpectedError string
2713-
}
2714-
2715-
func (tr Chain) assignConsumerPubKey(action AssignConsumerPubKeyAction, verbose bool) {
2709+
func (tr Chain) assignConsumerPubKey(action e2e.AssignConsumerPubKeyAction, verbose bool) {
27162710
valCfg := tr.testConfig.validatorConfigs[action.Validator]
27172711

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

2725-
assignKey := fmt.Sprintf(
2726-
`%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`,
2727-
tr.testConfig.chainConfigs[ChainID("provi")].BinaryName,
2728-
string(tr.testConfig.chainConfigs[action.Chain].ConsumerId),
2729-
action.ConsumerPubkey,
2730-
action.Validator,
2731-
tr.testConfig.chainConfigs[ChainID("provi")].ChainId,
2719+
bz, err := tr.target.AssignConsumerPubKey(action, gas,
27322720
tr.getValidatorHome(ChainID("provi"), action.Validator),
27332721
tr.getValidatorNode(ChainID("provi"), action.Validator),
2734-
gas,
2722+
verbose,
27352723
)
27362724

2737-
cmd := tr.target.ExecCommand(
2738-
"/bin/bash", "-c",
2739-
assignKey,
2740-
)
2741-
2742-
if verbose {
2743-
fmt.Println("assignConsumerPubKey cmd:", cmd.String())
2744-
}
2745-
2746-
bz, err := cmd.CombinedOutput()
27472725
if err != nil && !action.ExpectError {
27482726
log.Fatalf("unexpected error during key assignment - output: %s, err: %s", string(bz), err)
27492727
}
@@ -3112,3 +3090,28 @@ func (tr Chain) AdvanceTimeForChain(chain ChainID, duration time.Duration) {
31123090
// wait for 1 block of the chain to get a block with the advanced timestamp
31133091
tr.waitBlocks(chain, 1, time.Minute)
31143092
}
3093+
3094+
func (tr Commands) AssignConsumerPubKey(action e2e.AssignConsumerPubKeyAction, gas, home, node string, verbose bool) ([]byte, error) {
3095+
assignKey := fmt.Sprintf(
3096+
`%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`,
3097+
tr.chainConfigs[ChainID("provi")].BinaryName,
3098+
string(tr.chainConfigs[action.Chain].ConsumerId),
3099+
action.ConsumerPubkey,
3100+
action.Validator,
3101+
tr.chainConfigs[ChainID("provi")].ChainId,
3102+
home,
3103+
node,
3104+
gas,
3105+
)
3106+
3107+
cmd := tr.target.ExecCommand(
3108+
"/bin/bash", "-c",
3109+
assignKey,
3110+
)
3111+
3112+
if verbose {
3113+
fmt.Println("assignConsumerPubKey cmd:", cmd.String())
3114+
}
3115+
3116+
return cmd.CombinedOutput()
3117+
}

tests/e2e/state.go

-115
Original file line numberDiff line numberDiff line change
@@ -43,121 +43,6 @@ type Chain struct {
4343
testConfig *TestConfig
4444
}
4545

46-
func (tr Chain) GetChainState(chain ChainID, modelState ChainState) ChainState {
47-
chainState := ChainState{}
48-
49-
if modelState.ValBalances != nil {
50-
valBalances := tr.GetBalances(chain, *modelState.ValBalances)
51-
chainState.ValBalances = &valBalances
52-
}
53-
54-
if modelState.Proposals != nil {
55-
proposals := tr.GetProposals(chain, *modelState.Proposals)
56-
chainState.Proposals = &proposals
57-
}
58-
59-
if modelState.ProposedConsumerChains != nil {
60-
proposedConsumerChains := tr.GetProposedConsumerChains(chain)
61-
chainState.ProposedConsumerChains = &proposedConsumerChains
62-
}
63-
64-
if modelState.ValPowers != nil {
65-
tr.waitBlocks(chain, 1, 10*time.Second)
66-
powers := tr.GetValPowers(chain, *modelState.ValPowers)
67-
chainState.ValPowers = &powers
68-
}
69-
70-
if modelState.StakedTokens != nil {
71-
representPowers := tr.GetStakedTokens(chain, *modelState.StakedTokens)
72-
chainState.StakedTokens = &representPowers
73-
}
74-
75-
if modelState.IBCTransferParams != nil {
76-
params := tr.target.GetIBCTransferParams(chain)
77-
chainState.IBCTransferParams = &params
78-
}
79-
80-
if modelState.Rewards != nil {
81-
rewards := tr.GetRewards(chain, *modelState.Rewards)
82-
chainState.Rewards = &rewards
83-
}
84-
85-
if modelState.ConsumerChains != nil {
86-
chains := tr.target.GetConsumerChains(chain)
87-
chainState.ConsumerChains = &chains
88-
}
89-
90-
if modelState.AssignedKeys != nil {
91-
assignedKeys := tr.GetConsumerAddresses(chain, *modelState.AssignedKeys)
92-
chainState.AssignedKeys = &assignedKeys
93-
}
94-
95-
if modelState.ProviderKeys != nil {
96-
providerKeys := tr.GetProviderAddresses(chain, *modelState.ProviderKeys)
97-
chainState.ProviderKeys = &providerKeys
98-
}
99-
100-
if modelState.RegisteredConsumerRewardDenoms != nil {
101-
registeredConsumerRewardDenoms := tr.target.GetRegisteredConsumerRewardDenoms(chain)
102-
chainState.RegisteredConsumerRewardDenoms = &registeredConsumerRewardDenoms
103-
}
104-
105-
if modelState.ClientsFrozenHeights != nil {
106-
chainClientsFrozenHeights := map[string]clienttypes.Height{}
107-
for id := range *modelState.ClientsFrozenHeights {
108-
chainClientsFrozenHeights[id] = tr.GetClientFrozenHeight(chain, id)
109-
}
110-
chainState.ClientsFrozenHeights = &chainClientsFrozenHeights
111-
}
112-
113-
if modelState.HasToValidate != nil {
114-
hasToValidate := map[ValidatorID][]ChainID{}
115-
for validatorId := range *modelState.HasToValidate {
116-
hasToValidate[validatorId] = tr.target.GetHasToValidate(validatorId)
117-
}
118-
chainState.HasToValidate = &hasToValidate
119-
}
120-
121-
if modelState.InflationRateChange != nil {
122-
// get the inflation rate now
123-
inflationRateNow := tr.target.GetInflationRate(chain)
124-
125-
// wait a block
126-
tr.waitBlocks(chain, 1, 10*time.Second)
127-
128-
// get the new inflation rate
129-
inflationRateAfter := tr.target.GetInflationRate(chain)
130-
131-
// calculate the change
132-
inflationRateChange := inflationRateAfter - inflationRateNow
133-
var inflationRateChangeDirection int
134-
if inflationRateChange > 0 {
135-
inflationRateChangeDirection = 1
136-
} else if inflationRateChange < 0 {
137-
inflationRateChangeDirection = -1
138-
} else {
139-
inflationRateChangeDirection = 0
140-
}
141-
chainState.InflationRateChange = &inflationRateChangeDirection
142-
}
143-
144-
if modelState.ConsumerCommissionRates != nil {
145-
consumerCommissionRates := tr.GetConsumerCommissionRates(chain, *modelState.ConsumerCommissionRates)
146-
chainState.ConsumerCommissionRates = &consumerCommissionRates
147-
}
148-
149-
if modelState.ConsumerPendingPacketQueueSize != nil {
150-
pendingPacketQueueSize := tr.target.GetPendingPacketQueueSize(chain)
151-
chainState.ConsumerPendingPacketQueueSize = &pendingPacketQueueSize
152-
}
153-
154-
if *verbose {
155-
log.Println("Done getting chain state:\n" + pretty.Sprint(chainState))
156-
}
157-
158-
return chainState
159-
}
160-
16146
func (tr Chain) waitBlocks(chain ChainID, blocks uint, timeout time.Duration) {
16247
if tr.testConfig.useCometmock {
16348
// call advance_blocks method on cometmock

0 commit comments

Comments
 (0)