Skip to content

Commit

Permalink
Merge PR #2570: Cmds for query deposits
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes committed Oct 23, 2018
2 parents 5476b1b + ef8aab8 commit 701a00c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ BREAKING CHANGES
* [cli] \#2073 --from can now be either an address or a key name
* [cli] [\#1184](https://github.com/cosmos/cosmos-sdk/issues/1184) Subcommands reorganisation, see [\#2390](https://github.com/cosmos/cosmos-sdk/pull/2390) for a comprehensive list of changes.
* [cli] [\#2524](https://github.com/cosmos/cosmos-sdk/issues/2524) Add support offline mode to `gaiacli tx sign`. Lookups are not performed if the flag `--offline` is on.
* [cli] [\#2570](https://github.com/cosmos/cosmos-sdk/pull/2570) Add commands to query deposits on proposals

* Gaia
* Make the transient store key use a distinct store key. [#2013](https://github.com/cosmos/cosmos-sdk/pull/2013)
Expand Down
34 changes: 34 additions & 0 deletions cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
proposalsQuery, _ = tests.ExecuteT(t, fmt.Sprintf("gaiacli query proposals %v", flags), "")
require.Equal(t, " 1 - Test", proposalsQuery)

deposit := executeGetDeposit(t,
fmt.Sprintf("gaiacli query deposit --proposal-id=1 --depositer=%s --output=json %v",
fooAddr, flags))
require.Equal(t, int64(5), deposit.Amount.AmountOf("steak").Int64())

depositStr := fmt.Sprintf("gaiacli tx deposit %v", flags)
depositStr += fmt.Sprintf(" --from=%s", "foo")
depositStr += fmt.Sprintf(" --deposit=%s", "10steak")
Expand All @@ -364,6 +369,17 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
executeWrite(t, depositStr, app.DefaultKeyPass)
tests.WaitForNextNBlocksTM(2, port)

// test query deposit
deposits := executeGetDeposits(t,
fmt.Sprintf("gaiacli query deposits --proposal-id=1 --output=json %v", flags))
require.Len(t, deposits, 1)
require.Equal(t, int64(15), deposits[0].Amount.AmountOf("steak").Int64())

deposit = executeGetDeposit(t,
fmt.Sprintf("gaiacli query deposit --proposal-id=1 --depositer=%s --output=json %v",
fooAddr, flags))
require.Equal(t, int64(15), deposit.Amount.AmountOf("steak").Int64())

fooAcc = executeGetAccount(t, fmt.Sprintf("gaiacli query account %s %v", fooAddr, flags))
require.Equal(t, int64(35), fooAcc.GetCoins().AmountOf("steak").Int64())
proposal1 = executeGetProposal(t, fmt.Sprintf("gaiacli query proposal --proposal-id=1 --output=json %v", flags))
Expand Down Expand Up @@ -724,3 +740,21 @@ func executeGetVotes(t *testing.T, cmdStr string) []gov.Vote {
require.NoError(t, err, "out %v\n, err %v", out, err)
return votes
}

func executeGetDeposit(t *testing.T, cmdStr string) gov.Deposit {
out, _ := tests.ExecuteT(t, cmdStr, "")
var deposit gov.Deposit
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &deposit)
require.NoError(t, err, "out %v\n, err %v", out, err)
return deposit
}

func executeGetDeposits(t *testing.T, cmdStr string) []gov.Deposit {
out, _ := tests.ExecuteT(t, cmdStr, "")
var deposits []gov.Deposit
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &deposits)
require.NoError(t, err, "out %v\n, err %v", out, err)
return deposits
}
2 changes: 2 additions & 0 deletions cmd/gaia/cmd/gaiacli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func main() {
stakecmd.GetCmdQueryPool(storeStake, cdc),
govcmd.GetCmdQueryProposal(storeGov, cdc),
govcmd.GetCmdQueryProposals(storeGov, cdc),
govcmd.GetCmdQueryDeposit(storeGov, cdc),
govcmd.GetCmdQueryDeposits(storeGov, cdc),
stakecmd.GetCmdQueryRedelegation(storeStake, cdc),
stakecmd.GetCmdQueryRedelegations(storeStake, cdc),
slashingcmd.GetCmdQuerySigningInfo(storeSlashing, cdc),
Expand Down

0 comments on commit 701a00c

Please sign in to comment.