Skip to content

Commit

Permalink
Merge branch 'develop' into rigel/blockly-mint
Browse files Browse the repository at this point in the history
  • Loading branch information
rigelrozanski authored Nov 22, 2018
2 parents d41eeb1 + f09fa33 commit b678bcc
Show file tree
Hide file tree
Showing 35 changed files with 597 additions and 435 deletions.
10 changes: 8 additions & 2 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ BREAKING CHANGES
* [cli] [\#2786](https://github.com/cosmos/cosmos-sdk/pull/2786) Fix redelegation command flow
* [cli] [\#2829](https://github.com/cosmos/cosmos-sdk/pull/2829) add-genesis-account command now validates state when adding accounts
* [cli] [\#2804](https://github.com/cosmos/cosmos-sdk/issues/2804) Check whether key exists before passing it on to `tx create-validator`.
* [cli] [\#2874](https://github.com/cosmos/cosmos-sdk/pull/2874) `gaiacli tx sign` takes an optional `--output-document` flag to support output redirection.

* Gaia
* [mint] [\#2825] minting now occurs every block, inflation parameter updates still hourly
Expand All @@ -18,6 +19,7 @@ BREAKING CHANGES
* [\#2752](https://github.com/cosmos/cosmos-sdk/pull/2752) Don't hardcode bondable denom.
* [\#2019](https://github.com/cosmos/cosmos-sdk/issues/2019) Cap total number of signatures. Current per-transaction limit is 7, and if that is exceeded transaction is rejected.
* [\#2801](https://github.com/cosmos/cosmos-sdk/pull/2801) Remove AppInit structure.
* [\#2798](https://github.com/cosmos/cosmos-sdk/issues/2798) Governance API has miss-spelled English word in JSON response ('depositer' -> 'depositor')

* Tendermint

Expand Down Expand Up @@ -67,15 +69,19 @@ IMPROVEMENTS
- [types] #2776 Improve safety of `Coin` and `Coins` types. Various functions
and methods will panic when a negative amount is discovered.
- #2815 Gas unit fields changed from `int64` to `uint64`.
- #2825 More staking and distribution invariants

- #2821 Codespaces are now strings
- #2779 Introduce `ValidateBasic` to the `Tx` interface and call it in the ante
handler.
- #2825 More staking and distribution invariants

* Tendermint
- #2796 Update to go-amino 0.14.1


BUG FIXES

* Gaia REST API (`gaiacli advanced rest-server`)
- [gaia-lite] #2868 Added handler for governance tally endpoit

* Gaia CLI (`gaiacli`)

Expand Down
3 changes: 2 additions & 1 deletion baseapp/baseapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ func (tx *txTest) setFailOnHandler(fail bool) {
}

// Implements Tx
func (tx txTest) GetMsgs() []sdk.Msg { return tx.Msgs }
func (tx txTest) GetMsgs() []sdk.Msg { return tx.Msgs }
func (tx txTest) ValidateBasic() sdk.Error { return nil }

const (
routeMsgCounter = "msgCounter"
Expand Down
49 changes: 36 additions & 13 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ func TestDeposit(t *testing.T) {
func TestVote(t *testing.T) {
name, password := "test", "1234567890"
addr, seed := CreateAddr(t, "test", password, GetKeyBase(t))
cleanup, _, _, port := InitializeTestLCD(t, 1, []sdk.AccAddress{addr})
cleanup, _, operAddrs, port := InitializeTestLCD(t, 1, []sdk.AccAddress{addr})
defer cleanup()

// create SubmitProposal TX
Expand All @@ -696,21 +696,35 @@ func TestVote(t *testing.T) {
proposal := getProposal(t, port, proposalID)
require.Equal(t, "Test", proposal.GetTitle())

// create SubmitProposal TX
// deposit
resultTx = doDeposit(t, port, seed, name, password, addr, proposalID, 5)
tests.WaitForHeight(resultTx.Height+1, port)

// query proposal
proposal = getProposal(t, port, proposalID)
require.Equal(t, gov.StatusVotingPeriod, proposal.GetStatus())

// create SubmitProposal TX
// vote
resultTx = doVote(t, port, seed, name, password, addr, proposalID)
tests.WaitForHeight(resultTx.Height+1, port)

vote := getVote(t, port, proposalID, addr)
require.Equal(t, proposalID, vote.ProposalID)
require.Equal(t, gov.OptionYes, vote.Option)

tally := getTally(t, port, proposalID)
require.Equal(t, sdk.ZeroDec(), tally.Yes, "tally should be 0 as the address is not bonded")

// create bond TX
resultTx = doDelegate(t, port, seed, name, password, addr, operAddrs[0], 60)
tests.WaitForHeight(resultTx.Height+1, port)

// vote
resultTx = doVote(t, port, seed, name, password, addr, proposalID)
tests.WaitForHeight(resultTx.Height+1, port)

tally = getTally(t, port, proposalID)
require.Equal(t, sdk.NewDec(60), tally.Yes, "tally should be equal to the amount delegated")
}

func TestUnjail(t *testing.T) {
Expand Down Expand Up @@ -816,11 +830,11 @@ func TestProposalsQuery(t *testing.T) {
require.Equal(t, proposalID3, (proposals[2]).GetProposalID())

// Test query deposited by addr1
proposals = getProposalsFilterDepositer(t, port, addrs[0])
proposals = getProposalsFilterDepositor(t, port, addrs[0])
require.Equal(t, proposalID1, (proposals[0]).GetProposalID())

// Test query deposited by addr2
proposals = getProposalsFilterDepositer(t, port, addrs[1])
proposals = getProposalsFilterDepositor(t, port, addrs[1])
require.Equal(t, proposalID2, (proposals[0]).GetProposalID())
require.Equal(t, proposalID3, (proposals[1]).GetProposalID())

Expand All @@ -834,7 +848,7 @@ func TestProposalsQuery(t *testing.T) {
require.Equal(t, proposalID3, (proposals[0]).GetProposalID())

// Test query voted and deposited by addr1
proposals = getProposalsFilterVoterDepositer(t, port, addrs[0], addrs[0])
proposals = getProposalsFilterVoterDepositor(t, port, addrs[0], addrs[0])
require.Equal(t, proposalID2, (proposals[0]).GetProposalID())

// Test query votes on Proposal 2
Expand Down Expand Up @@ -1301,8 +1315,8 @@ func getDeposits(t *testing.T, port string, proposalID uint64) []gov.Deposit {
return deposits
}

func getDeposit(t *testing.T, port string, proposalID uint64, depositerAddr sdk.AccAddress) gov.Deposit {
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d/deposits/%s", proposalID, depositerAddr), nil)
func getDeposit(t *testing.T, port string, proposalID uint64, depositorAddr sdk.AccAddress) gov.Deposit {
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d/deposits/%s", proposalID, depositorAddr), nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
var deposit gov.Deposit
err := cdc.UnmarshalJSON([]byte(body), &deposit)
Expand All @@ -1328,6 +1342,15 @@ func getVotes(t *testing.T, port string, proposalID uint64) []gov.Vote {
return votes
}

func getTally(t *testing.T, port string, proposalID uint64) gov.TallyResult {
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d/tally", proposalID), nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
var tally gov.TallyResult
err := cdc.UnmarshalJSON([]byte(body), &tally)
require.Nil(t, err)
return tally
}

func getProposalsAll(t *testing.T, port string) []gov.Proposal {
res, body := Request(t, port, "GET", "/gov/proposals", nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
Expand All @@ -1338,8 +1361,8 @@ func getProposalsAll(t *testing.T, port string) []gov.Proposal {
return proposals
}

func getProposalsFilterDepositer(t *testing.T, port string, depositerAddr sdk.AccAddress) []gov.Proposal {
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?depositer=%s", depositerAddr), nil)
func getProposalsFilterDepositor(t *testing.T, port string, depositorAddr sdk.AccAddress) []gov.Proposal {
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?depositor=%s", depositorAddr), nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)

var proposals []gov.Proposal
Expand All @@ -1358,8 +1381,8 @@ func getProposalsFilterVoter(t *testing.T, port string, voterAddr sdk.AccAddress
return proposals
}

func getProposalsFilterVoterDepositer(t *testing.T, port string, voterAddr, depositerAddr sdk.AccAddress) []gov.Proposal {
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?depositer=%s&voter=%s", depositerAddr, voterAddr), nil)
func getProposalsFilterVoterDepositor(t *testing.T, port string, voterAddr, depositorAddr sdk.AccAddress) []gov.Proposal {
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals?depositor=%s&voter=%s", depositorAddr, voterAddr), nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)

var proposals []gov.Proposal
Expand Down Expand Up @@ -1421,7 +1444,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk

// deposit on proposal
jsonStr := []byte(fmt.Sprintf(`{
"depositer": "%s",
"depositor": "%s",
"amount": [{ "denom": "%s", "amount": "%d" }],
"base_req": {
"name": "%s",
Expand Down
67 changes: 48 additions & 19 deletions client/lcd/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,8 +1226,8 @@ paths:
required: false
type: string
- in: query
name: depositer
description: depositer address
name: depositor
description: depositor address
required: false
type: string
- in: query
Expand Down Expand Up @@ -1281,7 +1281,7 @@ paths:
properties:
base_req:
"$ref": "#/definitions/BaseReq"
depositer:
depositor:
"$ref": "#/definitions/Address"
amount:
type: array
Expand Down Expand Up @@ -1321,6 +1321,29 @@ paths:
description: Invalid proposal id
500:
description: Internal Server Error
/gov/proposals/{proposalId}/tally:
get:
summary: Get a proposal's tally result at the current time
description: Gets a proposal's tally result at the current time. If the proposal is pending deposits (i.e status 'DepositPeriod') it returns an empty tally result.
produces:
- application/json
tags:
- ICS22
parameters:
- type: string
description: proposal id
name: proposalId
required: true
in: path
responses:
200:
description: OK
schema:
$ref: "#/definitions/TallyResult"
400:
description: Invalid proposal id
500:
description: Internal Server Error
/gov/proposals/{proposalId}/votes:
post:
summary: Vote a proposal
Expand Down Expand Up @@ -1418,10 +1441,10 @@ paths:
description: Invalid proposal id
500:
description: Internal Server Error
/gov/proposals/{proposalId}/deposits/{depositer}:
/gov/proposals/{proposalId}/deposits/{depositor}:
get:
summary: Query deposit
description: Query deposit by proposalId and depositer address
description: Query deposit by proposalId and depositor address
produces:
- application/json
tags:
Expand All @@ -1433,8 +1456,8 @@ paths:
required: true
in: path
- type: string
description: Bech32 depositer address
name: depositer
description: Bech32 depositor address
name: depositor
required: true
in: path
responses:
Expand All @@ -1443,7 +1466,7 @@ paths:
schema:
$ref: "#/definitions/Deposit"
400:
description: Invalid proposal id or depositer address
description: Invalid proposal id or depositor address
404:
description: Found no deposit
500:
Expand Down Expand Up @@ -1893,16 +1916,7 @@ definitions:
proposal_status:
type: string
tally_result:
type: object
properties:
yes:
type: string
abstain:
type: string
no:
type: string
no_with_veto:
type: string
$ref: "#/definitions/TallyResult"
submit_time:
type: string
total_deposit:
Expand All @@ -1920,8 +1934,23 @@ definitions:
"$ref": "#/definitions/Coin"
proposal_id:
type: integer
depositer:
depositor:
"$ref": "#/definitions/Address"
TallyResult:
type: object
properties:
yes:
type: string
example: "0.0000000000"
abstain:
type: string
example: "0.0000000000"
no:
type: string
example: "0.0000000000"
no_with_veto:
type: string
example: "0.0000000000"
Vote:
type: object
properties:
Expand Down
5 changes: 3 additions & 2 deletions client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"bytes"
"fmt"
"io"
"os"

"github.com/cosmos/cosmos-sdk/client/context"
Expand Down Expand Up @@ -88,7 +89,7 @@ func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error), cdc *

// PrintUnsignedStdTx builds an unsigned StdTx and prints it to os.Stdout.
// Don't perform online validation or lookups if offline is true.
func PrintUnsignedStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg, offline bool) (err error) {
func PrintUnsignedStdTx(w io.Writer, txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msgs []sdk.Msg, offline bool) (err error) {
var stdTx auth.StdTx
if offline {
stdTx, err = buildUnsignedStdTxOffline(txBldr, cliCtx, msgs)
Expand All @@ -100,7 +101,7 @@ func PrintUnsignedStdTx(txBldr authtxb.TxBuilder, cliCtx context.CLIContext, msg
}
json, err := txBldr.Codec.MarshalJSON(stdTx)
if err == nil {
fmt.Printf("%s\n", json)
fmt.Fprintf(w, "%s\n", json)
}
return
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/gaia/cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
require.Equal(t, " 1 - Test", proposalsQuery)

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

Expand Down Expand Up @@ -394,7 +394,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
require.Equal(t, int64(15), deposits[0].Amount.AmountOf(stakeTypes.DefaultBondDenom).Int64())

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

Expand Down
Loading

0 comments on commit b678bcc

Please sign in to comment.