Skip to content

Commit

Permalink
test: Fix failing e2e test (#1186)
Browse files Browse the repository at this point in the history
* Tests: Fix failing e2e tests

* Update tests/e2e/actions.go

Co-authored-by: MSalopek <matija.salopek994@gmail.com>

* chore: appease lint rules

* added check error message

---------

Co-authored-by: MSalopek <matija.salopek994@gmail.com>
  • Loading branch information
bermuell and MSalopek authored Aug 9, 2023
1 parent aaa545d commit 3f4c54c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1813,14 +1813,16 @@ type assignConsumerPubKeyAction struct {
// reconfigureNode will change keys the node uses and restart
reconfigureNode bool
// executing the action should raise an error
expectError bool
expectError bool
expectedError string
}

func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbose bool) {
valCfg := tr.validatorConfigs[action.validator]

// Note: to get error response reported back from this command '--gas auto' needs to be set.
assignKey := fmt.Sprintf(
`%s tx provider assign-consensus-key %s '%s' --from validator%s --chain-id %s --home %s --node %s --gas 90000 --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 auto --keyring-backend test -y -o json`,
tr.chainConfigs[chainID("provi")].binaryName,
string(tr.chainConfigs[action.chain].chainId),
action.consumerPubkey,
Expand All @@ -1847,8 +1849,12 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos
}

if action.expectError {
if err == nil || !strings.Contains(string(bz), action.expectedError) {
log.Fatalf("expected error not raised: expected: '%s', got '%s'", action.expectedError, (bz))
}

if verbose {
fmt.Printf("got expected error during key assignment | err: %s \n", err.Error())
fmt.Printf("got expected error during key assignment | err: %s | output: %s \n", err, string(bz))
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/steps_start_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
consumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`,
reconfigureNode: false,
expectError: true,
expectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator",
},
state: State{},
},
Expand All @@ -100,6 +101,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
consumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`,
reconfigureNode: false,
expectError: true,
expectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator",
},
state: State{
chainID(consumerName): ChainState{
Expand Down

0 comments on commit 3f4c54c

Please sign in to comment.