From 2f007f57daee7876f630beaae19277fb97e92451 Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Wed, 20 Sep 2023 16:00:34 +0200 Subject: [PATCH] test: add e2e test --- tests/e2e/state.go | 28 ++++++++++++++++++++++++++++ tests/e2e/steps_start_chains.go | 3 +++ 2 files changed, 31 insertions(+) diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 8cc343ef00..a77e053016 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -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 @@ -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) @@ -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 +} diff --git a/tests/e2e/steps_start_chains.go b/tests/e2e/steps_start_chains.go index 6017a22641..e014b76fc1 100644 --- a/tests/e2e/steps_start_chains.go +++ b/tests/e2e/steps_start_chains.go @@ -22,6 +22,7 @@ func stepStartProviderChain() []Step { validatorID("bob"): 9500000000, validatorID("carol"): 9500000000, }, + ProposedConsumerChains: []string{}, }, }, }, @@ -54,6 +55,7 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint Status: "PROPOSAL_STATUS_VOTING_PERIOD", }, }, + ProposedConsumerChains: []string{consumerName}, }, }, }, @@ -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,