Merge PR #2099: Query staking Pool and Params
This commit is contained in:
committed by
Christopher Goes
parent
68f5ee786c
commit
cfb5acca6e
@@ -117,6 +117,11 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||
fooAcc := executeGetAccount(t, fmt.Sprintf("gaiacli account %s %v", fooAddr, flags))
|
||||
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf("steak").Int64())
|
||||
|
||||
defaultParams := stake.DefaultParams()
|
||||
initialPool := stake.InitialPool()
|
||||
initialPool.BondedTokens = initialPool.BondedTokens.Add(sdk.NewDec(100)) // Delegate tx on GaiaAppGenState
|
||||
initialPool = initialPool.ProcessProvisions(defaultParams) // provisions are added to the pool every hour
|
||||
|
||||
// create validator
|
||||
cvStr := fmt.Sprintf("gaiacli stake create-validator %v", flags)
|
||||
cvStr += fmt.Sprintf(" --from=%s", "bar")
|
||||
@@ -124,6 +129,8 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||
cvStr += fmt.Sprintf(" --amount=%v", "2steak")
|
||||
cvStr += fmt.Sprintf(" --moniker=%v", "bar-vally")
|
||||
|
||||
initialPool.BondedTokens = initialPool.BondedTokens.Add(sdk.NewDec(1))
|
||||
|
||||
executeWrite(t, cvStr, app.DefaultKeyPass)
|
||||
tests.WaitForNextNBlocksTM(2, port)
|
||||
|
||||
@@ -150,6 +157,14 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
||||
*/
|
||||
validator = executeGetValidator(t, fmt.Sprintf("gaiacli stake validator %s --output=json %v", barAddr, flags))
|
||||
require.Equal(t, "1.0000000000", validator.Tokens.String())
|
||||
|
||||
params := executeGetParams(t, fmt.Sprintf("gaiacli stake parameters --output=json %v", flags))
|
||||
require.True(t, defaultParams.Equal(params))
|
||||
|
||||
pool := executeGetPool(t, fmt.Sprintf("gaiacli stake pool --output=json %v", flags))
|
||||
require.Equal(t, initialPool.DateLastCommissionReset, pool.DateLastCommissionReset)
|
||||
require.Equal(t, initialPool.PrevBondedShares, pool.PrevBondedShares)
|
||||
require.Equal(t, initialPool.BondedTokens, pool.BondedTokens)
|
||||
}
|
||||
|
||||
func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||
@@ -328,6 +343,9 @@ func executeGetAccount(t *testing.T, cmdStr string) auth.BaseAccount {
|
||||
return acc
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
// stake
|
||||
|
||||
func executeGetValidator(t *testing.T, cmdStr string) stake.Validator {
|
||||
out := tests.ExecuteT(t, cmdStr, "")
|
||||
var validator stake.Validator
|
||||
@@ -337,6 +355,27 @@ func executeGetValidator(t *testing.T, cmdStr string) stake.Validator {
|
||||
return validator
|
||||
}
|
||||
|
||||
func executeGetPool(t *testing.T, cmdStr string) stake.Pool {
|
||||
out := tests.ExecuteT(t, cmdStr, "")
|
||||
var pool stake.Pool
|
||||
cdc := app.MakeCodec()
|
||||
err := cdc.UnmarshalJSON([]byte(out), &pool)
|
||||
require.NoError(t, err, "out %v\n, err %v", out, err)
|
||||
return pool
|
||||
}
|
||||
|
||||
func executeGetParams(t *testing.T, cmdStr string) stake.Params {
|
||||
out := tests.ExecuteT(t, cmdStr, "")
|
||||
var params stake.Params
|
||||
cdc := app.MakeCodec()
|
||||
err := cdc.UnmarshalJSON([]byte(out), ¶ms)
|
||||
require.NoError(t, err, "out %v\n, err %v", out, err)
|
||||
return params
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
// gov
|
||||
|
||||
func executeGetProposal(t *testing.T, cmdStr string) gov.Proposal {
|
||||
out := tests.ExecuteT(t, cmdStr, "")
|
||||
var proposal gov.Proposal
|
||||
|
||||
@@ -88,6 +88,8 @@ func main() {
|
||||
stakecmd.GetCmdQueryValidators("stake", cdc),
|
||||
stakecmd.GetCmdQueryDelegation("stake", cdc),
|
||||
stakecmd.GetCmdQueryDelegations("stake", cdc),
|
||||
stakecmd.GetCmdQueryParams("stake", cdc),
|
||||
stakecmd.GetCmdQueryPool("stake", cdc),
|
||||
stakecmd.GetCmdQueryUnbondingDelegation("stake", cdc),
|
||||
stakecmd.GetCmdQueryUnbondingDelegations("stake", cdc),
|
||||
stakecmd.GetCmdQueryRedelegation("stake", cdc),
|
||||
|
||||
Reference in New Issue
Block a user