Skip to content

Commit

Permalink
test: use cometmock in CI; run parallel jobs (#1181)
Browse files Browse the repository at this point in the history
* test: reduce number of happyPath steps

* test: reduce number of happyPath steps

* test: update steps after opt-out

* test: update steps and fix lint

* tests: add cometmock tests

* chore: Fix and enable CometMock in e2e tests (#1184)

* Add make time.sleep WaitTime and wait block after waiting time

* Uncomment verbose error check

* Fix spacing

* Make format

* Add make target for CometMock e2e tests

* Add CometMock job to automated tests

* tests: revert reducing happyPath steps count

* tests: revert reducing happyPath steps count

* Fix --gas auto with CometMock

---------

Co-authored-by: Philip Offtermatt <[email protected]>
Co-authored-by: Philip Offtermatt <[email protected]>
  • Loading branch information
3 people authored Aug 9, 2023
1 parent 3f4c54c commit 4045b6a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/automated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,31 @@ jobs:
run: make proto-check
- name: Unit, integration and difference tests
run: go test ./...
E2E_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: E2E tests
run: make test-e2e-short
Cometmock_Tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
lfs: true
- name: Checkout LFS objects
run: git lfs checkout
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: E2E tests
run: make test-e2e-short-cometmock
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ test-diff:
test-e2e-short:
go run ./tests/e2e/... --happy-path-only

# run only happy path E2E tests with cometmock
# this set of traces does not test equivocation but it does check downtime
test-e2e-short-cometmock:
go run ./tests/e2e/... --short-happy-path --use-cometmock --use-gorelayer

# run full E2E tests in sequence (including multiconsumer)
test-e2e-multi-consumer:
go run ./tests/e2e/... --include-multi-consumer
Expand Down
15 changes: 12 additions & 3 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func (tr *TestRun) voteGovProposal(
wg.Wait()
// wait for inclusion in a block -> '--broadcast-mode block' is deprecated
tr.waitBlocks(action.chain, 1, 10*time.Second)
time.Sleep(time.Duration(tr.chainConfigs[action.chain].votingWaitTime) * time.Second)
tr.WaitTime(time.Duration(tr.chainConfigs[action.chain].votingWaitTime) * time.Second)
}

type startConsumerChainAction struct {
Expand Down Expand Up @@ -1821,15 +1821,21 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos
valCfg := tr.validatorConfigs[action.validator]

// Note: to get error response reported back from this command '--gas auto' needs to be set.
gas := "auto"
// Unfortunately, --gas auto does not work with CometMock. so when using CometMock, just use --gas 9000000 then
if tr.useCometmock {
gas = "9000000"
}
assignKey := fmt.Sprintf(
`%s tx provider assign-consensus-key %s '%s' --from validator%s --chain-id %s --home %s --node %s --gas auto --keyring-backend test -y -o json`,
`%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].chainId),
action.consumerPubkey,
action.validator,
tr.chainConfigs[chainID("provi")].chainId,
tr.getValidatorHome(chainID("provi"), action.validator),
tr.getValidatorNode(chainID("provi"), action.validator),
gas,
)

//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
Expand All @@ -1848,7 +1854,7 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos
log.Fatalf("unexpected error during key assignment - output: %s, err: %s", string(bz), err)
}

if action.expectError {
if action.expectError && !tr.useCometmock { // error report ony works with --gas auto, which does not work with CometMock, so ignore
if err == nil || !strings.Contains(string(bz), action.expectedError) {
log.Fatalf("expected error not raised: expected: '%s', got '%s'", action.expectedError, (bz))
}
Expand Down Expand Up @@ -1972,6 +1978,8 @@ func (tr TestRun) GetPathNameForGorelayer(chainA, chainB chainID) string {
}

// WaitTime waits for the given duration.
// To make sure that the new timestamp is visible on-chain, it also waits until at least one block has been
// produced on each chain after waiting.
// The CometMock version of this takes a pointer to the TestRun as it needs to manipulate
// information in the testrun that stores how much each chain has waited, to keep times in sync.
// Be careful that all functions calling WaitTime should therefore also take a pointer to the TestRun.
Expand All @@ -1985,6 +1993,7 @@ func (tr *TestRun) WaitTime(duration time.Duration) {
continue
}
tr.AdvanceTimeForChain(chain, duration)
tr.waitBlocks(chain, 1, 2*time.Second)
}
}
}
Expand Down

0 comments on commit 4045b6a

Please sign in to comment.