Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: e2e/staking to system tests #21882

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions tests/e2e/staking/cli_test.go

This file was deleted.

122 changes: 0 additions & 122 deletions tests/e2e/staking/suite.go

This file was deleted.

2 changes: 1 addition & 1 deletion tests/systemtests/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions tests/systemtests/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -29,24 +30,32 @@ 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
rsp = cli.RunAndWait("tx", "staking", "unbond", valAddr, "5000stake", "--from="+account1Addr, "--fees=1stake")
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)
Expand Down
Loading