Merge PR #3818: Introduce sdk.NewCoins
This commit is contained in:
parent
a24dee0155
commit
fbd79d0cad
|
@ -26,6 +26,9 @@
|
||||||
|
|
||||||
### SDK
|
### SDK
|
||||||
|
|
||||||
|
* [\3813](https://github.com/cosmos/cosmos-sdk/pull/3813) New sdk.NewCoins safe constructor to replace bare
|
||||||
|
sdk.Coins{} declarations.
|
||||||
|
|
||||||
### Tendermint
|
### Tendermint
|
||||||
|
|
||||||
<!------------------------------- IMPROVEMENTS ------------------------------->
|
<!------------------------------- IMPROVEMENTS ------------------------------->
|
||||||
|
|
|
@ -41,7 +41,7 @@ func makeGenesisState(t *testing.T, genTxs []auth.StdTx) GenesisState {
|
||||||
msg := msgs[0].(staking.MsgCreateValidator)
|
msg := msgs[0].(staking.MsgCreateValidator)
|
||||||
|
|
||||||
acc := auth.NewBaseAccountWithAddress(sdk.AccAddress(msg.ValidatorAddress))
|
acc := auth.NewBaseAccountWithAddress(sdk.AccAddress(msg.ValidatorAddress))
|
||||||
acc.Coins = sdk.Coins{sdk.NewInt64Coin(defaultBondDenom, 150)}
|
acc.Coins = sdk.NewCoins(sdk.NewInt64Coin(defaultBondDenom, 150))
|
||||||
genAccs[i] = NewGenesisAccount(&acc)
|
genAccs[i] = NewGenesisAccount(&acc)
|
||||||
stakingData.Pool.NotBondedTokens = stakingData.Pool.NotBondedTokens.Add(sdk.NewInt(150)) // increase the supply
|
stakingData.Pool.NotBondedTokens = stakingData.Pool.NotBondedTokens.Add(sdk.NewInt(150)) // increase the supply
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func TestToAccount(t *testing.T) {
|
||||||
priv := ed25519.GenPrivKey()
|
priv := ed25519.GenPrivKey()
|
||||||
addr := sdk.AccAddress(priv.PubKey().Address())
|
addr := sdk.AccAddress(priv.PubKey().Address())
|
||||||
authAcc := auth.NewBaseAccountWithAddress(addr)
|
authAcc := auth.NewBaseAccountWithAddress(addr)
|
||||||
authAcc.SetCoins(sdk.Coins{sdk.NewInt64Coin(defaultBondDenom, 150)})
|
authAcc.SetCoins(sdk.NewCoins(sdk.NewInt64Coin(defaultBondDenom, 150)))
|
||||||
genAcc := NewGenesisAccount(&authAcc)
|
genAcc := NewGenesisAccount(&authAcc)
|
||||||
acc := genAcc.ToAccount()
|
acc := genAcc.ToAccount()
|
||||||
require.IsType(t, &auth.BaseAccount{}, acc)
|
require.IsType(t, &auth.BaseAccount{}, acc)
|
||||||
|
|
|
@ -32,8 +32,8 @@ func TestAddGenesisAccount(t *testing.T) {
|
||||||
args{
|
args{
|
||||||
app.GenesisState{},
|
app.GenesisState{},
|
||||||
addr1,
|
addr1,
|
||||||
sdk.Coins{},
|
sdk.NewCoins(),
|
||||||
sdk.Coins{},
|
sdk.NewCoins(),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
@ -44,8 +44,8 @@ func TestAddGenesisAccount(t *testing.T) {
|
||||||
args{
|
args{
|
||||||
app.GenesisState{Accounts: []app.GenesisAccount{{Address: addr1}}},
|
app.GenesisState{Accounts: []app.GenesisAccount{{Address: addr1}}},
|
||||||
addr1,
|
addr1,
|
||||||
sdk.Coins{},
|
sdk.NewCoins(),
|
||||||
sdk.Coins{},
|
sdk.NewCoins(),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
@ -56,8 +56,8 @@ func TestAddGenesisAccount(t *testing.T) {
|
||||||
args{
|
args{
|
||||||
app.GenesisState{},
|
app.GenesisState{},
|
||||||
addr1,
|
addr1,
|
||||||
sdk.Coins{sdk.NewInt64Coin("stake", 50)},
|
sdk.NewCoins(sdk.NewInt64Coin("stake", 50)),
|
||||||
sdk.Coins{sdk.NewInt64Coin("stake", 100)},
|
sdk.NewCoins(sdk.NewInt64Coin("stake", 100)),
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
@ -68,8 +68,8 @@ func TestAddGenesisAccount(t *testing.T) {
|
||||||
args{
|
args{
|
||||||
app.GenesisState{},
|
app.GenesisState{},
|
||||||
addr1,
|
addr1,
|
||||||
sdk.Coins{sdk.NewInt64Coin("stake", 50)},
|
sdk.NewCoins(sdk.NewInt64Coin("stake", 50)),
|
||||||
sdk.Coins{sdk.NewInt64Coin("stake", 50)},
|
sdk.NewCoins(sdk.NewInt64Coin("stake", 50)),
|
||||||
1654668078,
|
1654668078,
|
||||||
1554668078,
|
1554668078,
|
||||||
},
|
},
|
||||||
|
|
|
@ -130,6 +130,28 @@ func (coin Coin) IsNegative() bool {
|
||||||
// Coins is a set of Coin, one per currency
|
// Coins is a set of Coin, one per currency
|
||||||
type Coins []Coin
|
type Coins []Coin
|
||||||
|
|
||||||
|
// NewCoins constructs a new coin set.
|
||||||
|
func NewCoins(coins ...Coin) Coins {
|
||||||
|
// remove zeroes
|
||||||
|
newCoins := removeZeroCoins(Coins(coins))
|
||||||
|
if len(newCoins) == 0 {
|
||||||
|
return Coins{}
|
||||||
|
}
|
||||||
|
|
||||||
|
newCoins.Sort()
|
||||||
|
|
||||||
|
// detect duplicate Denoms
|
||||||
|
if dupIndex := findDup(newCoins); dupIndex != -1 {
|
||||||
|
panic(fmt.Errorf("find duplicate denom: %s", newCoins[dupIndex]))
|
||||||
|
}
|
||||||
|
|
||||||
|
if !newCoins.IsValid() {
|
||||||
|
panic(fmt.Errorf("invalid coin set: %s", newCoins))
|
||||||
|
}
|
||||||
|
|
||||||
|
return newCoins
|
||||||
|
}
|
||||||
|
|
||||||
func (coins Coins) String() string {
|
func (coins Coins) String() string {
|
||||||
if len(coins) == 0 {
|
if len(coins) == 0 {
|
||||||
return ""
|
return ""
|
||||||
|
@ -552,3 +574,19 @@ func ParseCoins(coinsStr string) (coins Coins, err error) {
|
||||||
|
|
||||||
return coins, nil
|
return coins, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// findDup works on the assumption that coins is sorted
|
||||||
|
func findDup(coins Coins) int {
|
||||||
|
if len(coins) <= 1 {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
prevDenom := coins[0]
|
||||||
|
for i := 1; i < len(coins); i++ {
|
||||||
|
if coins[i] == prevDenom {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
|
@ -519,3 +519,31 @@ func TestCoinsIsAnyGTE(t *testing.T) {
|
||||||
assert.True(t, Coins{{testDenom1, one}, {testDenom2, one}}.IsAnyGTE(Coins{{testDenom1, one}, {testDenom2, two}}))
|
assert.True(t, Coins{{testDenom1, one}, {testDenom2, one}}.IsAnyGTE(Coins{{testDenom1, one}, {testDenom2, two}}))
|
||||||
assert.True(t, Coins{{"xxx", one}, {"yyy", one}}.IsAnyGTE(Coins{{testDenom2, one}, {"ccc", one}, {"yyy", one}, {"zzz", one}}))
|
assert.True(t, Coins{{"xxx", one}, {"yyy", one}}.IsAnyGTE(Coins{{testDenom2, one}, {"ccc", one}, {"yyy", one}, {"zzz", one}}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewCoins(t *testing.T) {
|
||||||
|
tenatom := NewInt64Coin("atom", 10)
|
||||||
|
tenbtc := NewInt64Coin("btc", 10)
|
||||||
|
zeroeth := NewInt64Coin("eth", 0)
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
coins Coins
|
||||||
|
want Coins
|
||||||
|
wantPanic bool
|
||||||
|
}{
|
||||||
|
{"empty args", []Coin{}, Coins{}, false},
|
||||||
|
{"one coin", []Coin{tenatom}, Coins{tenatom}, false},
|
||||||
|
{"sort after create", []Coin{tenbtc, tenatom}, Coins{tenatom, tenbtc}, false},
|
||||||
|
{"sort and remove zeroes", []Coin{zeroeth, tenbtc, tenatom}, Coins{tenatom, tenbtc}, false},
|
||||||
|
{"panic on dups", []Coin{tenatom, tenatom}, Coins{}, true},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
if tt.wantPanic {
|
||||||
|
require.Panics(t, func() { NewCoins(tt.coins...) })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
got := NewCoins(tt.coins...)
|
||||||
|
require.True(t, got.IsEqual(tt.want))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -300,18 +300,18 @@ func TestAnteHandlerFees(t *testing.T) {
|
||||||
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
|
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
|
||||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInsufficientFunds)
|
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInsufficientFunds)
|
||||||
|
|
||||||
acc1.SetCoins(sdk.Coins{sdk.NewInt64Coin("atom", 149)})
|
acc1.SetCoins(sdk.NewCoins(sdk.NewInt64Coin("atom", 149)))
|
||||||
input.ak.SetAccount(ctx, acc1)
|
input.ak.SetAccount(ctx, acc1)
|
||||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInsufficientFunds)
|
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInsufficientFunds)
|
||||||
|
|
||||||
require.True(t, input.fck.GetCollectedFees(ctx).IsEqual(emptyCoins))
|
require.True(t, input.fck.GetCollectedFees(ctx).IsEqual(emptyCoins))
|
||||||
require.True(t, input.ak.GetAccount(ctx, addr1).GetCoins().AmountOf("atom").Equal(sdk.NewInt(149)))
|
require.True(t, input.ak.GetAccount(ctx, addr1).GetCoins().AmountOf("atom").Equal(sdk.NewInt(149)))
|
||||||
|
|
||||||
acc1.SetCoins(sdk.Coins{sdk.NewInt64Coin("atom", 150)})
|
acc1.SetCoins(sdk.NewCoins(sdk.NewInt64Coin("atom", 150)))
|
||||||
input.ak.SetAccount(ctx, acc1)
|
input.ak.SetAccount(ctx, acc1)
|
||||||
checkValidTx(t, anteHandler, ctx, tx, false)
|
checkValidTx(t, anteHandler, ctx, tx, false)
|
||||||
|
|
||||||
require.True(t, input.fck.GetCollectedFees(ctx).IsEqual(sdk.Coins{sdk.NewInt64Coin("atom", 150)}))
|
require.True(t, input.fck.GetCollectedFees(ctx).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("atom", 150))))
|
||||||
require.True(t, input.ak.GetAccount(ctx, addr1).GetCoins().AmountOf("atom").Equal(sdk.NewInt(0)))
|
require.True(t, input.ak.GetAccount(ctx, addr1).GetCoins().AmountOf("atom").Equal(sdk.NewInt(0)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,24 +333,24 @@ func TestAnteHandlerMemoGas(t *testing.T) {
|
||||||
var tx sdk.Tx
|
var tx sdk.Tx
|
||||||
msg := newTestMsg(addr1)
|
msg := newTestMsg(addr1)
|
||||||
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
|
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
|
||||||
fee := NewStdFee(0, sdk.Coins{sdk.NewInt64Coin("atom", 0)})
|
fee := NewStdFee(0, sdk.NewCoins(sdk.NewInt64Coin("atom", 0)))
|
||||||
|
|
||||||
// tx does not have enough gas
|
// tx does not have enough gas
|
||||||
tx = newTestTx(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee)
|
tx = newTestTx(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee)
|
||||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas)
|
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas)
|
||||||
|
|
||||||
// tx with memo doesn't have enough gas
|
// tx with memo doesn't have enough gas
|
||||||
fee = NewStdFee(801, sdk.Coins{sdk.NewInt64Coin("atom", 0)})
|
fee = NewStdFee(801, sdk.NewCoins(sdk.NewInt64Coin("atom", 0)))
|
||||||
tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, "abcininasidniandsinasindiansdiansdinaisndiasndiadninsd")
|
tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, "abcininasidniandsinasindiansdiansdinaisndiasndiadninsd")
|
||||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas)
|
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas)
|
||||||
|
|
||||||
// memo too large
|
// memo too large
|
||||||
fee = NewStdFee(9000, sdk.Coins{sdk.NewInt64Coin("atom", 0)})
|
fee = NewStdFee(9000, sdk.NewCoins(sdk.NewInt64Coin("atom", 0)))
|
||||||
tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("01234567890", 500))
|
tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("01234567890", 500))
|
||||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeMemoTooLarge)
|
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeMemoTooLarge)
|
||||||
|
|
||||||
// tx with memo has enough gas
|
// tx with memo has enough gas
|
||||||
fee = NewStdFee(9000, sdk.Coins{sdk.NewInt64Coin("atom", 0)})
|
fee = NewStdFee(9000, sdk.NewCoins(sdk.NewInt64Coin("atom", 0)))
|
||||||
tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("0123456789", 10))
|
tx = newTestTxWithMemo(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee, strings.Repeat("0123456789", 10))
|
||||||
checkValidTx(t, anteHandler, ctx, tx, false)
|
checkValidTx(t, anteHandler, ctx, tx, false)
|
||||||
}
|
}
|
||||||
|
@ -721,28 +721,28 @@ func TestEnsureSufficientMempoolFees(t *testing.T) {
|
||||||
input StdFee
|
input StdFee
|
||||||
expectedOK bool
|
expectedOK bool
|
||||||
}{
|
}{
|
||||||
{NewStdFee(200000, sdk.Coins{sdk.NewInt64Coin("photino", 5)}), false},
|
{NewStdFee(200000, sdk.NewCoins(sdk.NewInt64Coin("photino", 5))), false},
|
||||||
{NewStdFee(200000, sdk.Coins{sdk.NewInt64Coin("stake", 1)}), false},
|
{NewStdFee(200000, sdk.NewCoins(sdk.NewInt64Coin("stake", 1))), false},
|
||||||
{NewStdFee(200000, sdk.Coins{sdk.NewInt64Coin("stake", 2)}), true},
|
{NewStdFee(200000, sdk.NewCoins(sdk.NewInt64Coin("stake", 2))), true},
|
||||||
{NewStdFee(200000, sdk.Coins{sdk.NewInt64Coin("photino", 10)}), true},
|
{NewStdFee(200000, sdk.NewCoins(sdk.NewInt64Coin("photino", 10))), true},
|
||||||
{
|
{
|
||||||
NewStdFee(
|
NewStdFee(
|
||||||
200000,
|
200000,
|
||||||
sdk.Coins{
|
sdk.NewCoins(
|
||||||
sdk.NewInt64Coin("photino", 10),
|
sdk.NewInt64Coin("photino", 10),
|
||||||
sdk.NewInt64Coin("stake", 2),
|
sdk.NewInt64Coin("stake", 2),
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
NewStdFee(
|
NewStdFee(
|
||||||
200000,
|
200000,
|
||||||
sdk.Coins{
|
sdk.NewCoins(
|
||||||
sdk.NewInt64Coin("atom", 5),
|
sdk.NewInt64Coin("atom", 5),
|
||||||
sdk.NewInt64Coin("photino", 10),
|
sdk.NewInt64Coin("photino", 10),
|
||||||
sdk.NewInt64Coin("stake", 2),
|
sdk.NewInt64Coin("stake", 2),
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -33,10 +33,11 @@ func (fck FeeCollectionKeeper) GetCollectedFees(ctx sdk.Context) sdk.Coins {
|
||||||
store := ctx.KVStore(fck.key)
|
store := ctx.KVStore(fck.key)
|
||||||
bz := store.Get(collectedFeesKey)
|
bz := store.Get(collectedFeesKey)
|
||||||
if bz == nil {
|
if bz == nil {
|
||||||
return sdk.Coins{}
|
return sdk.NewCoins()
|
||||||
}
|
}
|
||||||
|
|
||||||
feePool := &(sdk.Coins{})
|
emptyFees := sdk.NewCoins()
|
||||||
|
feePool := &emptyFees
|
||||||
fck.cdc.MustUnmarshalBinaryLengthPrefixed(bz, feePool)
|
fck.cdc.MustUnmarshalBinaryLengthPrefixed(bz, feePool)
|
||||||
return *feePool
|
return *feePool
|
||||||
}
|
}
|
||||||
|
@ -57,5 +58,5 @@ func (fck FeeCollectionKeeper) AddCollectedFees(ctx sdk.Context, coins sdk.Coins
|
||||||
|
|
||||||
// ClearCollectedFees - clear the fee pool
|
// ClearCollectedFees - clear the fee pool
|
||||||
func (fck FeeCollectionKeeper) ClearCollectedFees(ctx sdk.Context) {
|
func (fck FeeCollectionKeeper) ClearCollectedFees(ctx sdk.Context) {
|
||||||
fck.setCollectedFees(ctx, sdk.Coins{})
|
fck.setCollectedFees(ctx, sdk.NewCoins())
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
emptyCoins = sdk.Coins{}
|
emptyCoins = sdk.NewCoins()
|
||||||
oneCoin = sdk.Coins{sdk.NewInt64Coin("foocoin", 1)}
|
oneCoin = sdk.NewCoins(sdk.NewInt64Coin("foocoin", 1))
|
||||||
twoCoins = sdk.Coins{sdk.NewInt64Coin("foocoin", 2)}
|
twoCoins = sdk.NewCoins(sdk.NewInt64Coin("foocoin", 2))
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFeeCollectionKeeperGetSet(t *testing.T) {
|
func TestFeeCollectionKeeperGetSet(t *testing.T) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ func NewGenesisState(collectedFees sdk.Coins, params Params) GenesisState {
|
||||||
|
|
||||||
// DefaultGenesisState - Return a default genesis state
|
// DefaultGenesisState - Return a default genesis state
|
||||||
func DefaultGenesisState() GenesisState {
|
func DefaultGenesisState() GenesisState {
|
||||||
return NewGenesisState(sdk.Coins{}, DefaultParams())
|
return NewGenesisState(sdk.NewCoins(), DefaultParams())
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitGenesis - Init store state from genesis data
|
// InitGenesis - Init store state from genesis data
|
||||||
|
|
|
@ -141,7 +141,7 @@ func (fee StdFee) Bytes() []byte {
|
||||||
// (in the lcd_test, client side its null,
|
// (in the lcd_test, client side its null,
|
||||||
// server side its [])
|
// server side its [])
|
||||||
if len(fee.Amount) == 0 {
|
if len(fee.Amount) == 0 {
|
||||||
fee.Amount = sdk.Coins{}
|
fee.Amount = sdk.NewCoins()
|
||||||
}
|
}
|
||||||
bz, err := msgCdc.MarshalJSON(fee) // TODO
|
bz, err := msgCdc.MarshalJSON(fee) // TODO
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -55,7 +55,7 @@ func newTestMsg(addrs ...sdk.AccAddress) *sdk.TestMsg {
|
||||||
|
|
||||||
func newStdFee() StdFee {
|
func newStdFee() StdFee {
|
||||||
return NewStdFee(50000,
|
return NewStdFee(50000,
|
||||||
sdk.Coins{sdk.NewInt64Coin("atom", 150)},
|
sdk.NewCoins(sdk.NewInt64Coin("atom", 150)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ func (keeper BaseViewKeeper) Codespace() sdk.CodespaceType {
|
||||||
func getCoins(ctx sdk.Context, am auth.AccountKeeper, addr sdk.AccAddress) sdk.Coins {
|
func getCoins(ctx sdk.Context, am auth.AccountKeeper, addr sdk.AccAddress) sdk.Coins {
|
||||||
acc := am.GetAccount(ctx, addr)
|
acc := am.GetAccount(ctx, addr)
|
||||||
if acc == nil {
|
if acc == nil {
|
||||||
return sdk.Coins{}
|
return sdk.NewCoins()
|
||||||
}
|
}
|
||||||
return acc.GetCoins()
|
return acc.GetCoins()
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ func subtractCoins(ctx sdk.Context, ak auth.AccountKeeper, addr sdk.AccAddress,
|
||||||
return nil, nil, sdk.ErrInvalidCoins(amt.String())
|
return nil, nil, sdk.ErrInvalidCoins(amt.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
oldCoins, spendableCoins := sdk.Coins{}, sdk.Coins{}
|
oldCoins, spendableCoins := sdk.NewCoins(), sdk.NewCoins()
|
||||||
|
|
||||||
acc := getAccount(ctx, ak, addr)
|
acc := getAccount(ctx, ak, addr)
|
||||||
if acc != nil {
|
if acc != nil {
|
||||||
|
|
|
@ -66,71 +66,71 @@ func TestKeeper(t *testing.T) {
|
||||||
|
|
||||||
// Test GetCoins/SetCoins
|
// Test GetCoins/SetCoins
|
||||||
input.ak.SetAccount(ctx, acc)
|
input.ak.SetAccount(ctx, acc)
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins()))
|
||||||
|
|
||||||
bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
bankKeeper.SetCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10)))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
|
|
||||||
// Test HasCoins
|
// Test HasCoins
|
||||||
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15))))
|
||||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 5))))
|
||||||
|
|
||||||
// Test AddCoins
|
// Test AddCoins
|
||||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
|
bankKeeper.AddCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15)))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 25)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 25))))
|
||||||
|
|
||||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 15)})
|
bankKeeper.AddCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 15)))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 15), sdk.NewInt64Coin("foocoin", 25)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 15), sdk.NewInt64Coin("foocoin", 25))))
|
||||||
|
|
||||||
// Test SubtractCoins
|
// Test SubtractCoins
|
||||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
bankKeeper.SubtractCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10)))
|
||||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)})
|
bankKeeper.SubtractCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 5)))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15))))
|
||||||
|
|
||||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 11)})
|
bankKeeper.SubtractCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 11)))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15))))
|
||||||
|
|
||||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 10)})
|
bankKeeper.SubtractCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10)))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15))))
|
||||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}))
|
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 1))))
|
||||||
|
|
||||||
// Test SendCoins
|
// Test SendCoins
|
||||||
bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
|
bankKeeper.SendCoins(ctx, addr, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5)))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||||
|
|
||||||
_, err2 := bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 50)})
|
_, err2 := bankKeeper.SendCoins(ctx, addr, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 50)))
|
||||||
require.Implements(t, (*sdk.Error)(nil), err2)
|
require.Implements(t, (*sdk.Error)(nil), err2)
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||||
|
|
||||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
|
bankKeeper.AddCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 30)))
|
||||||
bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)})
|
bankKeeper.SendCoins(ctx, addr, addr2, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5))))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10))))
|
||||||
|
|
||||||
// Test InputOutputCoins
|
// Test InputOutputCoins
|
||||||
input1 := NewInput(addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)})
|
input1 := NewInput(addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 2)))
|
||||||
output1 := NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)})
|
output1 := NewOutput(addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 2)))
|
||||||
bankKeeper.InputOutputCoins(ctx, []Input{input1}, []Output{output1})
|
bankKeeper.InputOutputCoins(ctx, []Input{input1}, []Output{output1})
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 7)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 7))))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 8)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 8))))
|
||||||
|
|
||||||
inputs := []Input{
|
inputs := []Input{
|
||||||
NewInput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 3)}),
|
NewInput(addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 3))),
|
||||||
NewInput(addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 3), sdk.NewInt64Coin("foocoin", 2)}),
|
NewInput(addr2, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 3), sdk.NewInt64Coin("foocoin", 2))),
|
||||||
}
|
}
|
||||||
|
|
||||||
outputs := []Output{
|
outputs := []Output{
|
||||||
NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}),
|
NewOutput(addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 1))),
|
||||||
NewOutput(addr3, sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}),
|
NewOutput(addr3, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5))),
|
||||||
}
|
}
|
||||||
bankKeeper.InputOutputCoins(ctx, inputs, outputs)
|
bankKeeper.InputOutputCoins(ctx, inputs, outputs)
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 21), sdk.NewInt64Coin("foocoin", 4)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 21), sdk.NewInt64Coin("foocoin", 4))))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 7), sdk.NewInt64Coin("foocoin", 6)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 7), sdk.NewInt64Coin("foocoin", 6))))
|
||||||
require.True(t, bankKeeper.GetCoins(ctx, addr3).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, bankKeeper.GetCoins(ctx, addr3).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5))))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSendKeeper(t *testing.T) {
|
func TestSendKeeper(t *testing.T) {
|
||||||
|
@ -147,33 +147,33 @@ func TestSendKeeper(t *testing.T) {
|
||||||
|
|
||||||
// Test GetCoins/SetCoins
|
// Test GetCoins/SetCoins
|
||||||
input.ak.SetAccount(ctx, acc)
|
input.ak.SetAccount(ctx, acc)
|
||||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
|
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins()))
|
||||||
|
|
||||||
bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
bankKeeper.SetCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10)))
|
||||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
|
|
||||||
// Test HasCoins
|
// Test HasCoins
|
||||||
require.True(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, sendKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
require.True(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, sendKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||||
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15))))
|
||||||
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 5))))
|
||||||
|
|
||||||
bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
|
bankKeeper.SetCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15)))
|
||||||
|
|
||||||
// Test SendCoins
|
// Test SendCoins
|
||||||
sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
|
sendKeeper.SendCoins(ctx, addr, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5)))
|
||||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||||
|
|
||||||
_, err := sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 50)})
|
_, err := sendKeeper.SendCoins(ctx, addr, addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 50)))
|
||||||
require.Implements(t, (*sdk.Error)(nil), err)
|
require.Implements(t, (*sdk.Error)(nil), err)
|
||||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||||
|
|
||||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
|
bankKeeper.AddCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 30)))
|
||||||
sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)})
|
sendKeeper.SendCoins(ctx, addr, addr2, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 5)))
|
||||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 20), sdk.NewInt64Coin("foocoin", 5))))
|
||||||
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10))))
|
||||||
|
|
||||||
// validate coins with invalid denoms or negative values cannot be sent
|
// validate coins with invalid denoms or negative values cannot be sent
|
||||||
// NOTE: We must use the Coin literal as the constructor does not allow
|
// NOTE: We must use the Coin literal as the constructor does not allow
|
||||||
|
@ -195,16 +195,16 @@ func TestViewKeeper(t *testing.T) {
|
||||||
|
|
||||||
// Test GetCoins/SetCoins
|
// Test GetCoins/SetCoins
|
||||||
input.ak.SetAccount(ctx, acc)
|
input.ak.SetAccount(ctx, acc)
|
||||||
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{}))
|
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins()))
|
||||||
|
|
||||||
bankKeeper.SetCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
bankKeeper.SetCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10)))
|
||||||
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
|
|
||||||
// Test HasCoins
|
// Test HasCoins
|
||||||
require.True(t, viewKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
require.True(t, viewKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||||
require.True(t, viewKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
require.True(t, viewKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||||
require.False(t, viewKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
require.False(t, viewKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15))))
|
||||||
require.False(t, viewKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
require.False(t, viewKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 5))))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVestingAccountSend(t *testing.T) {
|
func TestVestingAccountSend(t *testing.T) {
|
||||||
|
@ -213,8 +213,8 @@ func TestVestingAccountSend(t *testing.T) {
|
||||||
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
||||||
endTime := now.Add(24 * time.Hour)
|
endTime := now.Add(24 * time.Hour)
|
||||||
|
|
||||||
origCoins := sdk.Coins{sdk.NewInt64Coin("steak", 100)}
|
origCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100))
|
||||||
sendCoins := sdk.Coins{sdk.NewInt64Coin("steak", 50)}
|
sendCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 50))
|
||||||
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
||||||
bankKeeper.SetSendEnabled(ctx, true)
|
bankKeeper.SetSendEnabled(ctx, true)
|
||||||
|
|
||||||
|
@ -247,8 +247,8 @@ func TestVestingAccountReceive(t *testing.T) {
|
||||||
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
||||||
endTime := now.Add(24 * time.Hour)
|
endTime := now.Add(24 * time.Hour)
|
||||||
|
|
||||||
origCoins := sdk.Coins{sdk.NewInt64Coin("steak", 100)}
|
origCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100))
|
||||||
sendCoins := sdk.Coins{sdk.NewInt64Coin("steak", 50)}
|
sendCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 50))
|
||||||
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
||||||
bankKeeper.SetSendEnabled(ctx, true)
|
bankKeeper.SetSendEnabled(ctx, true)
|
||||||
|
|
||||||
|
@ -281,8 +281,8 @@ func TestDelegateCoins(t *testing.T) {
|
||||||
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
||||||
endTime := now.Add(24 * time.Hour)
|
endTime := now.Add(24 * time.Hour)
|
||||||
|
|
||||||
origCoins := sdk.Coins{sdk.NewInt64Coin("steak", 100)}
|
origCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100))
|
||||||
delCoins := sdk.Coins{sdk.NewInt64Coin("steak", 50)}
|
delCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 50))
|
||||||
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
||||||
bankKeeper.SetSendEnabled(ctx, true)
|
bankKeeper.SetSendEnabled(ctx, true)
|
||||||
|
|
||||||
|
@ -318,8 +318,8 @@ func TestUndelegateCoins(t *testing.T) {
|
||||||
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
||||||
endTime := now.Add(24 * time.Hour)
|
endTime := now.Add(24 * time.Hour)
|
||||||
|
|
||||||
origCoins := sdk.Coins{sdk.NewInt64Coin("steak", 100)}
|
origCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100))
|
||||||
delCoins := sdk.Coins{sdk.NewInt64Coin("steak", 50)}
|
delCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 50))
|
||||||
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
||||||
bankKeeper.SetSendEnabled(ctx, true)
|
bankKeeper.SetSendEnabled(ctx, true)
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
func TestMsgSendRoute(t *testing.T) {
|
func TestMsgSendRoute(t *testing.T) {
|
||||||
addr1 := sdk.AccAddress([]byte("from"))
|
addr1 := sdk.AccAddress([]byte("from"))
|
||||||
addr2 := sdk.AccAddress([]byte("to"))
|
addr2 := sdk.AccAddress([]byte("to"))
|
||||||
coins := sdk.Coins{sdk.NewInt64Coin("atom", 10)}
|
coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10))
|
||||||
var msg = NewMsgSend(addr1, addr2, coins)
|
var msg = NewMsgSend(addr1, addr2, coins)
|
||||||
|
|
||||||
require.Equal(t, msg.Route(), "bank")
|
require.Equal(t, msg.Route(), "bank")
|
||||||
|
@ -22,9 +22,9 @@ func TestMsgSendRoute(t *testing.T) {
|
||||||
func TestMsgSendValidation(t *testing.T) {
|
func TestMsgSendValidation(t *testing.T) {
|
||||||
addr1 := sdk.AccAddress([]byte("from"))
|
addr1 := sdk.AccAddress([]byte("from"))
|
||||||
addr2 := sdk.AccAddress([]byte("to"))
|
addr2 := sdk.AccAddress([]byte("to"))
|
||||||
atom123 := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
atom123 := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||||
atom0 := sdk.Coins{sdk.NewInt64Coin("atom", 0)}
|
atom0 := sdk.NewCoins(sdk.NewInt64Coin("atom", 0))
|
||||||
atom123eth123 := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 123)}
|
atom123eth123 := sdk.NewCoins(sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 123))
|
||||||
atom123eth0 := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 0)}
|
atom123eth0 := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 0)}
|
||||||
|
|
||||||
var emptyAddr sdk.AccAddress
|
var emptyAddr sdk.AccAddress
|
||||||
|
@ -41,12 +41,12 @@ func TestMsgSendValidation(t *testing.T) {
|
||||||
{false, NewMsgSend(addr1, emptyAddr, atom123)}, // empty to addr
|
{false, NewMsgSend(addr1, emptyAddr, atom123)}, // empty to addr
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tc := range cases {
|
for _, tc := range cases {
|
||||||
err := tc.tx.ValidateBasic()
|
err := tc.tx.ValidateBasic()
|
||||||
if tc.valid {
|
if tc.valid {
|
||||||
require.Nil(t, err, "%d: %+v", i, err)
|
require.Nil(t, err)
|
||||||
} else {
|
} else {
|
||||||
require.NotNil(t, err, "%d", i)
|
require.NotNil(t, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ func TestMsgSendValidation(t *testing.T) {
|
||||||
func TestMsgSendGetSignBytes(t *testing.T) {
|
func TestMsgSendGetSignBytes(t *testing.T) {
|
||||||
addr1 := sdk.AccAddress([]byte("input"))
|
addr1 := sdk.AccAddress([]byte("input"))
|
||||||
addr2 := sdk.AccAddress([]byte("output"))
|
addr2 := sdk.AccAddress([]byte("output"))
|
||||||
coins := sdk.Coins{sdk.NewInt64Coin("atom", 10)}
|
coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10))
|
||||||
var msg = NewMsgSend(addr1, addr2, coins)
|
var msg = NewMsgSend(addr1, addr2, coins)
|
||||||
res := msg.GetSignBytes()
|
res := msg.GetSignBytes()
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ func TestMsgSendGetSignBytes(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMsgSendGetSigners(t *testing.T) {
|
func TestMsgSendGetSigners(t *testing.T) {
|
||||||
var msg = NewMsgSend(sdk.AccAddress([]byte("input1")), sdk.AccAddress{}, sdk.Coins{})
|
var msg = NewMsgSend(sdk.AccAddress([]byte("input1")), sdk.AccAddress{}, sdk.NewCoins())
|
||||||
res := msg.GetSigners()
|
res := msg.GetSigners()
|
||||||
// TODO: fix this !
|
// TODO: fix this !
|
||||||
require.Equal(t, fmt.Sprintf("%v", res), "[696E70757431]")
|
require.Equal(t, fmt.Sprintf("%v", res), "[696E70757431]")
|
||||||
|
@ -73,7 +73,7 @@ func TestMsgMultiSendRoute(t *testing.T) {
|
||||||
// Construct a MsgSend
|
// Construct a MsgSend
|
||||||
addr1 := sdk.AccAddress([]byte("input"))
|
addr1 := sdk.AccAddress([]byte("input"))
|
||||||
addr2 := sdk.AccAddress([]byte("output"))
|
addr2 := sdk.AccAddress([]byte("output"))
|
||||||
coins := sdk.Coins{sdk.NewInt64Coin("atom", 10)}
|
coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10))
|
||||||
var msg = MsgMultiSend{
|
var msg = MsgMultiSend{
|
||||||
Inputs: []Input{NewInput(addr1, coins)},
|
Inputs: []Input{NewInput(addr1, coins)},
|
||||||
Outputs: []Output{NewOutput(addr2, coins)},
|
Outputs: []Output{NewOutput(addr2, coins)},
|
||||||
|
@ -87,12 +87,12 @@ func TestMsgMultiSendRoute(t *testing.T) {
|
||||||
func TestInputValidation(t *testing.T) {
|
func TestInputValidation(t *testing.T) {
|
||||||
addr1 := sdk.AccAddress([]byte{1, 2})
|
addr1 := sdk.AccAddress([]byte{1, 2})
|
||||||
addr2 := sdk.AccAddress([]byte{7, 8})
|
addr2 := sdk.AccAddress([]byte{7, 8})
|
||||||
someCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
someCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||||
multiCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 20)}
|
multiCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 20))
|
||||||
|
|
||||||
var emptyAddr sdk.AccAddress
|
var emptyAddr sdk.AccAddress
|
||||||
emptyCoins := sdk.Coins{}
|
emptyCoins := sdk.NewCoins()
|
||||||
emptyCoins2 := sdk.Coins{sdk.NewInt64Coin("eth", 0)}
|
emptyCoins2 := sdk.NewCoins(sdk.NewInt64Coin("eth", 0))
|
||||||
someEmptyCoins := sdk.Coins{sdk.NewInt64Coin("eth", 10), sdk.NewInt64Coin("atom", 0)}
|
someEmptyCoins := sdk.Coins{sdk.NewInt64Coin("eth", 10), sdk.NewInt64Coin("atom", 0)}
|
||||||
unsortedCoins := sdk.Coins{sdk.NewInt64Coin("eth", 1), sdk.NewInt64Coin("atom", 1)}
|
unsortedCoins := sdk.Coins{sdk.NewInt64Coin("eth", 1), sdk.NewInt64Coin("atom", 1)}
|
||||||
|
|
||||||
|
@ -125,12 +125,12 @@ func TestInputValidation(t *testing.T) {
|
||||||
func TestOutputValidation(t *testing.T) {
|
func TestOutputValidation(t *testing.T) {
|
||||||
addr1 := sdk.AccAddress([]byte{1, 2})
|
addr1 := sdk.AccAddress([]byte{1, 2})
|
||||||
addr2 := sdk.AccAddress([]byte{7, 8})
|
addr2 := sdk.AccAddress([]byte{7, 8})
|
||||||
someCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
someCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||||
multiCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 20)}
|
multiCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 20))
|
||||||
|
|
||||||
var emptyAddr sdk.AccAddress
|
var emptyAddr sdk.AccAddress
|
||||||
emptyCoins := sdk.Coins{}
|
emptyCoins := sdk.NewCoins()
|
||||||
emptyCoins2 := sdk.Coins{sdk.NewInt64Coin("eth", 0)}
|
emptyCoins2 := sdk.NewCoins(sdk.NewInt64Coin("eth", 0))
|
||||||
someEmptyCoins := sdk.Coins{sdk.NewInt64Coin("eth", 10), sdk.NewInt64Coin("atom", 0)}
|
someEmptyCoins := sdk.Coins{sdk.NewInt64Coin("eth", 10), sdk.NewInt64Coin("atom", 0)}
|
||||||
unsortedCoins := sdk.Coins{sdk.NewInt64Coin("eth", 1), sdk.NewInt64Coin("atom", 1)}
|
unsortedCoins := sdk.Coins{sdk.NewInt64Coin("eth", 1), sdk.NewInt64Coin("atom", 1)}
|
||||||
|
|
||||||
|
@ -163,10 +163,10 @@ func TestOutputValidation(t *testing.T) {
|
||||||
func TestMsgMultiSendValidation(t *testing.T) {
|
func TestMsgMultiSendValidation(t *testing.T) {
|
||||||
addr1 := sdk.AccAddress([]byte{1, 2})
|
addr1 := sdk.AccAddress([]byte{1, 2})
|
||||||
addr2 := sdk.AccAddress([]byte{7, 8})
|
addr2 := sdk.AccAddress([]byte{7, 8})
|
||||||
atom123 := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
atom123 := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||||
atom124 := sdk.Coins{sdk.NewInt64Coin("atom", 124)}
|
atom124 := sdk.NewCoins(sdk.NewInt64Coin("atom", 124))
|
||||||
eth123 := sdk.Coins{sdk.NewInt64Coin("eth", 123)}
|
eth123 := sdk.NewCoins(sdk.NewInt64Coin("eth", 123))
|
||||||
atom123eth123 := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 123)}
|
atom123eth123 := sdk.NewCoins(sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 123))
|
||||||
|
|
||||||
input1 := NewInput(addr1, atom123)
|
input1 := NewInput(addr1, atom123)
|
||||||
input2 := NewInput(addr1, eth123)
|
input2 := NewInput(addr1, eth123)
|
||||||
|
@ -217,7 +217,7 @@ func TestMsgMultiSendValidation(t *testing.T) {
|
||||||
func TestMsgMultiSendGetSignBytes(t *testing.T) {
|
func TestMsgMultiSendGetSignBytes(t *testing.T) {
|
||||||
addr1 := sdk.AccAddress([]byte("input"))
|
addr1 := sdk.AccAddress([]byte("input"))
|
||||||
addr2 := sdk.AccAddress([]byte("output"))
|
addr2 := sdk.AccAddress([]byte("output"))
|
||||||
coins := sdk.Coins{sdk.NewInt64Coin("atom", 10)}
|
coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10))
|
||||||
var msg = MsgMultiSend{
|
var msg = MsgMultiSend{
|
||||||
Inputs: []Input{NewInput(addr1, coins)},
|
Inputs: []Input{NewInput(addr1, coins)},
|
||||||
Outputs: []Output{NewOutput(addr2, coins)},
|
Outputs: []Output{NewOutput(addr2, coins)},
|
||||||
|
@ -250,7 +250,7 @@ func TestMsgSendSigners(t *testing.T) {
|
||||||
{7, 8, 9},
|
{7, 8, 9},
|
||||||
}
|
}
|
||||||
|
|
||||||
someCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
someCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||||
inputs := make([]Input, len(signers))
|
inputs := make([]Input, len(signers))
|
||||||
for i, signer := range signers {
|
for i, signer := range signers {
|
||||||
inputs[i] = NewInput(signer, someCoins)
|
inputs[i] = NewInput(signer, someCoins)
|
||||||
|
|
|
@ -28,7 +28,7 @@ func NonnegativeBalanceInvariant(ak auth.AccountKeeper) sdk.Invariant {
|
||||||
// is what is expected
|
// is what is expected
|
||||||
func TotalCoinsInvariant(ak auth.AccountKeeper, totalSupplyFn func() sdk.Coins) sdk.Invariant {
|
func TotalCoinsInvariant(ak auth.AccountKeeper, totalSupplyFn func() sdk.Coins) sdk.Invariant {
|
||||||
return func(ctx sdk.Context) error {
|
return func(ctx sdk.Context) error {
|
||||||
totalCoins := sdk.Coins{}
|
totalCoins := sdk.NewCoins()
|
||||||
|
|
||||||
chkAccount := func(acc auth.Account) bool {
|
chkAccount := func(acc auth.Account) bool {
|
||||||
coins := acc.GetCoins()
|
coins := acc.GetCoins()
|
||||||
|
|
|
@ -158,5 +158,5 @@ func (fck DummyFeeCollectionKeeper) SetCollectedFees(in sdk.Coins) {
|
||||||
heldFees = in
|
heldFees = in
|
||||||
}
|
}
|
||||||
func (fck DummyFeeCollectionKeeper) ClearCollectedFees(_ sdk.Context) {
|
func (fck DummyFeeCollectionKeeper) ClearCollectedFees(_ sdk.Context) {
|
||||||
heldFees = sdk.Coins{}
|
heldFees = sdk.NewCoins()
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ func (keeper Keeper) NewTextProposal(ctx sdk.Context, title string, description
|
||||||
ProposalType: proposalType,
|
ProposalType: proposalType,
|
||||||
Status: StatusDepositPeriod,
|
Status: StatusDepositPeriod,
|
||||||
FinalTallyResult: EmptyTallyResult(),
|
FinalTallyResult: EmptyTallyResult(),
|
||||||
TotalDeposit: sdk.Coins{},
|
TotalDeposit: sdk.NewCoins(),
|
||||||
SubmitTime: ctx.BlockHeader().Time,
|
SubmitTime: ctx.BlockHeader().Time,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,15 +69,15 @@ func TestDeposits(t *testing.T) {
|
||||||
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
|
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
|
||||||
proposalID := proposal.GetProposalID()
|
proposalID := proposal.GetProposalID()
|
||||||
|
|
||||||
fourSteak := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(4))}
|
fourSteak := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(4)))
|
||||||
fiveSteak := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(5))}
|
fiveSteak := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(5)))
|
||||||
|
|
||||||
addr0Initial := keeper.ck.GetCoins(ctx, addrs[0])
|
addr0Initial := keeper.ck.GetCoins(ctx, addrs[0])
|
||||||
addr1Initial := keeper.ck.GetCoins(ctx, addrs[1])
|
addr1Initial := keeper.ck.GetCoins(ctx, addrs[1])
|
||||||
|
|
||||||
expTokens := sdk.TokensFromTendermintPower(42)
|
expTokens := sdk.TokensFromTendermintPower(42)
|
||||||
require.Equal(t, sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, expTokens)}, addr0Initial)
|
require.Equal(t, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, expTokens)), addr0Initial)
|
||||||
require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.Coins{}))
|
require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.NewCoins()))
|
||||||
|
|
||||||
// Check no deposits at beginning
|
// Check no deposits at beginning
|
||||||
deposit, found := keeper.GetDeposit(ctx, proposalID, addrs[1])
|
deposit, found := keeper.GetDeposit(ctx, proposalID, addrs[1])
|
||||||
|
|
|
@ -11,10 +11,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
coinsPos = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000)}
|
coinsPos = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000))
|
||||||
coinsZero = sdk.Coins{}
|
coinsZero = sdk.NewCoins()
|
||||||
coinsPosNotAtoms = sdk.Coins{sdk.NewInt64Coin("foo", 10000)}
|
coinsPosNotAtoms = sdk.NewCoins(sdk.NewInt64Coin("foo", 10000))
|
||||||
coinsMulti = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000), sdk.NewInt64Coin("foo", 10000)}
|
coinsMulti = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000), sdk.NewInt64Coin("foo", 10000))
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -23,7 +23,7 @@ func init() {
|
||||||
|
|
||||||
// test ValidateBasic for MsgCreateValidator
|
// test ValidateBasic for MsgCreateValidator
|
||||||
func TestMsgSubmitProposal(t *testing.T) {
|
func TestMsgSubmitProposal(t *testing.T) {
|
||||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.NewCoins())
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
title, description string
|
title, description string
|
||||||
proposalType ProposalKind
|
proposalType ProposalKind
|
||||||
|
@ -65,7 +65,7 @@ func TestMsgDepositGetSignBytes(t *testing.T) {
|
||||||
|
|
||||||
// test ValidateBasic for MsgDeposit
|
// test ValidateBasic for MsgDeposit
|
||||||
func TestMsgDeposit(t *testing.T) {
|
func TestMsgDeposit(t *testing.T) {
|
||||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.NewCoins())
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
proposalID uint64
|
proposalID uint64
|
||||||
depositorAddr sdk.AccAddress
|
depositorAddr sdk.AccAddress
|
||||||
|
@ -90,7 +90,7 @@ func TestMsgDeposit(t *testing.T) {
|
||||||
|
|
||||||
// test ValidateBasic for MsgDeposit
|
// test ValidateBasic for MsgDeposit
|
||||||
func TestMsgVote(t *testing.T) {
|
func TestMsgVote(t *testing.T) {
|
||||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.NewCoins())
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
proposalID uint64
|
proposalID uint64
|
||||||
voterAddr sdk.AccAddress
|
voterAddr sdk.AccAddress
|
||||||
|
|
|
@ -62,7 +62,7 @@ func NewApp() *App {
|
||||||
KeyFeeCollection: sdk.NewKVStoreKey("fee"),
|
KeyFeeCollection: sdk.NewKVStoreKey("fee"),
|
||||||
KeyParams: sdk.NewKVStoreKey("params"),
|
KeyParams: sdk.NewKVStoreKey("params"),
|
||||||
TKeyParams: sdk.NewTransientStoreKey("transient_params"),
|
TKeyParams: sdk.NewTransientStoreKey("transient_params"),
|
||||||
TotalCoinsSupply: sdk.Coins{},
|
TotalCoinsSupply: sdk.NewCoins(),
|
||||||
}
|
}
|
||||||
|
|
||||||
app.ParamsKeeper = params.NewKeeper(app.Cdc, app.KeyParams, app.TKeyParams)
|
app.ParamsKeeper = params.NewKeeper(app.Cdc, app.KeyParams, app.TKeyParams)
|
||||||
|
@ -213,7 +213,7 @@ func SetGenesis(app *App, accs []auth.Account) {
|
||||||
func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) auth.StdTx {
|
func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) auth.StdTx {
|
||||||
// Make the transaction free
|
// Make the transaction free
|
||||||
fee := auth.StdFee{
|
fee := auth.StdFee{
|
||||||
Amount: sdk.Coins{sdk.NewInt64Coin("foocoin", 0)},
|
Amount: sdk.NewCoins(sdk.NewInt64Coin("foocoin", 0)),
|
||||||
Gas: 100000,
|
Gas: 100000,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue