Skip to content

Commit

Permalink
test: add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaru Wang committed Sep 20, 2023
1 parent 1c6d099 commit 2f007f5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type State map[chainID]ChainState
type ChainState struct {
ValBalances *map[validatorID]uint
Proposals *map[uint]Proposal
ProposedConsumerChains []string
ValPowers *map[validatorID]uint
RepresentativePowers *map[validatorID]uint
Params *[]Param
Expand Down Expand Up @@ -132,6 +133,11 @@ func (tr TestRun) getChainState(chain chainID, modelState ChainState) ChainState
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)
Expand Down Expand Up @@ -772,3 +778,25 @@ func (tr TestRun) curlJsonRPCRequest(method, params, address string) {
verbosity := false
executeCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity)
}


func (tr TestRun) getProposedConsumerChains(chain chainID) []string {
bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName,

"query", "provider", "list-proposed-consumer-chains",
`--node`, tr.getQueryNode(chain),
`-o`, `json`,
).CombinedOutput()
if err != nil {
log.Fatal(err, "\n", string(bz))
}

arr := gjson.Get(string(bz), "proposedChains").Array()
chains := []string{}
for _, c := range arr {
cid := c.Get("chainID").String()
chains = append(chains, cid)
}

return chains
}
3 changes: 3 additions & 0 deletions tests/e2e/steps_start_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func stepStartProviderChain() []Step {
validatorID("bob"): 9500000000,
validatorID("carol"): 9500000000,
},
ProposedConsumerChains: []string{},
},
},
},
Expand Down Expand Up @@ -54,6 +55,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
},
},
ProposedConsumerChains: []string{consumerName},
},
},
},
Expand Down Expand Up @@ -133,6 +135,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint
Status: "PROPOSAL_STATUS_PASSED",
},
},
ProposedConsumerChains: []string{},
ValBalances: &map[validatorID]uint{
validatorID("alice"): 9500000000,
validatorID("bob"): 9500000000,
Expand Down

0 comments on commit 2f007f5

Please sign in to comment.