Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: added more e2e permissionless tests (backport #2262) #2270

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 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 -cv latest -cv v5.2.0 -cv v4.4.0
run: go run ./tests/e2e/... --tc compatibility -pv latest -cv v5.2.0 -cv v4.4.0
happy-path-test:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down Expand Up @@ -309,6 +309,38 @@ jobs:
go-version: "1.22" # The Go version to download (if necessary) and use.
- name: E2E active set changes
run: go run ./tests/e2e/... --tc active-set-changes
permissionless-basic-test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- uses: actions/checkout@v4
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22" # The Go version to download (if necessary) and use.
- name: E2E basic permissionless tests
run: go run ./tests/e2e/... --tc permissionless-ics
permissionless-topN-test:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- uses: actions/checkout@v4
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22" # The Go version to download (if necessary) and use.
- name: E2E permissionless TopN tests
run: go run ./tests/e2e/... --tc permissionless-topN

inactive-provider-validators-on-consumer-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -346,6 +378,8 @@ jobs:
- partial-set-security-validators-denylisted-test
- partial-set-security-modification-proposal
- active-set-changes-test
- permissionless-basic-test
- permissionless-topN-test
if: ${{ failure() }}
runs-on: ubuntu-latest
steps:
Expand Down
65 changes: 59 additions & 6 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,58 @@ func (tr Chain) createConsumerChain(action CreateConsumerChainAction, verbose bo
tr.testConfig.chainConfigs[action.ConsumerChain] = consumerChainCfg
}

type RemoveConsumerChainAction struct {
Chain ChainID
From ValidatorID
ConsumerChain ChainID
}

func (tr Chain) removeConsumerChain(action RemoveConsumerChainAction, verbose bool) {
consumerId := tr.testConfig.chainConfigs[action.ConsumerChain].ConsumerId
if consumerId == "" {
log.Fatal("failed removing consumer chain. no consumer-id found for chain: ",
action.ConsumerChain)
}

// Send consumer chain removal
cmd := tr.target.ExecCommand(
tr.testConfig.chainConfigs[action.Chain].BinaryName,
"tx", "provider", "remove-consumer", string(consumerId),
`--from`, `validator`+fmt.Sprint(action.From),
`--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId),
`--home`, tr.getValidatorHome(action.Chain, action.From),
`--gas`, `900000`,
`--node`, tr.getValidatorNode(action.Chain, action.From),
`--keyring-backend`, `test`,
"--output", "json",
`-y`,
)

bz, err := cmd.CombinedOutput()
if err != nil {
log.Println("command failed:", cmd)
log.Fatalf("remove consumer failed error: %s, output: %s", err.Error(), string(bz))
}

// Check transaction
txResponse := &TxResponse{}
err = json.Unmarshal(bz, txResponse)
if err != nil {
log.Fatalf("unmarshalling tx response on remove-consumer: %s, json: %s", err.Error(), string(bz))
}

if txResponse.Code != 0 {
log.Fatalf("sending remove-consumer transaction failed with error code %d, Log:'%s'", txResponse.Code, txResponse.RawLog)
}

if verbose {
fmt.Println("running 'remove-consumer' returned: ", txResponse)
}

tr.waitBlocks(action.Chain, 2, 10*time.Second)

}

type SubmitConsumerAdditionProposalAction struct {
PreCCV bool
Chain ChainID
Expand Down Expand Up @@ -884,6 +936,7 @@ type SubmitConsumerModificationProposalAction struct {
Denylist []string
AllowInactiveVals bool
MinStake uint64
NewOwner string
}

func (tr Chain) submitConsumerModificationProposal(
Expand All @@ -900,8 +953,9 @@ func (tr Chain) submitConsumerModificationProposal(
authority := "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn"

msg := types.MsgUpdateConsumer{
Owner: authority,
ConsumerId: consumerId,
Owner: authority,
ConsumerId: consumerId,
NewOwnerAddress: action.NewOwner,
PowerShapingParameters: &types.PowerShapingParameters{
Top_N: action.TopN,
ValidatorsPowerCap: action.ValidatorsPowerCap,
Expand Down Expand Up @@ -1981,12 +2035,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 4 blocks
// Because `.app_state.provider.params.blocks_per_epoch` is set to 3 in the E2E tests, we wait 3 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, 4, 90*time.Second)
tr.waitBlocks(action.ChainB, 4, 90*time.Second)

tr.waitBlocks(action.ChainA, 3, 90*time.Second)
tr.waitBlocks(action.ChainB, 3, 90*time.Second)
// hermes clear packets ibc0 transfer channel-13
cmd := tr.target.ExecCommand("hermes", "clear", "packets",
"--chain", string(tr.testConfig.chainConfigs[action.ChainA].ChainId),
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ var stepChoices = map[string]StepChoice{
description: "test permissionless ics",
testConfig: PermissionlessTestCfg,
},
"permissionless-topN": {
name: "permissionless-topN",
steps: stepsPermissionlessTopN(),
description: "test permissionless ics topN transformation",
testConfig: PermissionlessTestCfg,
},
"inactive-vals-outside-max-validators": {
name: "inactive-vals-outside-max-validators",
steps: stepsInactiveValsTopNReproduce(),
Expand Down
39 changes: 22 additions & 17 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"log"
"os/exec"
"regexp"
"sort"
"strconv"
"time"

Expand Down Expand Up @@ -56,17 +57,7 @@
}
startBlock := tr.target.GetBlockHeight(chain)

start := time.Now()
for {
thisBlock := tr.target.GetBlockHeight(chain)
if thisBlock >= startBlock+blocks {
return
}
if time.Since(start) > timeout {
panic(fmt.Sprintf("\n\n\nwaitBlocks method on chain '%s' has timed out after: %s\n\n", chain, timeout))
}
time.Sleep(time.Second)
}
tr.waitUntilBlock(chain, startBlock+blocks, timeout)
}

func (tr Chain) waitUntilBlock(chain ChainID, block uint, timeout time.Duration) {
Expand Down Expand Up @@ -658,8 +649,13 @@
if phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_INITIALIZED)] ||
phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_REGISTERED)] ||
phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_LAUNCHED)] {
id := c.Get("chain_id").String()
chains[ChainID(id)] = true
id := c.Get("consumer_id").String()
for chainRef, cfg := range tr.chainConfigs {
if cfg.ConsumerId == ConsumerID(id) {
// note: 'chainRef' is the reference the test uses and not necessarily matching chain id
chains[chainRef] = true
}
}
}
}

Expand Down Expand Up @@ -814,12 +810,14 @@
arr := gjson.Get(string(bz), "consumer_ids").Array()
chains := []ChainID{}
for _, c := range arr {
for _, chain := range tr.chainConfigs {
for chainRef, chain := range tr.chainConfigs {
if chain.ConsumerId == ConsumerID(c.String()) {
chains = append(chains, chain.ChainId)
// we report the test chain reference which might not match the chain ID
// to support testing consumer chains with same chain ID
chains = append(chains, chainRef)
break
}
}

Check warning

Code scanning / CodeQL

Iteration over map Warning test

Iteration over map may be a possible source of non-determinism
}

return chains
Expand Down Expand Up @@ -903,14 +901,21 @@
arr := gjson.Get(string(bz), "chains").Array()
chains := []string{}
for _, c := range arr {
cid := c.Get("chain_id").String()
phase := c.Get("phase").String()
if phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_INITIALIZED)] ||
phase == types.ConsumerPhase_name[int32(types.CONSUMER_PHASE_REGISTERED)] {
chains = append(chains, cid)
cid := ConsumerID(c.Get("consumer_id").String())
for chainRef, chainCfg := range tr.chainConfigs {
if chainCfg.ConsumerId == cid {
chains = append(chains, string(chainRef))
}
}
}
}

sort.Slice(chains, func(i, j int) bool {
return chains[i] < chains[j]
})
return chains
}

Expand Down
Loading
Loading