|
|
|
@@ -20,7 +20,6 @@ import (
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
|
|
|
|
stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestGaiaCLIKeysAddMultisig(t *testing.T) {
|
|
|
|
@@ -167,8 +166,9 @@ func TestGaiaCLIFeesDeduction(t *testing.T) {
|
|
|
|
|
require.Equal(t, fooAmt.Int64(), fooAcc.GetCoins().AmountOf(fooDenom).Int64())
|
|
|
|
|
|
|
|
|
|
// insufficient funds (coins + fees) tx fails
|
|
|
|
|
largeCoins := staking.TokensFromTendermintPower(10000000)
|
|
|
|
|
success, _, _ = f.TxSend(
|
|
|
|
|
keyFoo, barAddr, sdk.NewInt64Coin(fooDenom, 10000000),
|
|
|
|
|
keyFoo, barAddr, sdk.NewCoin(fooDenom, largeCoins),
|
|
|
|
|
fmt.Sprintf("--fees=%s", sdk.NewInt64Coin(feeDenom, 2)))
|
|
|
|
|
require.False(t, success)
|
|
|
|
|
|
|
|
|
@@ -201,45 +201,47 @@ func TestGaiaCLISend(t *testing.T) {
|
|
|
|
|
barAddr := f.KeyAddress(keyBar)
|
|
|
|
|
|
|
|
|
|
fooAcc := f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
startTokens := staking.TokensFromTendermintPower(50)
|
|
|
|
|
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Send some tokens from one account to the other
|
|
|
|
|
f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10))
|
|
|
|
|
sendTokens := staking.TokensFromTendermintPower(10)
|
|
|
|
|
f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens))
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
// Ensure account balances match expected
|
|
|
|
|
barAcc := f.QueryAccount(barAddr)
|
|
|
|
|
require.Equal(t, int64(10), barAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Test --dry-run
|
|
|
|
|
success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--dry-run")
|
|
|
|
|
success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--dry-run")
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
|
|
|
|
|
// Check state didn't change
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// test autosequencing
|
|
|
|
|
f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10))
|
|
|
|
|
f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens))
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
// Ensure account balances match expected
|
|
|
|
|
barAcc = f.QueryAccount(barAddr)
|
|
|
|
|
require.Equal(t, int64(20), barAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, sendTokens.MulRaw(2), barAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(30), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens.Sub(sendTokens.MulRaw(2)), fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// test memo
|
|
|
|
|
f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--memo='testmemo'")
|
|
|
|
|
f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--memo='testmemo'")
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
// Ensure account balances match expected
|
|
|
|
|
barAcc = f.QueryAccount(barAddr)
|
|
|
|
|
require.Equal(t, int64(30), barAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, sendTokens.MulRaw(3), barAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(20), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens.Sub(sendTokens.MulRaw(3)), fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
f.Cleanup()
|
|
|
|
|
}
|
|
|
|
@@ -256,34 +258,36 @@ func TestGaiaCLIGasAuto(t *testing.T) {
|
|
|
|
|
barAddr := f.KeyAddress(keyBar)
|
|
|
|
|
|
|
|
|
|
fooAcc := f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
startTokens := staking.TokensFromTendermintPower(50)
|
|
|
|
|
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Test failure with auto gas disabled and very little gas set by hand
|
|
|
|
|
success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=10")
|
|
|
|
|
sendTokens := staking.TokensFromTendermintPower(10)
|
|
|
|
|
success, _, _ := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=10")
|
|
|
|
|
require.False(t, success)
|
|
|
|
|
|
|
|
|
|
// Check state didn't change
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Test failure with negative gas
|
|
|
|
|
success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=-100")
|
|
|
|
|
success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=-100")
|
|
|
|
|
require.False(t, success)
|
|
|
|
|
|
|
|
|
|
// Check state didn't change
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Test failure with 0 gas
|
|
|
|
|
success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=0")
|
|
|
|
|
success, _, _ = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=0")
|
|
|
|
|
require.False(t, success)
|
|
|
|
|
|
|
|
|
|
// Check state didn't change
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Enable auto gas
|
|
|
|
|
success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=auto")
|
|
|
|
|
success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=auto")
|
|
|
|
|
require.NotEmpty(t, stderr)
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
cdc := app.MakeCodec()
|
|
|
|
@@ -295,7 +299,7 @@ func TestGaiaCLIGasAuto(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Check state has changed accordingly
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
f.Cleanup()
|
|
|
|
|
}
|
|
|
|
@@ -308,23 +312,17 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
|
|
|
|
proc := f.GDStart()
|
|
|
|
|
defer proc.Stop(false)
|
|
|
|
|
|
|
|
|
|
fooAddr := f.KeyAddress(keyFoo)
|
|
|
|
|
barAddr := f.KeyAddress(keyBar)
|
|
|
|
|
barVal := sdk.ValAddress(barAddr)
|
|
|
|
|
|
|
|
|
|
consPubKey := sdk.MustBech32ifyConsPub(ed25519.GenPrivKey().PubKey())
|
|
|
|
|
|
|
|
|
|
f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10))
|
|
|
|
|
sendTokens := staking.TokensFromTendermintPower(10)
|
|
|
|
|
f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens))
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
barAcc := f.QueryAccount(barAddr)
|
|
|
|
|
require.Equal(t, int64(10), barAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
fooAcc := f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
|
|
|
|
|
defaultParams := staking.DefaultParams()
|
|
|
|
|
initialPool := staking.InitialPool()
|
|
|
|
|
initialPool.BondedTokens = initialPool.BondedTokens.Add(sdk.NewInt(101)) // Delegate tx on GaiaAppGenState
|
|
|
|
|
require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Generate a create validator transaction and ensure correctness
|
|
|
|
|
success, stdout, stderr := f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2), "--generate-only")
|
|
|
|
@@ -337,21 +335,22 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
|
|
|
|
require.Equal(t, 0, len(msg.GetSignatures()))
|
|
|
|
|
|
|
|
|
|
// Test --dry-run
|
|
|
|
|
success, _, _ = f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2), "--dry-run")
|
|
|
|
|
newValTokens := staking.TokensFromTendermintPower(2)
|
|
|
|
|
success, _, _ = f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewCoin(denom, newValTokens), "--dry-run")
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
|
|
|
|
|
// Create the validator
|
|
|
|
|
f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewInt64Coin(denom, 2))
|
|
|
|
|
f.TxStakingCreateValidator(keyBar, consPubKey, sdk.NewCoin(denom, newValTokens))
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
// Ensure funds were deducted properly
|
|
|
|
|
barAcc = f.QueryAccount(barAddr)
|
|
|
|
|
require.Equal(t, int64(8), barAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, sendTokens.Sub(newValTokens), barAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Ensure that validator state is as expected
|
|
|
|
|
validator := f.QueryStakingValidator(barVal)
|
|
|
|
|
require.Equal(t, validator.OperatorAddr, barVal)
|
|
|
|
|
require.True(sdk.IntEq(t, sdk.NewInt(2), validator.Tokens))
|
|
|
|
|
require.True(sdk.IntEq(t, newValTokens, validator.Tokens))
|
|
|
|
|
|
|
|
|
|
// Query delegations to the validator
|
|
|
|
|
validatorDelegations := f.QueryStakingDelegationsTo(barVal)
|
|
|
|
@@ -359,27 +358,21 @@ func TestGaiaCLICreateValidator(t *testing.T) {
|
|
|
|
|
require.NotZero(t, validatorDelegations[0].Shares)
|
|
|
|
|
|
|
|
|
|
// unbond a single share
|
|
|
|
|
success = f.TxStakingUnbond(keyBar, "1", barVal)
|
|
|
|
|
unbondTokens := staking.TokensFromTendermintPower(1)
|
|
|
|
|
success = f.TxStakingUnbond(keyBar, unbondTokens.String(), barVal)
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
// Ensure bonded staking is correct
|
|
|
|
|
remainingTokens := newValTokens.Sub(unbondTokens)
|
|
|
|
|
validator = f.QueryStakingValidator(barVal)
|
|
|
|
|
require.Equal(t, "1", validator.Tokens.String())
|
|
|
|
|
require.Equal(t, remainingTokens, validator.Tokens)
|
|
|
|
|
|
|
|
|
|
// Get unbonding delegations from the validator
|
|
|
|
|
validatorUbds := f.QueryStakingUnbondingDelegationsFrom(barVal)
|
|
|
|
|
require.Len(t, validatorUbds, 1)
|
|
|
|
|
require.Len(t, validatorUbds[0].Entries, 1)
|
|
|
|
|
require.Equal(t, "1", validatorUbds[0].Entries[0].Balance.Amount.String())
|
|
|
|
|
|
|
|
|
|
// Query staking parameters
|
|
|
|
|
params := f.QueryStakingParameters()
|
|
|
|
|
require.True(t, defaultParams.Equal(params))
|
|
|
|
|
|
|
|
|
|
// Query staking pool
|
|
|
|
|
pool := f.QueryStakingPool()
|
|
|
|
|
require.Equal(t, initialPool.BondedTokens, pool.BondedTokens)
|
|
|
|
|
require.Equal(t, remainingTokens.String(), validatorUbds[0].Entries[0].Balance.Amount.String())
|
|
|
|
|
|
|
|
|
|
f.Cleanup()
|
|
|
|
|
}
|
|
|
|
@@ -399,14 +392,16 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
|
|
|
|
fooAddr := f.KeyAddress(keyFoo)
|
|
|
|
|
|
|
|
|
|
fooAcc := f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(stakingTypes.DefaultBondDenom).Int64())
|
|
|
|
|
startTokens := staking.TokensFromTendermintPower(50)
|
|
|
|
|
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(staking.DefaultBondDenom))
|
|
|
|
|
|
|
|
|
|
proposalsQuery := f.QueryGovProposals()
|
|
|
|
|
require.Empty(t, proposalsQuery)
|
|
|
|
|
|
|
|
|
|
// Test submit generate only for submit proposal
|
|
|
|
|
proposalTokens := staking.TokensFromTendermintPower(5)
|
|
|
|
|
success, stdout, stderr := f.TxGovSubmitProposal(
|
|
|
|
|
keyFoo, "Text", "Test", "test", sdk.NewInt64Coin(denom, 5), "--generate-only")
|
|
|
|
|
keyFoo, "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens), "--generate-only")
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
require.Empty(t, stderr)
|
|
|
|
|
msg := unmarshalStdTx(t, stdout)
|
|
|
|
@@ -415,11 +410,11 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
|
|
|
|
require.Equal(t, 0, len(msg.GetSignatures()))
|
|
|
|
|
|
|
|
|
|
// Test --dry-run
|
|
|
|
|
success, _, _ = f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewInt64Coin(denom, 5), "--dry-run")
|
|
|
|
|
success, _, _ = f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens), "--dry-run")
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
|
|
|
|
|
// Create the proposal
|
|
|
|
|
f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewInt64Coin(denom, 5))
|
|
|
|
|
f.TxGovSubmitProposal(keyFoo, "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens))
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
// Ensure transaction tags can be queried
|
|
|
|
@@ -428,7 +423,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Ensure deposit was deducted
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(45), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens.Sub(proposalTokens), fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Ensure propsal is directly queryable
|
|
|
|
|
proposal1 := f.QueryGovProposal(1)
|
|
|
|
@@ -441,10 +436,11 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Query the deposits on the proposal
|
|
|
|
|
deposit := f.QueryGovDeposit(1, fooAddr)
|
|
|
|
|
require.Equal(t, int64(5), deposit.Amount.AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, proposalTokens, deposit.Amount.AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Test deposit generate only
|
|
|
|
|
success, stdout, stderr = f.TxGovDeposit(1, keyFoo, sdk.NewInt64Coin(denom, 10), "--generate-only")
|
|
|
|
|
depositTokens := staking.TokensFromTendermintPower(10)
|
|
|
|
|
success, stdout, stderr = f.TxGovDeposit(1, keyFoo, sdk.NewCoin(denom, depositTokens), "--generate-only")
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
require.Empty(t, stderr)
|
|
|
|
|
msg = unmarshalStdTx(t, stdout)
|
|
|
|
@@ -453,17 +449,17 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
|
|
|
|
require.Equal(t, 0, len(msg.GetSignatures()))
|
|
|
|
|
|
|
|
|
|
// Run the deposit transaction
|
|
|
|
|
f.TxGovDeposit(1, keyFoo, sdk.NewInt64Coin(denom, 10))
|
|
|
|
|
f.TxGovDeposit(1, keyFoo, sdk.NewCoin(denom, depositTokens))
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
// test query deposit
|
|
|
|
|
deposits := f.QueryGovDeposits(1)
|
|
|
|
|
require.Len(t, deposits, 1)
|
|
|
|
|
require.Equal(t, int64(15), deposits[0].Amount.AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, proposalTokens.Add(depositTokens), deposits[0].Amount.AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Ensure querying the deposit returns the proper amount
|
|
|
|
|
deposit = f.QueryGovDeposit(1, fooAddr)
|
|
|
|
|
require.Equal(t, int64(15), deposit.Amount.AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, proposalTokens.Add(depositTokens), deposit.Amount.AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Ensure tags are set on the transaction
|
|
|
|
|
txs = f.QueryTxs(1, 50, "action:deposit", fmt.Sprintf("depositor:%s", fooAddr))
|
|
|
|
@@ -471,7 +467,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Ensure account has expected amount of funds
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(35), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, startTokens.Sub(proposalTokens.Add(depositTokens)), fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Fetch the proposal and ensure it is now in the voting period
|
|
|
|
|
proposal1 = f.QueryGovProposal(1)
|
|
|
|
@@ -515,7 +511,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
|
|
|
|
|
require.Equal(t, uint64(1), proposalsQuery[0].GetProposalID())
|
|
|
|
|
|
|
|
|
|
// submit a second test proposal
|
|
|
|
|
f.TxGovSubmitProposal(keyFoo, "Text", "Apples", "test", sdk.NewInt64Coin(denom, 5))
|
|
|
|
|
f.TxGovSubmitProposal(keyFoo, "Text", "Apples", "test", sdk.NewCoin(denom, proposalTokens))
|
|
|
|
|
tests.WaitForNextNBlocksTM(1, f.Port)
|
|
|
|
|
|
|
|
|
|
// Test limit on proposals query
|
|
|
|
@@ -635,7 +631,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
|
|
|
|
|
barAddr := f.KeyAddress(keyBar)
|
|
|
|
|
|
|
|
|
|
// Test generate sendTx with default gas
|
|
|
|
|
success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--generate-only")
|
|
|
|
|
sendTokens := staking.TokensFromTendermintPower(10)
|
|
|
|
|
success, stdout, stderr := f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--generate-only")
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
require.Empty(t, stderr)
|
|
|
|
|
msg := unmarshalStdTx(t, stdout)
|
|
|
|
@@ -644,7 +641,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
|
|
|
|
|
require.Equal(t, 0, len(msg.GetSignatures()))
|
|
|
|
|
|
|
|
|
|
// Test generate sendTx with --gas=$amount
|
|
|
|
|
success, stdout, stderr = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=100", "--generate-only")
|
|
|
|
|
success, stdout, stderr = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=100", "--generate-only")
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
require.Empty(t, stderr)
|
|
|
|
|
msg = unmarshalStdTx(t, stdout)
|
|
|
|
@@ -653,7 +650,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
|
|
|
|
|
require.Equal(t, 0, len(msg.GetSignatures()))
|
|
|
|
|
|
|
|
|
|
// Test generate sendTx, estimate gas
|
|
|
|
|
success, stdout, stderr = f.TxSend(keyFoo, barAddr, sdk.NewInt64Coin(denom, 10), "--gas=auto", "--generate-only")
|
|
|
|
|
success, stdout, stderr = f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "--gas=auto", "--generate-only")
|
|
|
|
|
require.True(t, success)
|
|
|
|
|
require.NotEmpty(t, stderr)
|
|
|
|
|
msg = unmarshalStdTx(t, stdout)
|
|
|
|
@@ -689,7 +686,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
// Ensure foo has right amount of funds
|
|
|
|
|
fooAcc := f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(50), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
startTokens := staking.TokensFromTendermintPower(50)
|
|
|
|
|
require.Equal(t, startTokens, fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
// Test broadcast
|
|
|
|
|
success, stdout, _ = f.TxBroadcast(signedTxFile.Name())
|
|
|
|
@@ -706,8 +704,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
|
|
|
|
|
// Ensure account state
|
|
|
|
|
barAcc := f.QueryAccount(barAddr)
|
|
|
|
|
fooAcc = f.QueryAccount(fooAddr)
|
|
|
|
|
require.Equal(t, int64(10), barAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, int64(40), fooAcc.GetCoins().AmountOf(denom).Int64())
|
|
|
|
|
require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
require.Equal(t, startTokens.Sub(sendTokens), fooAcc.GetCoins().AmountOf(denom))
|
|
|
|
|
|
|
|
|
|
f.Cleanup()
|
|
|
|
|
}
|
|
|
|
|