test: e2e/staking to system tests (#21882)
This commit is contained in:
@@ -182,7 +182,7 @@ go test -mod=readonly -tags='system_test' -v ./... --run TestQueryTotalSupply -
|
||||
## Part 4: Set state via TX
|
||||
|
||||
Complexer workflows and tests require modifying state on a running chain. This works only with builtin logic and operations.
|
||||
If we want to burn some our new tokens, we need to submit a bank burn message to do this.
|
||||
If we want to burn some of our new tokens, we need to submit a bank burn message to do this.
|
||||
The CLI wrapper works similar to the query. Just pass the parameters. It uses the `node0` key as *default*:
|
||||
|
||||
```go
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
func TestStakeUnstake(t *testing.T) {
|
||||
// Scenario:
|
||||
// delegate tokens to validator
|
||||
// check validator has been updated
|
||||
// undelegate some tokens
|
||||
|
||||
sut.ResetChain(t)
|
||||
@@ -29,16 +30,24 @@ func TestStakeUnstake(t *testing.T) {
|
||||
// query validator address to delegate tokens
|
||||
rsp := cli.CustomQuery("q", "staking", "validators")
|
||||
valAddr := gjson.Get(rsp, "validators.#.operator_address").Array()[0].String()
|
||||
valPk := gjson.Get(rsp, "validators.#.consensus_pubkey.value").Array()[0].String()
|
||||
|
||||
// stake tokens
|
||||
rsp = cli.RunAndWait("tx", "staking", "delegate", valAddr, "10000stake", "--from="+account1Addr, "--fees=1stake")
|
||||
rsp = cli.RunAndWait("tx", "staking", "delegate", valAddr, "1000000stake", "--from="+account1Addr, "--fees=1stake")
|
||||
RequireTxSuccess(t, rsp)
|
||||
|
||||
t.Log(cli.QueryBalance(account1Addr, "stake"))
|
||||
assert.Equal(t, int64(9989999), cli.QueryBalance(account1Addr, "stake"))
|
||||
assert.Equal(t, int64(8999999), cli.QueryBalance(account1Addr, "stake"))
|
||||
|
||||
// check validator has been updated
|
||||
rsp = cli.CustomQuery("q", "block-results", gjson.Get(rsp, "height").String())
|
||||
validatorUpdates := gjson.Get(rsp, "validator_updates").Array()
|
||||
assert.NotEmpty(t, validatorUpdates)
|
||||
vpk := gjson.Get(validatorUpdates[0].String(), "pub_key_bytes").String()
|
||||
assert.Equal(t, vpk, valPk)
|
||||
|
||||
rsp = cli.CustomQuery("q", "staking", "delegation", account1Addr, valAddr)
|
||||
assert.Equal(t, "10000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
|
||||
assert.Equal(t, "1000000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
|
||||
assert.Equal(t, "stake", gjson.Get(rsp, "delegation_response.balance.denom").String(), rsp)
|
||||
|
||||
// unstake tokens
|
||||
@@ -46,7 +55,7 @@ func TestStakeUnstake(t *testing.T) {
|
||||
RequireTxSuccess(t, rsp)
|
||||
|
||||
rsp = cli.CustomQuery("q", "staking", "delegation", account1Addr, valAddr)
|
||||
assert.Equal(t, "5000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
|
||||
assert.Equal(t, "995000", gjson.Get(rsp, "delegation_response.balance.amount").String(), rsp)
|
||||
assert.Equal(t, "stake", gjson.Get(rsp, "delegation_response.balance.denom").String(), rsp)
|
||||
|
||||
rsp = cli.CustomQuery("q", "staking", "unbonding-delegation", account1Addr, valAddr)
|
||||
|
||||
Reference in New Issue
Block a user