committed by
Jack Zampolin
parent
d184121ea0
commit
d1614ebb7e
+42
-5
@@ -735,26 +735,33 @@ func TestProposalsQuery(t *testing.T) {
|
||||
cleanup, _, _, port := InitializeTestLCD(t, 1, []sdk.AccAddress{addrs[0], addrs[1]})
|
||||
defer cleanup()
|
||||
|
||||
depositParam := getDepositParam(t, port)
|
||||
halfMinDeposit := depositParam.MinDeposit.AmountOf(stakeTypes.DefaultBondDenom).Int64() / 2
|
||||
getVotingParam(t, port)
|
||||
getTallyingParam(t, port)
|
||||
|
||||
// Addr1 proposes (and deposits) proposals #1 and #2
|
||||
resultTx := doSubmitProposal(t, port, seeds[0], names[0], passwords[0], addrs[0], 5)
|
||||
resultTx := doSubmitProposal(t, port, seeds[0], names[0], passwords[0], addrs[0], halfMinDeposit)
|
||||
var proposalID1 uint64
|
||||
cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.DeliverTx.GetData(), &proposalID1)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
resultTx = doSubmitProposal(t, port, seeds[0], names[0], passwords[0], addrs[0], 5)
|
||||
|
||||
resultTx = doSubmitProposal(t, port, seeds[0], names[0], passwords[0], addrs[0], halfMinDeposit)
|
||||
var proposalID2 uint64
|
||||
cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.DeliverTx.GetData(), &proposalID2)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Addr2 proposes (and deposits) proposals #3
|
||||
resultTx = doSubmitProposal(t, port, seeds[1], names[1], passwords[1], addrs[1], 5)
|
||||
resultTx = doSubmitProposal(t, port, seeds[1], names[1], passwords[1], addrs[1], halfMinDeposit)
|
||||
var proposalID3 uint64
|
||||
cdc.MustUnmarshalBinaryLengthPrefixed(resultTx.DeliverTx.GetData(), &proposalID3)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// Addr2 deposits on proposals #2 & #3
|
||||
resultTx = doDeposit(t, port, seeds[1], names[1], passwords[1], addrs[1], proposalID2, 5)
|
||||
resultTx = doDeposit(t, port, seeds[1], names[1], passwords[1], addrs[1], proposalID2, halfMinDeposit)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
resultTx = doDeposit(t, port, seeds[1], names[1], passwords[1], addrs[1], proposalID3, 5)
|
||||
|
||||
resultTx = doDeposit(t, port, seeds[1], names[1], passwords[1], addrs[1], proposalID3, halfMinDeposit)
|
||||
tests.WaitForHeight(resultTx.Height+1, port)
|
||||
|
||||
// check deposits match proposal and individual deposits
|
||||
@@ -1246,6 +1253,36 @@ func getValidatorRedelegations(t *testing.T, port string, validatorAddr sdk.ValA
|
||||
|
||||
// ============= Governance Module ================
|
||||
|
||||
func getDepositParam(t *testing.T, port string) gov.DepositParams {
|
||||
res, body := Request(t, port, "GET", "/gov/parameters/deposit", nil)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
|
||||
var depositParams gov.DepositParams
|
||||
err := cdc.UnmarshalJSON([]byte(body), &depositParams)
|
||||
require.Nil(t, err)
|
||||
return depositParams
|
||||
}
|
||||
|
||||
func getVotingParam(t *testing.T, port string) gov.VotingParams {
|
||||
res, body := Request(t, port, "GET", "/gov/parameters/voting", nil)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
|
||||
var votingParams gov.VotingParams
|
||||
err := cdc.UnmarshalJSON([]byte(body), &votingParams)
|
||||
require.Nil(t, err)
|
||||
return votingParams
|
||||
}
|
||||
|
||||
func getTallyingParam(t *testing.T, port string) gov.TallyParams {
|
||||
res, body := Request(t, port, "GET", "/gov/parameters/tallying", nil)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
|
||||
var tallyParams gov.TallyParams
|
||||
err := cdc.UnmarshalJSON([]byte(body), &tallyParams)
|
||||
require.Nil(t, err)
|
||||
return tallyParams
|
||||
}
|
||||
|
||||
func getProposal(t *testing.T, port string, proposalID uint64) gov.Proposal {
|
||||
res, body := Request(t, port, "GET", fmt.Sprintf("/gov/proposals/%d", proposalID), nil)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
|
||||
@@ -1451,7 +1451,7 @@ paths:
|
||||
/gov/proposals/{proposalId}/votes/{voter}:
|
||||
get:
|
||||
summary: Query vote
|
||||
description: Query vote information by proposalId and voter address
|
||||
description: Query vote information by proposal Id and voter address
|
||||
produces:
|
||||
- application/json
|
||||
tags:
|
||||
@@ -1478,6 +1478,83 @@ paths:
|
||||
description: Found no vote
|
||||
500:
|
||||
description: Internal Server Error
|
||||
/gov/parameters/deposit:
|
||||
get:
|
||||
summary: Query governance deposit parameters
|
||||
description: Query governance deposit parameters. The max_deposit_period units are in nanoseconds.
|
||||
produces:
|
||||
- application/json
|
||||
tags:
|
||||
- ICS22
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
min_deposit:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/Coin"
|
||||
max_deposit_period:
|
||||
type: string
|
||||
example: "86400000000000"
|
||||
400:
|
||||
description: <other_path> is not a valid query request path
|
||||
404:
|
||||
description: Found no deposit parameters
|
||||
500:
|
||||
description: Internal Server Error
|
||||
/gov/parameters/tallying:
|
||||
get:
|
||||
summary: Query governance tally parameters
|
||||
description: Query governance tally parameters
|
||||
produces:
|
||||
- application/json
|
||||
tags:
|
||||
- ICS22
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
schema:
|
||||
properties:
|
||||
threshold:
|
||||
type: string
|
||||
example: "0.5000000000"
|
||||
veto:
|
||||
type: string
|
||||
example: "0.3340000000"
|
||||
governance_penalty:
|
||||
type: string
|
||||
example: "0.0100000000"
|
||||
400:
|
||||
description: <other_path> is not a valid query request path
|
||||
404:
|
||||
description: Found no tally parameters
|
||||
500:
|
||||
description: Internal Server Error
|
||||
/gov/parameters/voting:
|
||||
get:
|
||||
summary: Query governance voting parameters
|
||||
description: Query governance voting parameters. The voting_period units are in nanoseconds.
|
||||
produces:
|
||||
- application/json
|
||||
tags:
|
||||
- ICS22
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
schema:
|
||||
properties:
|
||||
voting_period:
|
||||
type: string
|
||||
example: "86400000000000"
|
||||
400:
|
||||
description: <other_path> is not a valid query request path
|
||||
404:
|
||||
description: Found no voting parameters
|
||||
500:
|
||||
description: Internal Server Error
|
||||
|
||||
definitions:
|
||||
CheckTxResult:
|
||||
|
||||
@@ -4,9 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -16,6 +14,9 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
stakeTypes "github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
"github.com/tendermint/tendermint/crypto/secp256k1"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/keys"
|
||||
gapp "github.com/cosmos/cosmos-sdk/cmd/gaia/app"
|
||||
@@ -25,6 +26,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/tests"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/stake"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
Reference in New Issue
Block a user