Merge branch 'develop' into sunny/coins-AllGT-test
This commit is contained in:
commit
714168f473
121
CHANGELOG.md
121
CHANGELOG.md
|
@ -1,5 +1,112 @@
|
|||
# Changelog
|
||||
|
||||
## 0.33.0
|
||||
|
||||
BREAKING CHANGES
|
||||
|
||||
* Gaia REST API
|
||||
* [\#3641](https://github.com/cosmos/cosmos-sdk/pull/3641) Remove the ability to use a Keybase from the REST API client:
|
||||
* `password` and `generate_only` have been removed from the `base_req` object
|
||||
* All txs that used to sign or use the Keybase now only generate the tx
|
||||
* `keys` routes completely removed
|
||||
* [\#3692](https://github.com/cosmos/cosmos-sdk/pull/3692) Update tx encoding and broadcasting endpoints:
|
||||
* Remove duplicate broadcasting endpoints in favor of POST @ `/txs`
|
||||
* The `Tx` field now accepts a `StdTx` and not raw tx bytes
|
||||
* Move encoding endpoint to `/txs/encode`
|
||||
|
||||
* Gaia
|
||||
* [\#3787](https://github.com/cosmos/cosmos-sdk/pull/3787) Fork the `x/bank` module into the Gaia application with only a
|
||||
modified message handler, where the modified message handler behaves the same as
|
||||
the standard `x/bank` message handler except for `MsgMultiSend` that must burn
|
||||
exactly 9 atoms and transfer 1 atom, and `MsgSend` is disabled.
|
||||
* [\#3789](https://github.com/cosmos/cosmos-sdk/pull/3789) Update validator creation flow:
|
||||
* Remove `NewMsgCreateValidatorOnBehalfOf` and corresponding business logic
|
||||
* Ensure the validator address equals the delegator address during
|
||||
`MsgCreateValidator#ValidateBasic`
|
||||
|
||||
* SDK
|
||||
* [\#3750](https://github.com/cosmos/cosmos-sdk/issues/3750) Track outstanding rewards per-validator instead of globally,
|
||||
and fix the main simulation issue, which was that slashes of
|
||||
re-delegations to a validator were not correctly accounted for
|
||||
in fee distribution when the redelegation in question had itself
|
||||
been slashed (from a fault committed by a different validator)
|
||||
in the same BeginBlock. Outstanding rewards are now available
|
||||
on a per-validator basis in REST.
|
||||
* [\#3669](https://github.com/cosmos/cosmos-sdk/pull/3669) Ensure consistency in message naming, codec registration, and JSON
|
||||
tags.
|
||||
* [\#3788](https://github.com/cosmos/cosmos-sdk/pull/3788) Change order of operations for greater accuracy when calculating delegation share token value
|
||||
* [\#3788](https://github.com/cosmos/cosmos-sdk/pull/3788) DecCoins.Cap -> DecCoins.Intersect
|
||||
* [\#3666](https://github.com/cosmos/cosmos-sdk/pull/3666) Improve coins denom validation.
|
||||
* [\#3751](https://github.com/cosmos/cosmos-sdk/pull/3751) Disable (temporarily) support for ED25519 account key pairs.
|
||||
|
||||
* Tendermint
|
||||
* [\#3804] Update to Tendermint `v0.31.0-dev0`
|
||||
|
||||
FEATURES
|
||||
|
||||
* SDK
|
||||
* [\#3719](https://github.com/cosmos/cosmos-sdk/issues/3719) DBBackend can now be set at compile time.
|
||||
Defaults: goleveldb. Supported: cleveldb.
|
||||
|
||||
IMPROVEMENTS
|
||||
|
||||
* Gaia REST API
|
||||
* Update the `TxResponse` type allowing for the `Logs` result to be JSON decoded automatically.
|
||||
|
||||
* Gaia CLI
|
||||
* [\#3653](https://github.com/cosmos/cosmos-sdk/pull/3653) Prompt user confirmation prior to signing and broadcasting a transaction.
|
||||
* [\#3670](https://github.com/cosmos/cosmos-sdk/pull/3670) CLI support for showing bech32 addresses in Ledger devices
|
||||
* [\#3711](https://github.com/cosmos/cosmos-sdk/pull/3711) Update `tx sign` to use `--from` instead of the deprecated `--name`
|
||||
CLI flag.
|
||||
* [\#3738](https://github.com/cosmos/cosmos-sdk/pull/3738) Improve multisig UX:
|
||||
* `gaiacli keys show -o json` now includes constituent pubkeys, respective weights and threshold
|
||||
* `gaiacli keys show --show-multisig` now displays constituent pubkeys, respective weights and threshold
|
||||
* `gaiacli tx sign --validate-signatures` now displays multisig signers with their respective weights
|
||||
* [\#3730](https://github.com/cosmos/cosmos-sdk/issues/3730) Improve workflow for
|
||||
`gaiad gentx` with offline public keys, by outputting stdtx file that needs to be signed.
|
||||
* [\#3761](https://github.com/cosmos/cosmos-sdk/issues/3761) Querying account related information using custom querier in auth module
|
||||
|
||||
* SDK
|
||||
* [\#3753](https://github.com/cosmos/cosmos-sdk/issues/3753) Remove no-longer-used governance penalty parameter
|
||||
* [\#3679](https://github.com/cosmos/cosmos-sdk/issues/3679) Consistent operators across Coins, DecCoins, Int, Dec
|
||||
replaced: Minus->Sub Plus->Add Div->Quo
|
||||
* [\#3665](https://github.com/cosmos/cosmos-sdk/pull/3665) Overhaul sdk.Uint type in preparation for Coins Int -> Uint migration.
|
||||
* [\#3691](https://github.com/cosmos/cosmos-sdk/issues/3691) Cleanup error messages
|
||||
* [\#3456](https://github.com/cosmos/cosmos-sdk/issues/3456) Integrate in the Int.ToDec() convenience function
|
||||
* [\#3300](https://github.com/cosmos/cosmos-sdk/pull/3300) Update the spec-spec, spec file reorg, and TOC updates.
|
||||
* [\#3694](https://github.com/cosmos/cosmos-sdk/pull/3694) Push tagged docker images on docker hub when tag is created.
|
||||
* [\#3716](https://github.com/cosmos/cosmos-sdk/pull/3716) Update file permissions the client keys directory and contents to `0700`.
|
||||
* [\#3681](https://github.com/cosmos/cosmos-sdk/issues/3681) Migrate ledger-cosmos-go from ZondaX to Cosmos organization
|
||||
|
||||
* Tendermint
|
||||
* [\#3699](https://github.com/cosmos/cosmos-sdk/pull/3699) Upgrade to Tendermint 0.30.1
|
||||
|
||||
BUG FIXES
|
||||
|
||||
* Gaia CLI
|
||||
* [\#3731](https://github.com/cosmos/cosmos-sdk/pull/3731) `keys add --interactive` bip32 passphrase regression fix
|
||||
* [\#3714](https://github.com/cosmos/cosmos-sdk/issues/3714) Fix USB raw access issues with gaiacli when installed via snap
|
||||
|
||||
* Gaia
|
||||
* [\#3777](https://github.com/cosmso/cosmos-sdk/pull/3777) `gaiad export` no longer panics when the database is empty
|
||||
* [\#3806](https://github.com/cosmos/cosmos-sdk/pull/3806) Properly return errors from a couple of struct Unmarshal functions
|
||||
|
||||
* SDK
|
||||
* [\#3728](https://github.com/cosmos/cosmos-sdk/issues/3728) Truncate decimal multiplication & division in distribution to ensure
|
||||
no more than the collected fees / inflation are distributed
|
||||
* [\#3727](https://github.com/cosmos/cosmos-sdk/issues/3727) Return on zero-length (including []byte{}) PrefixEndBytes() calls
|
||||
* [\#3559](https://github.com/cosmos/cosmos-sdk/issues/3559) fix occasional failing due to non-determinism in lcd test TestBonding
|
||||
where validator is unexpectedly slashed throwing off test calculations
|
||||
* [\#3411](https://github.com/cosmos/cosmos-sdk/pull/3411) Include the `RequestInitChain.Time` in the block header init during
|
||||
`InitChain`.
|
||||
* [\#3717](https://github.com/cosmos/cosmos-sdk/pull/3717) Update the vesting specification and implementation to cap deduction from
|
||||
`DelegatedVesting` by at most `DelegatedVesting`. This accounts for the case where
|
||||
the undelegation amount may exceed the original delegation amount due to
|
||||
truncation of undelegation tokens.
|
||||
* [\#3717](https://github.com/cosmos/cosmos-sdk/pull/3717) Ignore unknown proposers in allocating rewards for proposers, in case
|
||||
unbonding period was just 1 block and proposer was already deleted.
|
||||
* [\#3726](https://github.com/cosmos/cosmos-sdk/pull/3724) Cap(clip) reward to remaining coins in AllocateTokens.
|
||||
|
||||
## 0.32.0
|
||||
|
||||
BREAKING CHANGES
|
||||
|
@ -18,19 +125,19 @@ BREAKING CHANGES
|
|||
IMPROVEMENTS
|
||||
|
||||
* SDK
|
||||
* [\#3311] Reconcile the `DecCoin/s` API with the `Coin/s` API.
|
||||
* [\#3614] Add coin denom length checks to the coins constructors.
|
||||
* [\#3311](https://github.com/cosmos/cosmos-sdk/pull/3311) Reconcile the `DecCoin/s` API with the `Coin/s` API.
|
||||
* [\#3614](https://github.com/cosmos/cosmos-sdk/pull/3614) Add coin denom length checks to the coins constructors.
|
||||
* [\#3621](https://github.com/cosmos/cosmos-sdk/issues/3621) remove many inter-module dependancies
|
||||
* [\#3601] JSON-stringify the ABCI log response which includes the log and message
|
||||
* [\#3601](https://github.com/cosmos/cosmos-sdk/pull/3601) JSON-stringify the ABCI log response which includes the log and message
|
||||
index.
|
||||
* [\#3604] Improve SDK funds related error messages and allow for unicode in
|
||||
* [\#3604](https://github.com/cosmos/cosmos-sdk/pull/3604) Improve SDK funds related error messages and allow for unicode in
|
||||
JSON ABCI log.
|
||||
* [\#3620](https://github.com/cosmos/cosmos-sdk/pull/3620) Version command shows build tags
|
||||
* [\#3638] Add Bcrypt benchmarks & justification of security parameter choice
|
||||
* [\#3648] Add JSON struct tags to vesting accounts.
|
||||
* [\#3638](https://github.com/cosmos/cosmos-sdk/pull/3638) Add Bcrypt benchmarks & justification of security parameter choice
|
||||
* [\#3648](https://github.com/cosmos/cosmos-sdk/pull/3648) Add JSON struct tags to vesting accounts.
|
||||
|
||||
* Tendermint
|
||||
* [\#3618] Upgrade to Tendermint 0.30.03
|
||||
* [\#3618](https://github.com/cosmos/cosmos-sdk/pull/3618) Upgrade to Tendermint 0.30.03
|
||||
|
||||
BUG FIXES
|
||||
|
||||
|
|
4
Makefile
4
Makefile
|
@ -160,8 +160,8 @@ godocs:
|
|||
|
||||
test: test_unit
|
||||
|
||||
test_cli:
|
||||
@go test -p 4 `go list github.com/cosmos/cosmos-sdk/cmd/gaia/cli_test` -tags=cli_test
|
||||
test_cli: build
|
||||
@go test -p 4 `go list ./cmd/gaia/cli_test/...` -tags=cli_test
|
||||
|
||||
test_ledger:
|
||||
# First test with mock
|
||||
|
|
89
PENDING.md
89
PENDING.md
|
@ -6,48 +6,14 @@
|
|||
|
||||
### Gaia REST API
|
||||
|
||||
* [\#3641] Remove the ability to use a Keybase from the REST API client:
|
||||
* `password` and `generate_only` have been removed from the `base_req` object
|
||||
* All txs that used to sign or use the Keybase now only generate the tx
|
||||
* `keys` routes completely removed
|
||||
* [\#3692] Update tx encoding and broadcasting endpoints:
|
||||
* Remove duplicate broadcasting endpoints in favor of POST @ `/txs`
|
||||
* The `Tx` field now accepts a `StdTx` and not raw tx bytes
|
||||
* Move encoding endpoint to `/txs/encode`
|
||||
|
||||
### Gaia CLI
|
||||
|
||||
### Gaia
|
||||
|
||||
* [\#3787] Fork the `x/bank` module into the Gaia application with only a
|
||||
modified message handler, where the modified message handler behaves the same as
|
||||
the standard `x/bank` message handler except for `MsgMultiSend` that must burn
|
||||
exactly 9 atoms and transfer 1 atom, and `MsgSend` is disabled.
|
||||
* [\#3789] Update validator creation flow:
|
||||
* Remove `NewMsgCreateValidatorOnBehalfOf` and corresponding business logic
|
||||
* Ensure the validator address equals the delegator address during
|
||||
`MsgCreateValidator#ValidateBasic`
|
||||
|
||||
### SDK
|
||||
|
||||
* \#3750 Track outstanding rewards per-validator instead of globally,
|
||||
and fix the main simulation issue, which was that slashes of
|
||||
re-delegations to a validator were not correctly accounted for
|
||||
in fee distribution when the redelegation in question had itself
|
||||
been slashed (from a fault committed by a different validator)
|
||||
in the same BeginBlock. Outstanding rewards are now available
|
||||
on a per-validator basis in REST.
|
||||
* [\#3669] Ensure consistency in message naming, codec registration, and JSON
|
||||
tags.
|
||||
* #3788 Change order of operations for greater accuracy when calculating delegation share token value
|
||||
* #3788 DecCoins.Cap -> DecCoins.Intersect
|
||||
* [\#3666] Improve coins denom validation.
|
||||
* [\#3751] Disable (temporarily) support for ED25519 account key pairs.
|
||||
|
||||
### Tendermint
|
||||
|
||||
* [\#3804] Update to Tendermint `v0.31.0-dev0`
|
||||
|
||||
<!--------------------------------- FEATURES --------------------------------->
|
||||
|
||||
## FEATURES
|
||||
|
@ -60,8 +26,8 @@ tags.
|
|||
|
||||
### SDK
|
||||
|
||||
* [\#3719](https://github.com/cosmos/cosmos-sdk/issues/3719) DBBackend can now be set at compile time.
|
||||
Defaults: goleveldb. Supported: cleveldb.
|
||||
* [\3813](https://github.com/cosmos/cosmos-sdk/pull/3813) New sdk.NewCoins safe constructor to replace bare
|
||||
sdk.Coins{} declarations.
|
||||
|
||||
### Tendermint
|
||||
|
||||
|
@ -71,42 +37,16 @@ tags.
|
|||
|
||||
### Gaia REST API
|
||||
|
||||
* Update the `TxResponse` type allowing for the `Logs` result to be JSON
|
||||
decoded automatically.
|
||||
|
||||
### Gaia CLI
|
||||
|
||||
* [\#3653] Prompt user confirmation prior to signing and broadcasting a transaction.
|
||||
* [\#3670] CLI support for showing bech32 addresses in Ledger devices
|
||||
* [\#3711] Update `tx sign` to use `--from` instead of the deprecated `--name`
|
||||
CLI flag.
|
||||
* [\#3738] Improve multisig UX:
|
||||
* `gaiacli keys show -o json` now includes constituent pubkeys, respective weights and threshold
|
||||
* `gaiacli keys show --show-multisig` now displays constituent pubkeys, respective weights and threshold
|
||||
* `gaiacli tx sign --validate-signatures` now displays multisig signers with their respective weights
|
||||
* [\#3730](https://github.com/cosmos/cosmos-sdk/issues/3730) Improve workflow for
|
||||
`gaiad gentx` with offline public keys, by outputting stdtx file that needs to be signed.
|
||||
* [\#3761](https://github.com/cosmos/cosmos-sdk/issues/3761) Querying account related information using custom querier in auth module
|
||||
|
||||
### Gaia
|
||||
|
||||
* #3808 `gaiad` and `gaiacli` integration tests use ./build/ binaries.
|
||||
|
||||
### SDK
|
||||
|
||||
* \#3753 Remove no-longer-used governance penalty parameter
|
||||
* \#3679 Consistent operators across Coins, DecCoins, Int, Dec
|
||||
replaced: Minus->Sub Plus->Add Div->Quo
|
||||
* [\#3665] Overhaul sdk.Uint type in preparation for Coins Int -> Uint migration.
|
||||
* \#3691 Cleanup error messages
|
||||
* \#3456 Integrate in the Int.ToDec() convenience function
|
||||
* [\#3300] Update the spec-spec, spec file reorg, and TOC updates.
|
||||
* [\#3694] Push tagged docker images on docker hub when tag is created.
|
||||
* [\#3716] Update file permissions the client keys directory and contents to `0700`.
|
||||
* [\#3681](https://github.com/cosmos/cosmos-sdk/issues/3681) Migrate ledger-cosmos-go from ZondaX to Cosmos organization
|
||||
|
||||
### Tendermint
|
||||
|
||||
* [\#3699] Upgrade to Tendermint 0.30.1
|
||||
|
||||
<!--------------------------------- BUG FIXES -------------------------------->
|
||||
|
||||
## BUG FIXES
|
||||
|
@ -115,29 +55,8 @@ CLI flag.
|
|||
|
||||
### Gaia CLI
|
||||
|
||||
* [\#3731](https://github.com/cosmos/cosmos-sdk/pull/3731) `keys add --interactive` bip32 passphrase regression fix
|
||||
* [\#3714](https://github.com/cosmos/cosmos-sdk/issues/3714) Fix USB raw access issues with gaiacli when installed via snap
|
||||
|
||||
### Gaia
|
||||
|
||||
* [\#3777](https://github.com/cosmso/cosmos-sdk/pull/3777) `gaiad export` no longer panics when the database is empty
|
||||
* [\#3806](https://github.com/cosmos/cosmos-sdk/pull/3806) Properly return errors from a couple of struct Unmarshal functions
|
||||
|
||||
### SDK
|
||||
|
||||
* \#3728 Truncate decimal multiplication & division in distribution to ensure
|
||||
no more than the collected fees / inflation are distributed
|
||||
* \#3727 Return on zero-length (including []byte{}) PrefixEndBytes() calls
|
||||
* \#3559 fix occasional failing due to non-determinism in lcd test TestBonding
|
||||
where validator is unexpectedly slashed throwing off test calculations
|
||||
* [\#3411] Include the `RequestInitChain.Time` in the block header init during
|
||||
`InitChain`.
|
||||
* [\#3717] Update the vesting specification and implementation to cap deduction from
|
||||
`DelegatedVesting` by at most `DelegatedVesting`. This accounts for the case where
|
||||
the undelegation amount may exceed the original delegation amount due to
|
||||
truncation of undelegation tokens.
|
||||
* [\#3717] Ignore unknown proposers in allocating rewards for proposers, in case
|
||||
unbonding period was just 1 block and proposer was already deleted.
|
||||
* [\#3726] Cap(clip) reward to remaining coins in AllocateTokens.
|
||||
|
||||
### Tendermint
|
||||
|
|
|
@ -668,7 +668,7 @@ func doTransfer(
|
|||
resp, body, recvAddr := doTransferWithGas(
|
||||
t, port, seed, name, memo, pwd, addr, "", 1.0, false, true, fees,
|
||||
)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode, resp)
|
||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||
|
||||
var txResp sdk.TxResponse
|
||||
err := cdc.UnmarshalJSON([]byte(body), &txResp)
|
||||
|
|
|
@ -41,7 +41,7 @@ func makeGenesisState(t *testing.T, genTxs []auth.StdTx) GenesisState {
|
|||
msg := msgs[0].(staking.MsgCreateValidator)
|
||||
|
||||
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)
|
||||
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()
|
||||
addr := sdk.AccAddress(priv.PubKey().Address())
|
||||
authAcc := auth.NewBaseAccountWithAddress(addr)
|
||||
authAcc.SetCoins(sdk.Coins{sdk.NewInt64Coin(defaultBondDenom, 150)})
|
||||
authAcc.SetCoins(sdk.NewCoins(sdk.NewInt64Coin(defaultBondDenom, 150)))
|
||||
genAcc := NewGenesisAccount(&authAcc)
|
||||
acc := genAcc.ToAccount()
|
||||
require.IsType(t, &auth.BaseAccount{}, acc)
|
||||
|
|
|
@ -163,7 +163,7 @@ func (f *Fixtures) Flags() string {
|
|||
|
||||
// UnsafeResetAll is gaiad unsafe-reset-all
|
||||
func (f *Fixtures) UnsafeResetAll(flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiad --home=%s unsafe-reset-all", f.GDHome)
|
||||
cmd := fmt.Sprintf("../../../build/gaiad --home=%s unsafe-reset-all", f.GDHome)
|
||||
executeWrite(f.T, addFlags(cmd, flags))
|
||||
err := os.RemoveAll(filepath.Join(f.GDHome, "config", "gentx"))
|
||||
require.NoError(f.T, err)
|
||||
|
@ -172,7 +172,7 @@ func (f *Fixtures) UnsafeResetAll(flags ...string) {
|
|||
// GDInit is gaiad init
|
||||
// NOTE: GDInit sets the ChainID for the Fixtures instance
|
||||
func (f *Fixtures) GDInit(moniker string, flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiad init -o --home=%s %s", f.GDHome, moniker)
|
||||
cmd := fmt.Sprintf("../../../build/gaiad init -o --home=%s %s", f.GDHome, moniker)
|
||||
_, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
|
||||
var chainID string
|
||||
|
@ -189,25 +189,25 @@ func (f *Fixtures) GDInit(moniker string, flags ...string) {
|
|||
|
||||
// AddGenesisAccount is gaiad add-genesis-account
|
||||
func (f *Fixtures) AddGenesisAccount(address sdk.AccAddress, coins sdk.Coins, flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiad add-genesis-account %s %s --home=%s", address, coins, f.GDHome)
|
||||
cmd := fmt.Sprintf("../../../build/gaiad add-genesis-account %s %s --home=%s", address, coins, f.GDHome)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags))
|
||||
}
|
||||
|
||||
// GenTx is gaiad gentx
|
||||
func (f *Fixtures) GenTx(name string, flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiad gentx --name=%s --home=%s --home-client=%s", name, f.GDHome, f.GCLIHome)
|
||||
cmd := fmt.Sprintf("../../../build/gaiad gentx --name=%s --home=%s --home-client=%s", name, f.GDHome, f.GCLIHome)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
// CollectGenTxs is gaiad collect-gentxs
|
||||
func (f *Fixtures) CollectGenTxs(flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiad collect-gentxs --home=%s", f.GDHome)
|
||||
cmd := fmt.Sprintf("../../../build/gaiad collect-gentxs --home=%s", f.GDHome)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
// GDStart runs gaiad start with the appropriate flags and returns a process
|
||||
func (f *Fixtures) GDStart(flags ...string) *tests.Process {
|
||||
cmd := fmt.Sprintf("gaiad start --home=%s --rpc.laddr=%v --p2p.laddr=%v", f.GDHome, f.RPCAddr, f.P2PAddr)
|
||||
cmd := fmt.Sprintf("../../../build/gaiad start --home=%s --rpc.laddr=%v --p2p.laddr=%v", f.GDHome, f.RPCAddr, f.P2PAddr)
|
||||
proc := tests.GoExecuteTWithStdout(f.T, addFlags(cmd, flags))
|
||||
tests.WaitForTMStart(f.Port)
|
||||
tests.WaitForNextNBlocksTM(1, f.Port)
|
||||
|
@ -216,7 +216,7 @@ func (f *Fixtures) GDStart(flags ...string) *tests.Process {
|
|||
|
||||
// GDTendermint returns the results of gaiad tendermint [query]
|
||||
func (f *Fixtures) GDTendermint(query string) string {
|
||||
cmd := fmt.Sprintf("gaiad tendermint %s --home=%s", query, f.GDHome)
|
||||
cmd := fmt.Sprintf("../../../build/gaiad tendermint %s --home=%s", query, f.GDHome)
|
||||
success, stdout, stderr := executeWriteRetStdStreams(f.T, cmd)
|
||||
require.Empty(f.T, stderr)
|
||||
require.True(f.T, success)
|
||||
|
@ -225,7 +225,7 @@ func (f *Fixtures) GDTendermint(query string) string {
|
|||
|
||||
// ValidateGenesis runs gaiad validate-genesis
|
||||
func (f *Fixtures) ValidateGenesis() {
|
||||
cmd := fmt.Sprintf("gaiad validate-genesis --home=%s", f.GDHome)
|
||||
cmd := fmt.Sprintf("../../../build/gaiad validate-genesis --home=%s", f.GDHome)
|
||||
executeWriteCheckErr(f.T, cmd)
|
||||
}
|
||||
|
||||
|
@ -234,31 +234,31 @@ func (f *Fixtures) ValidateGenesis() {
|
|||
|
||||
// KeysDelete is gaiacli keys delete
|
||||
func (f *Fixtures) KeysDelete(name string, flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiacli keys delete --home=%s %s", f.GCLIHome, name)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli keys delete --home=%s %s", f.GCLIHome, name)
|
||||
executeWrite(f.T, addFlags(cmd, append(append(flags, "-y"), "-f")))
|
||||
}
|
||||
|
||||
// KeysAdd is gaiacli keys add
|
||||
func (f *Fixtures) KeysAdd(name string, flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiacli keys add --home=%s %s", f.GCLIHome, name)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli keys add --home=%s %s", f.GCLIHome, name)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
// KeysAddRecover prepares gaiacli keys add --recover
|
||||
func (f *Fixtures) KeysAddRecover(name, mnemonic string, flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiacli keys add --home=%s --recover %s", f.GCLIHome, name)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli keys add --home=%s --recover %s", f.GCLIHome, name)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags), app.DefaultKeyPass, mnemonic)
|
||||
}
|
||||
|
||||
// KeysAddRecoverHDPath prepares gaiacli keys add --recover --account --index
|
||||
func (f *Fixtures) KeysAddRecoverHDPath(name, mnemonic string, account uint32, index uint32, flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiacli keys add --home=%s --recover %s --account %d --index %d", f.GCLIHome, name, account, index)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli keys add --home=%s --recover %s --account %d --index %d", f.GCLIHome, name, account, index)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags), app.DefaultKeyPass, mnemonic)
|
||||
}
|
||||
|
||||
// KeysShow is gaiacli keys show
|
||||
func (f *Fixtures) KeysShow(name string, flags ...string) keys.KeyOutput {
|
||||
cmd := fmt.Sprintf("gaiacli keys show --home=%s %s", f.GCLIHome, name)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli keys show --home=%s %s", f.GCLIHome, name)
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var ko keys.KeyOutput
|
||||
err := clientkeys.UnmarshalJSON([]byte(out), &ko)
|
||||
|
@ -279,7 +279,7 @@ func (f *Fixtures) KeyAddress(name string) sdk.AccAddress {
|
|||
|
||||
// CLIConfig is gaiacli config
|
||||
func (f *Fixtures) CLIConfig(key, value string, flags ...string) {
|
||||
cmd := fmt.Sprintf("gaiacli config --home=%s %s %s", f.GCLIHome, key, value)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli config --home=%s %s %s", f.GCLIHome, key, value)
|
||||
executeWriteCheckErr(f.T, addFlags(cmd, flags))
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ func (f *Fixtures) CLIConfig(key, value string, flags ...string) {
|
|||
|
||||
// TxSend is gaiacli tx send
|
||||
func (f *Fixtures) TxSend(from string, to sdk.AccAddress, amount sdk.Coin, flags ...string) (bool, string, string) {
|
||||
cmd := fmt.Sprintf("gaiacli tx send %s %s %v --from=%s", to, amount, f.Flags(), from)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx send %s %s %v --from=%s", to, amount, f.Flags(), from)
|
||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
|
@ -296,25 +296,25 @@ func (f *Fixtures) txSendWithConfirm(
|
|||
from string, to sdk.AccAddress, amount sdk.Coin, confirm string, flags ...string,
|
||||
) (bool, string, string) {
|
||||
|
||||
cmd := fmt.Sprintf("gaiacli tx send %s %s %v --from=%s", to, amount, f.Flags(), from)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx send %s %s %v --from=%s", to, amount, f.Flags(), from)
|
||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), confirm, app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
// TxSign is gaiacli tx sign
|
||||
func (f *Fixtures) TxSign(signer, fileName string, flags ...string) (bool, string, string) {
|
||||
cmd := fmt.Sprintf("gaiacli tx sign %v --from=%s %v", f.Flags(), signer, fileName)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx sign %v --from=%s %v", f.Flags(), signer, fileName)
|
||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
// TxBroadcast is gaiacli tx broadcast
|
||||
func (f *Fixtures) TxBroadcast(fileName string, flags ...string) (bool, string, string) {
|
||||
cmd := fmt.Sprintf("gaiacli tx broadcast %v %v", f.Flags(), fileName)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx broadcast %v %v", f.Flags(), fileName)
|
||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
// TxEncode is gaiacli tx encode
|
||||
func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, string) {
|
||||
cmd := fmt.Sprintf("gaiacli tx encode %v %v", f.Flags(), fileName)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx encode %v %v", f.Flags(), fileName)
|
||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, str
|
|||
func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string,
|
||||
flags ...string) (bool, string, string) {
|
||||
|
||||
cmd := fmt.Sprintf("gaiacli tx multisign %v %s %s %s", f.Flags(),
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx multisign %v %s %s %s", f.Flags(),
|
||||
fileName, name, strings.Join(signaturesFiles, " "),
|
||||
)
|
||||
return executeWriteRetStdStreams(f.T, cmd)
|
||||
|
@ -333,7 +333,7 @@ func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string,
|
|||
|
||||
// TxStakingCreateValidator is gaiacli tx staking create-validator
|
||||
func (f *Fixtures) TxStakingCreateValidator(from, consPubKey string, amount sdk.Coin, flags ...string) (bool, string, string) {
|
||||
cmd := fmt.Sprintf("gaiacli tx staking create-validator %v --from=%s --pubkey=%s", f.Flags(), from, consPubKey)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx staking create-validator %v --from=%s --pubkey=%s", f.Flags(), from, consPubKey)
|
||||
cmd += fmt.Sprintf(" --amount=%v --moniker=%v --commission-rate=%v", amount, from, "0.05")
|
||||
cmd += fmt.Sprintf(" --commission-max-rate=%v --commission-max-change-rate=%v", "0.20", "0.10")
|
||||
cmd += fmt.Sprintf(" --min-self-delegation=%v", "1")
|
||||
|
@ -342,7 +342,7 @@ func (f *Fixtures) TxStakingCreateValidator(from, consPubKey string, amount sdk.
|
|||
|
||||
// TxStakingUnbond is gaiacli tx staking unbond
|
||||
func (f *Fixtures) TxStakingUnbond(from, shares string, validator sdk.ValAddress, flags ...string) bool {
|
||||
cmd := fmt.Sprintf("gaiacli tx staking unbond %s %v --from=%s %v", validator, shares, from, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx staking unbond %s %v --from=%s %v", validator, shares, from, f.Flags())
|
||||
return executeWrite(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
|
@ -351,20 +351,20 @@ func (f *Fixtures) TxStakingUnbond(from, shares string, validator sdk.ValAddress
|
|||
|
||||
// TxGovSubmitProposal is gaiacli tx gov submit-proposal
|
||||
func (f *Fixtures) TxGovSubmitProposal(from, typ, title, description string, deposit sdk.Coin, flags ...string) (bool, string, string) {
|
||||
cmd := fmt.Sprintf("gaiacli tx gov submit-proposal %v --from=%s --type=%s", f.Flags(), from, typ)
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx gov submit-proposal %v --from=%s --type=%s", f.Flags(), from, typ)
|
||||
cmd += fmt.Sprintf(" --title=%s --description=%s --deposit=%s", title, description, deposit)
|
||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
// TxGovDeposit is gaiacli tx gov deposit
|
||||
func (f *Fixtures) TxGovDeposit(proposalID int, from string, amount sdk.Coin, flags ...string) (bool, string, string) {
|
||||
cmd := fmt.Sprintf("gaiacli tx gov deposit %d %s --from=%s %v", proposalID, amount, from, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx gov deposit %d %s --from=%s %v", proposalID, amount, from, f.Flags())
|
||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
// TxGovVote is gaiacli tx gov vote
|
||||
func (f *Fixtures) TxGovVote(proposalID int, option gov.VoteOption, from string, flags ...string) (bool, string, string) {
|
||||
cmd := fmt.Sprintf("gaiacli tx gov vote %d %s --from=%s %v", proposalID, option, from, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli tx gov vote %d %s --from=%s %v", proposalID, option, from, f.Flags())
|
||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), app.DefaultKeyPass)
|
||||
}
|
||||
|
||||
|
@ -373,7 +373,7 @@ func (f *Fixtures) TxGovVote(proposalID int, option gov.VoteOption, from string,
|
|||
|
||||
// QueryAccount is gaiacli query account
|
||||
func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.BaseAccount {
|
||||
cmd := fmt.Sprintf("gaiacli query account %s %v", address, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query account %s %v", address, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var initRes map[string]json.RawMessage
|
||||
err := json.Unmarshal([]byte(out), &initRes)
|
||||
|
@ -392,7 +392,7 @@ func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.Ba
|
|||
|
||||
// QueryTxs is gaiacli query txs
|
||||
func (f *Fixtures) QueryTxs(page, limit int, tags ...string) []sdk.TxResponse {
|
||||
cmd := fmt.Sprintf("gaiacli query txs --page=%d --limit=%d --tags='%s' %v", page, limit, queryTags(tags), f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query txs --page=%d --limit=%d --tags='%s' %v", page, limit, queryTags(tags), f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, cmd, "")
|
||||
var txs []sdk.TxResponse
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -403,7 +403,7 @@ func (f *Fixtures) QueryTxs(page, limit int, tags ...string) []sdk.TxResponse {
|
|||
|
||||
// QueryTxsInvalid query txs with wrong parameters and compare expected error
|
||||
func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, tags ...string) {
|
||||
cmd := fmt.Sprintf("gaiacli query txs --page=%d --limit=%d --tags='%s' %v", page, limit, queryTags(tags), f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query txs --page=%d --limit=%d --tags='%s' %v", page, limit, queryTags(tags), f.Flags())
|
||||
_, err := tests.ExecuteT(f.T, cmd, "")
|
||||
require.EqualError(f.T, expectedErr, err)
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, tags ...s
|
|||
|
||||
// QueryStakingValidator is gaiacli query staking validator
|
||||
func (f *Fixtures) QueryStakingValidator(valAddr sdk.ValAddress, flags ...string) staking.Validator {
|
||||
cmd := fmt.Sprintf("gaiacli query staking validator %s %v", valAddr, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query staking validator %s %v", valAddr, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var validator staking.Validator
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -424,7 +424,7 @@ func (f *Fixtures) QueryStakingValidator(valAddr sdk.ValAddress, flags ...string
|
|||
|
||||
// QueryStakingUnbondingDelegationsFrom is gaiacli query staking unbonding-delegations-from
|
||||
func (f *Fixtures) QueryStakingUnbondingDelegationsFrom(valAddr sdk.ValAddress, flags ...string) []staking.UnbondingDelegation {
|
||||
cmd := fmt.Sprintf("gaiacli query staking unbonding-delegations-from %s %v", valAddr, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query staking unbonding-delegations-from %s %v", valAddr, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var ubds []staking.UnbondingDelegation
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -435,7 +435,7 @@ func (f *Fixtures) QueryStakingUnbondingDelegationsFrom(valAddr sdk.ValAddress,
|
|||
|
||||
// QueryStakingDelegationsTo is gaiacli query staking delegations-to
|
||||
func (f *Fixtures) QueryStakingDelegationsTo(valAddr sdk.ValAddress, flags ...string) []staking.Delegation {
|
||||
cmd := fmt.Sprintf("gaiacli query staking delegations-to %s %v", valAddr, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query staking delegations-to %s %v", valAddr, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var delegations []staking.Delegation
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -446,7 +446,7 @@ func (f *Fixtures) QueryStakingDelegationsTo(valAddr sdk.ValAddress, flags ...st
|
|||
|
||||
// QueryStakingPool is gaiacli query staking pool
|
||||
func (f *Fixtures) QueryStakingPool(flags ...string) staking.Pool {
|
||||
cmd := fmt.Sprintf("gaiacli query staking pool %v", f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query staking pool %v", f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var pool staking.Pool
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -457,7 +457,7 @@ func (f *Fixtures) QueryStakingPool(flags ...string) staking.Pool {
|
|||
|
||||
// QueryStakingParameters is gaiacli query staking parameters
|
||||
func (f *Fixtures) QueryStakingParameters(flags ...string) staking.Params {
|
||||
cmd := fmt.Sprintf("gaiacli query staking params %v", f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query staking params %v", f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var params staking.Params
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -471,7 +471,7 @@ func (f *Fixtures) QueryStakingParameters(flags ...string) staking.Params {
|
|||
|
||||
// QueryGovParamDeposit is gaiacli query gov param deposit
|
||||
func (f *Fixtures) QueryGovParamDeposit() gov.DepositParams {
|
||||
cmd := fmt.Sprintf("gaiacli query gov param deposit %s", f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov param deposit %s", f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, cmd, "")
|
||||
var depositParam gov.DepositParams
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -482,7 +482,7 @@ func (f *Fixtures) QueryGovParamDeposit() gov.DepositParams {
|
|||
|
||||
// QueryGovParamVoting is gaiacli query gov param voting
|
||||
func (f *Fixtures) QueryGovParamVoting() gov.VotingParams {
|
||||
cmd := fmt.Sprintf("gaiacli query gov param voting %s", f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov param voting %s", f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, cmd, "")
|
||||
var votingParam gov.VotingParams
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -493,7 +493,7 @@ func (f *Fixtures) QueryGovParamVoting() gov.VotingParams {
|
|||
|
||||
// QueryGovParamTallying is gaiacli query gov param tallying
|
||||
func (f *Fixtures) QueryGovParamTallying() gov.TallyParams {
|
||||
cmd := fmt.Sprintf("gaiacli query gov param tallying %s", f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov param tallying %s", f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, cmd, "")
|
||||
var tallyingParam gov.TallyParams
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -504,7 +504,7 @@ func (f *Fixtures) QueryGovParamTallying() gov.TallyParams {
|
|||
|
||||
// QueryGovProposals is gaiacli query gov proposals
|
||||
func (f *Fixtures) QueryGovProposals(flags ...string) gov.Proposals {
|
||||
cmd := fmt.Sprintf("gaiacli query gov proposals %v", f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov proposals %v", f.Flags())
|
||||
stdout, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
if strings.Contains(stderr, "No matching proposals found") {
|
||||
return gov.Proposals{}
|
||||
|
@ -519,7 +519,7 @@ func (f *Fixtures) QueryGovProposals(flags ...string) gov.Proposals {
|
|||
|
||||
// QueryGovProposal is gaiacli query gov proposal
|
||||
func (f *Fixtures) QueryGovProposal(proposalID int, flags ...string) gov.Proposal {
|
||||
cmd := fmt.Sprintf("gaiacli query gov proposal %d %v", proposalID, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov proposal %d %v", proposalID, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var proposal gov.Proposal
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -530,7 +530,7 @@ func (f *Fixtures) QueryGovProposal(proposalID int, flags ...string) gov.Proposa
|
|||
|
||||
// QueryGovVote is gaiacli query gov vote
|
||||
func (f *Fixtures) QueryGovVote(proposalID int, voter sdk.AccAddress, flags ...string) gov.Vote {
|
||||
cmd := fmt.Sprintf("gaiacli query gov vote %d %s %v", proposalID, voter, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov vote %d %s %v", proposalID, voter, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var vote gov.Vote
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -541,7 +541,7 @@ func (f *Fixtures) QueryGovVote(proposalID int, voter sdk.AccAddress, flags ...s
|
|||
|
||||
// QueryGovVotes is gaiacli query gov votes
|
||||
func (f *Fixtures) QueryGovVotes(proposalID int, flags ...string) []gov.Vote {
|
||||
cmd := fmt.Sprintf("gaiacli query gov votes %d %v", proposalID, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov votes %d %v", proposalID, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var votes []gov.Vote
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -552,7 +552,7 @@ func (f *Fixtures) QueryGovVotes(proposalID int, flags ...string) []gov.Vote {
|
|||
|
||||
// QueryGovDeposit is gaiacli query gov deposit
|
||||
func (f *Fixtures) QueryGovDeposit(proposalID int, depositor sdk.AccAddress, flags ...string) gov.Deposit {
|
||||
cmd := fmt.Sprintf("gaiacli query gov deposit %d %s %v", proposalID, depositor, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov deposit %d %s %v", proposalID, depositor, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var deposit gov.Deposit
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -563,7 +563,7 @@ func (f *Fixtures) QueryGovDeposit(proposalID int, depositor sdk.AccAddress, fla
|
|||
|
||||
// QueryGovDeposits is gaiacli query gov deposits
|
||||
func (f *Fixtures) QueryGovDeposits(propsalID int, flags ...string) []gov.Deposit {
|
||||
cmd := fmt.Sprintf("gaiacli query gov deposits %d %v", propsalID, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query gov deposits %d %v", propsalID, f.Flags())
|
||||
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
|
||||
var deposits []gov.Deposit
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -577,7 +577,7 @@ func (f *Fixtures) QueryGovDeposits(propsalID int, flags ...string) []gov.Deposi
|
|||
|
||||
// QuerySigningInfo returns the signing info for a validator
|
||||
func (f *Fixtures) QuerySigningInfo(val string) slashing.ValidatorSigningInfo {
|
||||
cmd := fmt.Sprintf("gaiacli query slashing signing-info %s %s", val, f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query slashing signing-info %s %s", val, f.Flags())
|
||||
res, errStr := tests.ExecuteT(f.T, cmd, "")
|
||||
require.Empty(f.T, errStr)
|
||||
cdc := app.MakeCodec()
|
||||
|
@ -589,7 +589,7 @@ func (f *Fixtures) QuerySigningInfo(val string) slashing.ValidatorSigningInfo {
|
|||
|
||||
// QuerySlashingParams is gaiacli query slashing params
|
||||
func (f *Fixtures) QuerySlashingParams() slashing.Params {
|
||||
cmd := fmt.Sprintf("gaiacli query slashing params %s", f.Flags())
|
||||
cmd := fmt.Sprintf("../../../build/gaiacli query slashing params %s", f.Flags())
|
||||
res, errStr := tests.ExecuteT(f.T, cmd, "")
|
||||
require.Empty(f.T, errStr)
|
||||
cdc := app.MakeCodec()
|
||||
|
|
|
@ -32,8 +32,8 @@ func TestAddGenesisAccount(t *testing.T) {
|
|||
args{
|
||||
app.GenesisState{},
|
||||
addr1,
|
||||
sdk.Coins{},
|
||||
sdk.Coins{},
|
||||
sdk.NewCoins(),
|
||||
sdk.NewCoins(),
|
||||
0,
|
||||
0,
|
||||
},
|
||||
|
@ -44,8 +44,8 @@ func TestAddGenesisAccount(t *testing.T) {
|
|||
args{
|
||||
app.GenesisState{Accounts: []app.GenesisAccount{{Address: addr1}}},
|
||||
addr1,
|
||||
sdk.Coins{},
|
||||
sdk.Coins{},
|
||||
sdk.NewCoins(),
|
||||
sdk.NewCoins(),
|
||||
0,
|
||||
0,
|
||||
},
|
||||
|
@ -56,8 +56,8 @@ func TestAddGenesisAccount(t *testing.T) {
|
|||
args{
|
||||
app.GenesisState{},
|
||||
addr1,
|
||||
sdk.Coins{sdk.NewInt64Coin("stake", 50)},
|
||||
sdk.Coins{sdk.NewInt64Coin("stake", 100)},
|
||||
sdk.NewCoins(sdk.NewInt64Coin("stake", 50)),
|
||||
sdk.NewCoins(sdk.NewInt64Coin("stake", 100)),
|
||||
0,
|
||||
0,
|
||||
},
|
||||
|
@ -68,8 +68,8 @@ func TestAddGenesisAccount(t *testing.T) {
|
|||
args{
|
||||
app.GenesisState{},
|
||||
addr1,
|
||||
sdk.Coins{sdk.NewInt64Coin("stake", 50)},
|
||||
sdk.Coins{sdk.NewInt64Coin("stake", 50)},
|
||||
sdk.NewCoins(sdk.NewInt64Coin("stake", 50)),
|
||||
sdk.NewCoins(sdk.NewInt64Coin("stake", 50)),
|
||||
1654668078,
|
||||
1554668078,
|
||||
},
|
||||
|
|
|
@ -130,6 +130,28 @@ func (coin Coin) IsNegative() bool {
|
|||
// Coins is a set of Coin, one per currency
|
||||
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 {
|
||||
if len(coins) == 0 {
|
||||
return ""
|
||||
|
@ -552,3 +574,19 @@ func ParseCoins(coinsStr string) (coins Coins, err error) {
|
|||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -559,3 +559,31 @@ func TestCoinsIsAllGTE(t *testing.T) {
|
|||
assert.False(t, Coins{{testDenom1, one}, {testDenom2, one}}.IsAllGTE(Coins{{testDenom1, one}, {testDenom2, two}}))
|
||||
assert.False(t, Coins{{"xxx", one}, {"yyy", one}}.IsAllGTE(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)
|
||||
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)
|
||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInsufficientFunds)
|
||||
|
||||
require.True(t, input.fck.GetCollectedFees(ctx).IsEqual(emptyCoins))
|
||||
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)
|
||||
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)))
|
||||
}
|
||||
|
||||
|
@ -333,24 +333,24 @@ func TestAnteHandlerMemoGas(t *testing.T) {
|
|||
var tx sdk.Tx
|
||||
msg := newTestMsg(addr1)
|
||||
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 = newTestTx(ctx, []sdk.Msg{msg}, privs, accnums, seqs, fee)
|
||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas)
|
||||
|
||||
// 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")
|
||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeOutOfGas)
|
||||
|
||||
// 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))
|
||||
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeMemoTooLarge)
|
||||
|
||||
// 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))
|
||||
checkValidTx(t, anteHandler, ctx, tx, false)
|
||||
}
|
||||
|
@ -721,28 +721,28 @@ func TestEnsureSufficientMempoolFees(t *testing.T) {
|
|||
input StdFee
|
||||
expectedOK bool
|
||||
}{
|
||||
{NewStdFee(200000, sdk.Coins{sdk.NewInt64Coin("photino", 5)}), false},
|
||||
{NewStdFee(200000, sdk.Coins{sdk.NewInt64Coin("stake", 1)}), false},
|
||||
{NewStdFee(200000, sdk.Coins{sdk.NewInt64Coin("stake", 2)}), true},
|
||||
{NewStdFee(200000, sdk.Coins{sdk.NewInt64Coin("photino", 10)}), true},
|
||||
{NewStdFee(200000, sdk.NewCoins(sdk.NewInt64Coin("photino", 5))), false},
|
||||
{NewStdFee(200000, sdk.NewCoins(sdk.NewInt64Coin("stake", 1))), false},
|
||||
{NewStdFee(200000, sdk.NewCoins(sdk.NewInt64Coin("stake", 2))), true},
|
||||
{NewStdFee(200000, sdk.NewCoins(sdk.NewInt64Coin("photino", 10))), true},
|
||||
{
|
||||
NewStdFee(
|
||||
200000,
|
||||
sdk.Coins{
|
||||
sdk.NewCoins(
|
||||
sdk.NewInt64Coin("photino", 10),
|
||||
sdk.NewInt64Coin("stake", 2),
|
||||
},
|
||||
),
|
||||
),
|
||||
true,
|
||||
},
|
||||
{
|
||||
NewStdFee(
|
||||
200000,
|
||||
sdk.Coins{
|
||||
sdk.NewCoins(
|
||||
sdk.NewInt64Coin("atom", 5),
|
||||
sdk.NewInt64Coin("photino", 10),
|
||||
sdk.NewInt64Coin("stake", 2),
|
||||
},
|
||||
),
|
||||
),
|
||||
true,
|
||||
},
|
||||
|
|
|
@ -33,10 +33,11 @@ func (fck FeeCollectionKeeper) GetCollectedFees(ctx sdk.Context) sdk.Coins {
|
|||
store := ctx.KVStore(fck.key)
|
||||
bz := store.Get(collectedFeesKey)
|
||||
if bz == nil {
|
||||
return sdk.Coins{}
|
||||
return sdk.NewCoins()
|
||||
}
|
||||
|
||||
feePool := &(sdk.Coins{})
|
||||
emptyFees := sdk.NewCoins()
|
||||
feePool := &emptyFees
|
||||
fck.cdc.MustUnmarshalBinaryLengthPrefixed(bz, feePool)
|
||||
return *feePool
|
||||
}
|
||||
|
@ -57,5 +58,5 @@ func (fck FeeCollectionKeeper) AddCollectedFees(ctx sdk.Context, coins sdk.Coins
|
|||
|
||||
// ClearCollectedFees - clear the fee pool
|
||||
func (fck FeeCollectionKeeper) ClearCollectedFees(ctx sdk.Context) {
|
||||
fck.setCollectedFees(ctx, sdk.Coins{})
|
||||
fck.setCollectedFees(ctx, sdk.NewCoins())
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
emptyCoins = sdk.Coins{}
|
||||
oneCoin = sdk.Coins{sdk.NewInt64Coin("foocoin", 1)}
|
||||
twoCoins = sdk.Coins{sdk.NewInt64Coin("foocoin", 2)}
|
||||
emptyCoins = sdk.NewCoins()
|
||||
oneCoin = sdk.NewCoins(sdk.NewInt64Coin("foocoin", 1))
|
||||
twoCoins = sdk.NewCoins(sdk.NewInt64Coin("foocoin", 2))
|
||||
)
|
||||
|
||||
func TestFeeCollectionKeeperGetSet(t *testing.T) {
|
||||
|
|
|
@ -22,7 +22,7 @@ func NewGenesisState(collectedFees sdk.Coins, params Params) GenesisState {
|
|||
|
||||
// DefaultGenesisState - Return a default genesis state
|
||||
func DefaultGenesisState() GenesisState {
|
||||
return NewGenesisState(sdk.Coins{}, DefaultParams())
|
||||
return NewGenesisState(sdk.NewCoins(), DefaultParams())
|
||||
}
|
||||
|
||||
// InitGenesis - Init store state from genesis data
|
||||
|
|
|
@ -141,7 +141,7 @@ func (fee StdFee) Bytes() []byte {
|
|||
// (in the lcd_test, client side its null,
|
||||
// server side its [])
|
||||
if len(fee.Amount) == 0 {
|
||||
fee.Amount = sdk.Coins{}
|
||||
fee.Amount = sdk.NewCoins()
|
||||
}
|
||||
bz, err := msgCdc.MarshalJSON(fee) // TODO
|
||||
if err != nil {
|
||||
|
|
|
@ -55,7 +55,7 @@ func newTestMsg(addrs ...sdk.AccAddress) *sdk.TestMsg {
|
|||
|
||||
func newStdFee() StdFee {
|
||||
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 {
|
||||
acc := am.GetAccount(ctx, addr)
|
||||
if acc == nil {
|
||||
return sdk.Coins{}
|
||||
return sdk.NewCoins()
|
||||
}
|
||||
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())
|
||||
}
|
||||
|
||||
oldCoins, spendableCoins := sdk.Coins{}, sdk.Coins{}
|
||||
oldCoins, spendableCoins := sdk.NewCoins(), sdk.NewCoins()
|
||||
|
||||
acc := getAccount(ctx, ak, addr)
|
||||
if acc != nil {
|
||||
|
|
|
@ -66,71 +66,71 @@ func TestKeeper(t *testing.T) {
|
|||
|
||||
// Test GetCoins/SetCoins
|
||||
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)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(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.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
|
||||
// Test HasCoins
|
||||
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{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.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
||||
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
require.True(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15))))
|
||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 5))))
|
||||
|
||||
// Test AddCoins
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 15)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 25)}))
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15)))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 25))))
|
||||
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 15)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 15), sdk.NewInt64Coin("foocoin", 25)}))
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 15)))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 15), sdk.NewInt64Coin("foocoin", 25))))
|
||||
|
||||
// Test SubtractCoins
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)})
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 5)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10)))
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 5)))
|
||||
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)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 15)}))
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 11)))
|
||||
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)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 15)}))
|
||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}))
|
||||
bankKeeper.SubtractCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10)))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15))))
|
||||
require.False(t, bankKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 1))))
|
||||
|
||||
// Test SendCoins
|
||||
bankKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(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.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
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.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
require.True(t, bankKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
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.SendCoins(ctx, addr, addr2, sdk.Coins{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, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 30)))
|
||||
bankKeeper.SendCoins(ctx, addr, addr2, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), 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.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10))))
|
||||
|
||||
// Test InputOutputCoins
|
||||
input1 := NewInput(addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)})
|
||||
output1 := NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 2)})
|
||||
input1 := NewInput(addr2, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 2)))
|
||||
output1 := NewOutput(addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 2)))
|
||||
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, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 8)}))
|
||||
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.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 8))))
|
||||
|
||||
inputs := []Input{
|
||||
NewInput(addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 3)}),
|
||||
NewInput(addr2, sdk.Coins{sdk.NewInt64Coin("barcoin", 3), sdk.NewInt64Coin("foocoin", 2)}),
|
||||
NewInput(addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 3))),
|
||||
NewInput(addr2, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 3), sdk.NewInt64Coin("foocoin", 2))),
|
||||
}
|
||||
|
||||
outputs := []Output{
|
||||
NewOutput(addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 1)}),
|
||||
NewOutput(addr3, sdk.Coins{sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5)}),
|
||||
NewOutput(addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 1))),
|
||||
NewOutput(addr3, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5))),
|
||||
}
|
||||
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, addr2).IsEqual(sdk.Coins{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, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("barcoin", 21), sdk.NewInt64Coin("foocoin", 4))))
|
||||
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.NewCoins(sdk.NewInt64Coin("barcoin", 2), sdk.NewInt64Coin("foocoin", 5))))
|
||||
}
|
||||
|
||||
func TestSendKeeper(t *testing.T) {
|
||||
|
@ -147,33 +147,33 @@ func TestSendKeeper(t *testing.T) {
|
|||
|
||||
// Test GetCoins/SetCoins
|
||||
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)})
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(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.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
|
||||
// Test HasCoins
|
||||
require.True(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, sendKeeper.HasCoins(ctx, addr, sdk.Coins{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.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
||||
require.True(t, sendKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
require.True(t, sendKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||
require.False(t, sendKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15))))
|
||||
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
|
||||
sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 5)})
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(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.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
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.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("foocoin", 5)}))
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
require.True(t, sendKeeper.GetCoins(ctx, addr2).IsEqual(sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("barcoin", 30)})
|
||||
sendKeeper.SendCoins(ctx, addr, addr2, sdk.Coins{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, addr2).IsEqual(sdk.Coins{sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10)}))
|
||||
bankKeeper.AddCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 30)))
|
||||
sendKeeper.SendCoins(ctx, addr, addr2, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 10), 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.NewCoins(sdk.NewInt64Coin("barcoin", 10), sdk.NewInt64Coin("foocoin", 10))))
|
||||
|
||||
// validate coins with invalid denoms or negative values cannot be sent
|
||||
// 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
|
||||
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)})
|
||||
require.True(t, viewKeeper.GetCoins(ctx, addr).IsEqual(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.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
|
||||
// Test HasCoins
|
||||
require.True(t, viewKeeper.HasCoins(ctx, addr, sdk.Coins{sdk.NewInt64Coin("foocoin", 10)}))
|
||||
require.True(t, viewKeeper.HasCoins(ctx, addr, sdk.Coins{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.Coins{sdk.NewInt64Coin("barcoin", 5)}))
|
||||
require.True(t, viewKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 10))))
|
||||
require.True(t, viewKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 5))))
|
||||
require.False(t, viewKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 15))))
|
||||
require.False(t, viewKeeper.HasCoins(ctx, addr, sdk.NewCoins(sdk.NewInt64Coin("barcoin", 5))))
|
||||
}
|
||||
|
||||
func TestVestingAccountSend(t *testing.T) {
|
||||
|
@ -213,8 +213,8 @@ func TestVestingAccountSend(t *testing.T) {
|
|||
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
||||
endTime := now.Add(24 * time.Hour)
|
||||
|
||||
origCoins := sdk.Coins{sdk.NewInt64Coin("steak", 100)}
|
||||
sendCoins := sdk.Coins{sdk.NewInt64Coin("steak", 50)}
|
||||
origCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100))
|
||||
sendCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 50))
|
||||
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
||||
bankKeeper.SetSendEnabled(ctx, true)
|
||||
|
||||
|
@ -247,8 +247,8 @@ func TestVestingAccountReceive(t *testing.T) {
|
|||
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
||||
endTime := now.Add(24 * time.Hour)
|
||||
|
||||
origCoins := sdk.Coins{sdk.NewInt64Coin("steak", 100)}
|
||||
sendCoins := sdk.Coins{sdk.NewInt64Coin("steak", 50)}
|
||||
origCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100))
|
||||
sendCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 50))
|
||||
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
||||
bankKeeper.SetSendEnabled(ctx, true)
|
||||
|
||||
|
@ -281,8 +281,8 @@ func TestDelegateCoins(t *testing.T) {
|
|||
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
||||
endTime := now.Add(24 * time.Hour)
|
||||
|
||||
origCoins := sdk.Coins{sdk.NewInt64Coin("steak", 100)}
|
||||
delCoins := sdk.Coins{sdk.NewInt64Coin("steak", 50)}
|
||||
origCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100))
|
||||
delCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 50))
|
||||
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
||||
bankKeeper.SetSendEnabled(ctx, true)
|
||||
|
||||
|
@ -318,8 +318,8 @@ func TestUndelegateCoins(t *testing.T) {
|
|||
ctx := input.ctx.WithBlockHeader(abci.Header{Time: now})
|
||||
endTime := now.Add(24 * time.Hour)
|
||||
|
||||
origCoins := sdk.Coins{sdk.NewInt64Coin("steak", 100)}
|
||||
delCoins := sdk.Coins{sdk.NewInt64Coin("steak", 50)}
|
||||
origCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100))
|
||||
delCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 50))
|
||||
bankKeeper := NewBaseKeeper(input.ak, input.pk.Subspace(DefaultParamspace), DefaultCodespace)
|
||||
bankKeeper.SetSendEnabled(ctx, true)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
func TestMsgSendRoute(t *testing.T) {
|
||||
addr1 := sdk.AccAddress([]byte("from"))
|
||||
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)
|
||||
|
||||
require.Equal(t, msg.Route(), "bank")
|
||||
|
@ -22,9 +22,9 @@ func TestMsgSendRoute(t *testing.T) {
|
|||
func TestMsgSendValidation(t *testing.T) {
|
||||
addr1 := sdk.AccAddress([]byte("from"))
|
||||
addr2 := sdk.AccAddress([]byte("to"))
|
||||
atom123 := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
||||
atom0 := sdk.Coins{sdk.NewInt64Coin("atom", 0)}
|
||||
atom123eth123 := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 123)}
|
||||
atom123 := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||
atom0 := sdk.NewCoins(sdk.NewInt64Coin("atom", 0))
|
||||
atom123eth123 := sdk.NewCoins(sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 123))
|
||||
atom123eth0 := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 0)}
|
||||
|
||||
var emptyAddr sdk.AccAddress
|
||||
|
@ -41,12 +41,12 @@ func TestMsgSendValidation(t *testing.T) {
|
|||
{false, NewMsgSend(addr1, emptyAddr, atom123)}, // empty to addr
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
for _, tc := range cases {
|
||||
err := tc.tx.ValidateBasic()
|
||||
if tc.valid {
|
||||
require.Nil(t, err, "%d: %+v", i, err)
|
||||
require.Nil(t, err)
|
||||
} 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) {
|
||||
addr1 := sdk.AccAddress([]byte("input"))
|
||||
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)
|
||||
res := msg.GetSignBytes()
|
||||
|
||||
|
@ -63,7 +63,7 @@ func TestMsgSendGetSignBytes(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()
|
||||
// TODO: fix this !
|
||||
require.Equal(t, fmt.Sprintf("%v", res), "[696E70757431]")
|
||||
|
@ -73,7 +73,7 @@ func TestMsgMultiSendRoute(t *testing.T) {
|
|||
// Construct a MsgSend
|
||||
addr1 := sdk.AccAddress([]byte("input"))
|
||||
addr2 := sdk.AccAddress([]byte("output"))
|
||||
coins := sdk.Coins{sdk.NewInt64Coin("atom", 10)}
|
||||
coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10))
|
||||
var msg = MsgMultiSend{
|
||||
Inputs: []Input{NewInput(addr1, coins)},
|
||||
Outputs: []Output{NewOutput(addr2, coins)},
|
||||
|
@ -87,12 +87,12 @@ func TestMsgMultiSendRoute(t *testing.T) {
|
|||
func TestInputValidation(t *testing.T) {
|
||||
addr1 := sdk.AccAddress([]byte{1, 2})
|
||||
addr2 := sdk.AccAddress([]byte{7, 8})
|
||||
someCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
||||
multiCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 20)}
|
||||
someCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||
multiCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 20))
|
||||
|
||||
var emptyAddr sdk.AccAddress
|
||||
emptyCoins := sdk.Coins{}
|
||||
emptyCoins2 := sdk.Coins{sdk.NewInt64Coin("eth", 0)}
|
||||
emptyCoins := sdk.NewCoins()
|
||||
emptyCoins2 := sdk.NewCoins(sdk.NewInt64Coin("eth", 0))
|
||||
someEmptyCoins := sdk.Coins{sdk.NewInt64Coin("eth", 10), sdk.NewInt64Coin("atom", 0)}
|
||||
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) {
|
||||
addr1 := sdk.AccAddress([]byte{1, 2})
|
||||
addr2 := sdk.AccAddress([]byte{7, 8})
|
||||
someCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
||||
multiCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 20)}
|
||||
someCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||
multiCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 20))
|
||||
|
||||
var emptyAddr sdk.AccAddress
|
||||
emptyCoins := sdk.Coins{}
|
||||
emptyCoins2 := sdk.Coins{sdk.NewInt64Coin("eth", 0)}
|
||||
emptyCoins := sdk.NewCoins()
|
||||
emptyCoins2 := sdk.NewCoins(sdk.NewInt64Coin("eth", 0))
|
||||
someEmptyCoins := sdk.Coins{sdk.NewInt64Coin("eth", 10), sdk.NewInt64Coin("atom", 0)}
|
||||
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) {
|
||||
addr1 := sdk.AccAddress([]byte{1, 2})
|
||||
addr2 := sdk.AccAddress([]byte{7, 8})
|
||||
atom123 := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
||||
atom124 := sdk.Coins{sdk.NewInt64Coin("atom", 124)}
|
||||
eth123 := sdk.Coins{sdk.NewInt64Coin("eth", 123)}
|
||||
atom123eth123 := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 123)}
|
||||
atom123 := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||
atom124 := sdk.NewCoins(sdk.NewInt64Coin("atom", 124))
|
||||
eth123 := sdk.NewCoins(sdk.NewInt64Coin("eth", 123))
|
||||
atom123eth123 := sdk.NewCoins(sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 123))
|
||||
|
||||
input1 := NewInput(addr1, atom123)
|
||||
input2 := NewInput(addr1, eth123)
|
||||
|
@ -217,7 +217,7 @@ func TestMsgMultiSendValidation(t *testing.T) {
|
|||
func TestMsgMultiSendGetSignBytes(t *testing.T) {
|
||||
addr1 := sdk.AccAddress([]byte("input"))
|
||||
addr2 := sdk.AccAddress([]byte("output"))
|
||||
coins := sdk.Coins{sdk.NewInt64Coin("atom", 10)}
|
||||
coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10))
|
||||
var msg = MsgMultiSend{
|
||||
Inputs: []Input{NewInput(addr1, coins)},
|
||||
Outputs: []Output{NewOutput(addr2, coins)},
|
||||
|
@ -250,7 +250,7 @@ func TestMsgSendSigners(t *testing.T) {
|
|||
{7, 8, 9},
|
||||
}
|
||||
|
||||
someCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123)}
|
||||
someCoins := sdk.NewCoins(sdk.NewInt64Coin("atom", 123))
|
||||
inputs := make([]Input, len(signers))
|
||||
for i, signer := range signers {
|
||||
inputs[i] = NewInput(signer, someCoins)
|
||||
|
|
|
@ -28,7 +28,7 @@ func NonnegativeBalanceInvariant(ak auth.AccountKeeper) sdk.Invariant {
|
|||
// is what is expected
|
||||
func TotalCoinsInvariant(ak auth.AccountKeeper, totalSupplyFn func() sdk.Coins) sdk.Invariant {
|
||||
return func(ctx sdk.Context) error {
|
||||
totalCoins := sdk.Coins{}
|
||||
totalCoins := sdk.NewCoins()
|
||||
|
||||
chkAccount := func(acc auth.Account) bool {
|
||||
coins := acc.GetCoins()
|
||||
|
|
|
@ -158,5 +158,5 @@ func (fck DummyFeeCollectionKeeper) SetCollectedFees(in sdk.Coins) {
|
|||
heldFees = in
|
||||
}
|
||||
func (fck DummyFeeCollectionKeeper) ClearCollectedFees(_ sdk.Context) {
|
||||
heldFees = sdk.Coins{}
|
||||
heldFees = sdk.NewCoins()
|
||||
}
|
||||
|
|
|
@ -59,24 +59,30 @@ func CanWithdrawInvariant(k distr.Keeper, sk types.StakingKeeper) sdk.Invariant
|
|||
|
||||
var remaining sdk.DecCoins
|
||||
|
||||
valDelegationAddrs := make(map[string][]sdk.AccAddress)
|
||||
for _, del := range sk.GetAllSDKDelegations(ctx) {
|
||||
valAddr := del.GetValidatorAddr().String()
|
||||
valDelegationAddrs[valAddr] = append(valDelegationAddrs[valAddr], del.GetDelegatorAddr())
|
||||
}
|
||||
|
||||
// iterate over all validators
|
||||
sk.IterateValidators(ctx, func(_ int64, val sdk.Validator) (stop bool) {
|
||||
_ = k.WithdrawValidatorCommission(ctx, val.GetOperator())
|
||||
// TODO fetch delegations just for the validator, requires sdk.ValidatorSet change
|
||||
// iterate over all current delegations, withdraw rewards
|
||||
dels := sk.GetAllSDKDelegations(ctx)
|
||||
for _, delegation := range dels {
|
||||
if delegation.GetValidatorAddr().String() == val.GetOperator().String() {
|
||||
err := k.WithdrawDelegationRewards(ctx, delegation.GetDelegatorAddr(), delegation.GetValidatorAddr())
|
||||
if err != nil {
|
||||
|
||||
delegationAddrs, ok := valDelegationAddrs[val.GetOperator().String()]
|
||||
if ok {
|
||||
for _, delAddr := range delegationAddrs {
|
||||
if err := k.WithdrawDelegationRewards(ctx, delAddr, val.GetOperator()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remaining = k.GetValidatorOutstandingRewards(ctx, val.GetOperator())
|
||||
if len(remaining) > 0 && remaining[0].Amount.LT(sdk.ZeroDec()) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ func (keeper Keeper) NewTextProposal(ctx sdk.Context, title string, description
|
|||
ProposalType: proposalType,
|
||||
Status: StatusDepositPeriod,
|
||||
FinalTallyResult: EmptyTallyResult(),
|
||||
TotalDeposit: sdk.Coins{},
|
||||
TotalDeposit: sdk.NewCoins(),
|
||||
SubmitTime: ctx.BlockHeader().Time,
|
||||
}
|
||||
|
||||
|
|
|
@ -69,15 +69,15 @@ func TestDeposits(t *testing.T) {
|
|||
proposal := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
|
||||
proposalID := proposal.GetProposalID()
|
||||
|
||||
fourSteak := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(4))}
|
||||
fiveSteak := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(5))}
|
||||
fourSteak := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(4)))
|
||||
fiveSteak := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromTendermintPower(5)))
|
||||
|
||||
addr0Initial := keeper.ck.GetCoins(ctx, addrs[0])
|
||||
addr1Initial := keeper.ck.GetCoins(ctx, addrs[1])
|
||||
|
||||
expTokens := sdk.TokensFromTendermintPower(42)
|
||||
require.Equal(t, sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, expTokens)}, addr0Initial)
|
||||
require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.Coins{}))
|
||||
require.Equal(t, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, expTokens)), addr0Initial)
|
||||
require.True(t, proposal.GetTotalDeposit().IsEqual(sdk.NewCoins()))
|
||||
|
||||
// Check no deposits at beginning
|
||||
deposit, found := keeper.GetDeposit(ctx, proposalID, addrs[1])
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
coinsPos = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000)}
|
||||
coinsZero = sdk.Coins{}
|
||||
coinsPosNotAtoms = sdk.Coins{sdk.NewInt64Coin("foo", 10000)}
|
||||
coinsMulti = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000), sdk.NewInt64Coin("foo", 10000)}
|
||||
coinsPos = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000))
|
||||
coinsZero = sdk.NewCoins()
|
||||
coinsPosNotAtoms = sdk.NewCoins(sdk.NewInt64Coin("foo", 10000))
|
||||
coinsMulti = sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000), sdk.NewInt64Coin("foo", 10000))
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -23,7 +23,7 @@ func init() {
|
|||
|
||||
// test ValidateBasic for MsgCreateValidator
|
||||
func TestMsgSubmitProposal(t *testing.T) {
|
||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.NewCoins())
|
||||
tests := []struct {
|
||||
title, description string
|
||||
proposalType ProposalKind
|
||||
|
@ -65,7 +65,7 @@ func TestMsgDepositGetSignBytes(t *testing.T) {
|
|||
|
||||
// test ValidateBasic for MsgDeposit
|
||||
func TestMsgDeposit(t *testing.T) {
|
||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.NewCoins())
|
||||
tests := []struct {
|
||||
proposalID uint64
|
||||
depositorAddr sdk.AccAddress
|
||||
|
@ -90,7 +90,7 @@ func TestMsgDeposit(t *testing.T) {
|
|||
|
||||
// test ValidateBasic for MsgDeposit
|
||||
func TestMsgVote(t *testing.T) {
|
||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.Coins{})
|
||||
_, addrs, _, _ := mock.CreateGenAccounts(1, sdk.NewCoins())
|
||||
tests := []struct {
|
||||
proposalID uint64
|
||||
voterAddr sdk.AccAddress
|
||||
|
|
|
@ -62,7 +62,7 @@ func NewApp() *App {
|
|||
KeyFeeCollection: sdk.NewKVStoreKey("fee"),
|
||||
KeyParams: sdk.NewKVStoreKey("params"),
|
||||
TKeyParams: sdk.NewTransientStoreKey("transient_params"),
|
||||
TotalCoinsSupply: sdk.Coins{},
|
||||
TotalCoinsSupply: sdk.NewCoins(),
|
||||
}
|
||||
|
||||
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 {
|
||||
// Make the transaction free
|
||||
fee := auth.StdFee{
|
||||
Amount: sdk.Coins{sdk.NewInt64Coin("foocoin", 0)},
|
||||
Amount: sdk.NewCoins(sdk.NewInt64Coin("foocoin", 0)),
|
||||
Gas: 100000,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue