From 5ba376820ce964eb94a8db7a44a0291143930d24 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 23 Oct 2018 16:07:28 +0200 Subject: [PATCH 1/4] Add query deposits cmds --- cmd/gaia/cli_test/cli_test.go | 30 ++++++++++++++++++++++++++++++ cmd/gaia/cmd/gaiacli/main.go | 2 ++ 2 files changed, 32 insertions(+) diff --git a/cmd/gaia/cli_test/cli_test.go b/cmd/gaia/cli_test/cli_test.go index 2b717244c7a6..0b2fc3ce2d59 100644 --- a/cmd/gaia/cli_test/cli_test.go +++ b/cmd/gaia/cli_test/cli_test.go @@ -364,6 +364,18 @@ 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 %v", flags)) + require.Len(t, deposits, 2) + require.Equal(t, int64(5), deposits[0].Amount.AmountOf("steak").Int64()) + require.Equal(t, int64(10), deposits[1].Amount.AmountOf("steak").Int64()) + + deposit := executeGetDeposit(t, + fmt.Sprintf("gaiacli query deposit --proposal-id=1 --depositer=foo %v", + flags)) + require.Equal(t, int64(5), 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)) @@ -724,3 +736,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 +} diff --git a/cmd/gaia/cmd/gaiacli/main.go b/cmd/gaia/cmd/gaiacli/main.go index 710966478448..a2804706b760 100644 --- a/cmd/gaia/cmd/gaiacli/main.go +++ b/cmd/gaia/cmd/gaiacli/main.go @@ -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), From b27e743a73b5ffda156da62637cda26dc98f33e0 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 23 Oct 2018 16:28:10 +0200 Subject: [PATCH 2/4] Update test --- cmd/gaia/cli_test/cli_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/gaia/cli_test/cli_test.go b/cmd/gaia/cli_test/cli_test.go index 0b2fc3ce2d59..84773fe672c1 100644 --- a/cmd/gaia/cli_test/cli_test.go +++ b/cmd/gaia/cli_test/cli_test.go @@ -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=foo %v", + 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") @@ -367,14 +372,13 @@ func TestGaiaCLISubmitProposal(t *testing.T) { // test query deposit deposits := executeGetDeposits(t, fmt.Sprintf("gaiacli query deposits --proposal-id=1 %v", flags)) - require.Len(t, deposits, 2) - require.Equal(t, int64(5), deposits[0].Amount.AmountOf("steak").Int64()) - require.Equal(t, int64(10), deposits[1].Amount.AmountOf("steak").Int64()) + require.Len(t, deposits, 1) + require.Equal(t, int64(15), deposits[0].Amount.AmountOf("steak").Int64()) - deposit := executeGetDeposit(t, + deposit = executeGetDeposit(t, fmt.Sprintf("gaiacli query deposit --proposal-id=1 --depositer=foo %v", flags)) - require.Equal(t, int64(5), deposit.Amount.AmountOf("steak").Int64()) + 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()) From 8040a561164ff7ba5bd1ec7d6555fe4f3711fc11 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Tue, 23 Oct 2018 19:49:34 +0200 Subject: [PATCH 3/4] update depositer addr --- cmd/gaia/cli_test/cli_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/gaia/cli_test/cli_test.go b/cmd/gaia/cli_test/cli_test.go index 84773fe672c1..c375bcf4ec59 100644 --- a/cmd/gaia/cli_test/cli_test.go +++ b/cmd/gaia/cli_test/cli_test.go @@ -347,8 +347,8 @@ func TestGaiaCLISubmitProposal(t *testing.T) { require.Equal(t, " 1 - Test", proposalsQuery) deposit := executeGetDeposit(t, - fmt.Sprintf("gaiacli query deposit --proposal-id=1 --depositer=foo %v", - flags)) + 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) @@ -371,13 +371,13 @@ func TestGaiaCLISubmitProposal(t *testing.T) { // test query deposit deposits := executeGetDeposits(t, - fmt.Sprintf("gaiacli query deposits --proposal-id=1 %v", flags)) + 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=foo %v", - flags)) + 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)) From ef8aab84e1994c479f542f4cb4262a586a8db7cf Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Tue, 23 Oct 2018 20:37:36 +0200 Subject: [PATCH 4/4] Update PENDING.md --- PENDING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/PENDING.md b/PENDING.md index d773e4645261..7088a9336119 100644 --- a/PENDING.md +++ b/PENDING.md @@ -21,6 +21,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)