Skip to content

Commit 2908466

Browse files
JulianToledanomergify[bot]
authored andcommitted
test: e2e/staking to system tests (#21882)
(cherry picked from commit c971f75)
1 parent 5ad47e3 commit 2908466

File tree

4 files changed

+14
-147
lines changed

4 files changed

+14
-147
lines changed

tests/e2e/staking/cli_test.go

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/e2e/staking/suite.go

Lines changed: 0 additions & 122 deletions
This file was deleted.

tests/systemtests/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ go test -mod=readonly -tags='system_test' -v ./... --run TestQueryTotalSupply -
182182
## Part 4: Set state via TX
183183

184184
Complexer workflows and tests require modifying state on a running chain. This works only with builtin logic and operations.
185-
If we want to burn some our new tokens, we need to submit a bank burn message to do this.
185+
If we want to burn some of our new tokens, we need to submit a bank burn message to do this.
186186
The CLI wrapper works similar to the query. Just pass the parameters. It uses the `node0` key as *default*:
187187

188188
```go

tests/systemtests/staking_test.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
func TestStakeUnstake(t *testing.T) {
1313
// Scenario:
1414
// delegate tokens to validator
15+
// check validator has been updated
1516
// undelegate some tokens
1617

1718
sut.ResetChain(t)
@@ -29,24 +30,32 @@ func TestStakeUnstake(t *testing.T) {
2930
// query validator address to delegate tokens
3031
rsp := cli.CustomQuery("q", "staking", "validators")
3132
valAddr := gjson.Get(rsp, "validators.#.operator_address").Array()[0].String()
33+
valPk := gjson.Get(rsp, "validators.#.consensus_pubkey.value").Array()[0].String()
3234

3335
// stake tokens
34-
rsp = cli.RunAndWait("tx", "staking", "delegate", valAddr, "10000stake", "--from="+account1Addr, "--fees=1stake")
36+
rsp = cli.RunAndWait("tx", "staking", "delegate", valAddr, "1000000stake", "--from="+account1Addr, "--fees=1stake")
3537
RequireTxSuccess(t, rsp)
3638

3739
t.Log(cli.QueryBalance(account1Addr, "stake"))
38-
assert.Equal(t, int64(9989999), cli.QueryBalance(account1Addr, "stake"))
40+
assert.Equal(t, int64(8999999), cli.QueryBalance(account1Addr, "stake"))
41+
42+
// check validator has been updated
43+
rsp = cli.CustomQuery("q", "block-results", gjson.Get(rsp, "height").String())
44+
validatorUpdates := gjson.Get(rsp, "validator_updates").Array()
45+
assert.NotEmpty(t, validatorUpdates)
46+
vpk := gjson.Get(validatorUpdates[0].String(), "pub_key_bytes").String()
47+
assert.Equal(t, vpk, valPk)
3948

4049
rsp = cli.CustomQuery("q", "staking", "delegation", account1Addr, valAddr)
41-
assert.Equal(t, "10000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
50+
assert.Equal(t, "1000000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
4251
assert.Equal(t, "stake", gjson.Get(rsp, "delegation_response.balance.denom").String(), rsp)
4352

4453
// unstake tokens
4554
rsp = cli.RunAndWait("tx", "staking", "unbond", valAddr, "5000stake", "--from="+account1Addr, "--fees=1stake")
4655
RequireTxSuccess(t, rsp)
4756

4857
rsp = cli.CustomQuery("q", "staking", "delegation", account1Addr, valAddr)
49-
assert.Equal(t, "5000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
58+
assert.Equal(t, "995000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
5059
assert.Equal(t, "stake", gjson.Get(rsp, "delegation_response.balance.denom").String(), rsp)
5160

5261
rsp = cli.CustomQuery("q", "staking", "unbonding-delegation", account1Addr, valAddr)

0 commit comments

Comments
 (0)