Merge PR #56: Update to latest SDK: Supply
This commit is contained in:
committed by
Alexander Bezobchuk
parent
534e56abd1
commit
bab3694437
@@ -3,10 +3,9 @@
|
||||
The gaia cli integration tests live in this folder. You can run the full suite by running:
|
||||
|
||||
```bash
|
||||
$ go test -mod=readonly -p 4 `go list ./cmd/gaia/cli_test/...` -tags=cli_test
|
||||
# OR!
|
||||
$ make test_cli
|
||||
go test -mod=readonly -p 4 `go list ./cli_test/...` -tags=cli_test
|
||||
```
|
||||
|
||||
> NOTE: While the full suite runs in parallel, some of the tests can take up to a minute to complete
|
||||
|
||||
### Test Structure
|
||||
@@ -33,6 +32,7 @@ func TestMyNewCommand(t *testing.T) {
|
||||
```
|
||||
|
||||
This boilerplate above:
|
||||
|
||||
- Ensures the tests run in parallel. Because the tests are calling out to `os/exec` for many operations these tests can take a long time to run.
|
||||
- Creates `.gaiad` and `.gaiacli` folders in a new temp folder.
|
||||
- Uses `gaiacli` to create 2 accounts for use in testing: `foo` and `bar`
|
||||
|
||||
@@ -25,7 +25,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/tests"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/genaccounts"
|
||||
"github.com/cosmos/cosmos-sdk/x/genaccounts"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
)
|
||||
@@ -442,6 +442,23 @@ func TestGaiaCLIQueryRewards(t *testing.T) {
|
||||
f.Cleanup()
|
||||
}
|
||||
|
||||
func TestGaiaCLIQuerySupply(t *testing.T) {
|
||||
t.Parallel()
|
||||
f := InitFixtures(t)
|
||||
|
||||
// start gaiad server
|
||||
proc := f.GDStart()
|
||||
defer proc.Stop(false)
|
||||
|
||||
totalSupply := f.QueryTotalSupply()
|
||||
totalSupplyOf := f.QueryTotalSupplyOf(fooDenom)
|
||||
|
||||
require.Equal(t, totalCoins, totalSupply)
|
||||
require.True(sdk.IntEq(t, totalCoins.AmountOf(fooDenom), totalSupplyOf))
|
||||
|
||||
f.Cleanup()
|
||||
}
|
||||
|
||||
func TestGaiaCLISubmitProposal(t *testing.T) {
|
||||
t.Parallel()
|
||||
f := InitFixtures(t)
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||
"github.com/cosmos/cosmos-sdk/server"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/tests"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
@@ -45,16 +46,23 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
startCoins = sdk.Coins{
|
||||
sdk.NewCoin(feeDenom, sdk.TokensFromConsensusPower(1000000)),
|
||||
totalCoins = sdk.NewCoins(
|
||||
sdk.NewCoin(fee2Denom, sdk.TokensFromConsensusPower(2000000)),
|
||||
sdk.NewCoin(feeDenom, sdk.TokensFromConsensusPower(2000000)),
|
||||
sdk.NewCoin(fooDenom, sdk.TokensFromConsensusPower(2000)),
|
||||
sdk.NewCoin(denom, sdk.TokensFromConsensusPower(300).Add(sdk.NewInt(12))), // add coins from inflation
|
||||
)
|
||||
|
||||
startCoins = sdk.NewCoins(
|
||||
sdk.NewCoin(fee2Denom, sdk.TokensFromConsensusPower(1000000)),
|
||||
sdk.NewCoin(feeDenom, sdk.TokensFromConsensusPower(1000000)),
|
||||
sdk.NewCoin(fooDenom, sdk.TokensFromConsensusPower(1000)),
|
||||
sdk.NewCoin(denom, sdk.TokensFromConsensusPower(150)),
|
||||
}
|
||||
)
|
||||
|
||||
vestingCoins = sdk.Coins{
|
||||
vestingCoins = sdk.NewCoins(
|
||||
sdk.NewCoin(feeDenom, sdk.TokensFromConsensusPower(500000)),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
//___________________________________________________________________________________
|
||||
@@ -112,12 +120,12 @@ func (f Fixtures) GenesisFile() string {
|
||||
}
|
||||
|
||||
// GenesisFile returns the application's genesis state
|
||||
func (f Fixtures) GenesisState() app.GenesisState {
|
||||
func (f Fixtures) GenesisState() simapp.GenesisState {
|
||||
cdc := codec.New()
|
||||
genDoc, err := tmtypes.GenesisDocFromFile(f.GenesisFile())
|
||||
require.NoError(f.T, err)
|
||||
|
||||
var appState app.GenesisState
|
||||
var appState simapp.GenesisState
|
||||
require.NoError(f.T, cdc.UnmarshalJSON(genDoc.AppState, &appState))
|
||||
return appState
|
||||
}
|
||||
@@ -643,9 +651,9 @@ func (f *Fixtures) QuerySlashingParams() slashing.Params {
|
||||
//___________________________________________________________________________________
|
||||
// query distribution
|
||||
|
||||
// QuerySigningInfo returns the signing info for a validator
|
||||
// QueryRewards returns the rewards of a delegator
|
||||
func (f *Fixtures) QueryRewards(delAddr sdk.AccAddress, flags ...string) distribution.QueryDelegatorTotalRewardsResponse {
|
||||
cmd := fmt.Sprintf("%s query distr rewards %s %s", f.GaiacliBinary, delAddr, f.Flags())
|
||||
cmd := fmt.Sprintf("%s query distribution rewards %s %s", f.GaiacliBinary, delAddr, f.Flags())
|
||||
res, errStr := tests.ExecuteT(f.T, cmd, "")
|
||||
require.Empty(f.T, errStr)
|
||||
cdc := app.MakeCodec()
|
||||
@@ -655,6 +663,32 @@ func (f *Fixtures) QueryRewards(delAddr sdk.AccAddress, flags ...string) distrib
|
||||
return rewards
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
// query supply
|
||||
|
||||
// QueryTotalSupply returns the total supply of coins
|
||||
func (f *Fixtures) QueryTotalSupply(flags ...string) (totalSupply sdk.Coins) {
|
||||
cmd := fmt.Sprintf("%s query supply total %s", f.GaiacliBinary, f.Flags())
|
||||
res, errStr := tests.ExecuteT(f.T, cmd, "")
|
||||
require.Empty(f.T, errStr)
|
||||
cdc := app.MakeCodec()
|
||||
err := cdc.UnmarshalJSON([]byte(res), &totalSupply)
|
||||
require.NoError(f.T, err)
|
||||
return totalSupply
|
||||
}
|
||||
|
||||
// QueryTotalSupplyOf returns the total supply of a given coin denom
|
||||
func (f *Fixtures) QueryTotalSupplyOf(denom string, flags ...string) sdk.Int {
|
||||
cmd := fmt.Sprintf("%s query supply total %s %s", f.GaiacliBinary, denom, f.Flags())
|
||||
res, errStr := tests.ExecuteT(f.T, cmd, "")
|
||||
require.Empty(f.T, errStr)
|
||||
cdc := app.MakeCodec()
|
||||
var supplyOf sdk.Int
|
||||
err := cdc.UnmarshalJSON([]byte(res), &supplyOf)
|
||||
require.NoError(f.T, err)
|
||||
return supplyOf
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
// executors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user