fix CLI tests

This commit is contained in:
Federico Kunze 2020-04-27 13:16:18 -04:00
parent 5737f4fa19
commit 5473e9d8f4
No known key found for this signature in database
GPG Key ID: 655F93A970080A30
2 changed files with 256 additions and 234 deletions

View File

@ -12,14 +12,13 @@ import (
"path/filepath"
"strings"
"testing"
"time"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/crypto/ed25519"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/tests"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
@ -29,7 +28,7 @@ import (
"github.com/kava-labs/kava/app"
)
func TestGaiaCLIKeysAddMultisig(t *testing.T) {
func TestKavaCLIKeysAddMultisig(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
@ -52,7 +51,7 @@ func TestGaiaCLIKeysAddMultisig(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIKeysAddRecover(t *testing.T) {
func TestKavaCLIKeysAddRecover(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
@ -72,7 +71,7 @@ func TestGaiaCLIKeysAddRecover(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIKeysAddRecoverHDPath(t *testing.T) {
func TestKavaCLIKeysAddRecoverHDPath(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
@ -96,11 +95,11 @@ func TestGaiaCLIKeysAddRecoverHDPath(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIMinimumFees(t *testing.T) {
func TestKavaCLIMinimumFees(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server with minimum fees
// start kavad server with minimum fees
minGasPrice, _ := sdk.NewDecFromStr("0.000006")
fees := fmt.Sprintf(
"--minimum-gas-prices=%s,%s",
@ -134,11 +133,11 @@ func TestGaiaCLIMinimumFees(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIGasPrices(t *testing.T) {
func TestKavaCLIGasPrices(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server with minimum fees
// start kavad server with minimum fees
minGasPrice, _ := sdk.NewDecFromStr("0.000006")
proc := f.GDStart(fmt.Sprintf("--minimum-gas-prices=%s", sdk.NewDecCoinFromDec(feeDenom, minGasPrice)))
defer proc.Stop(false)
@ -168,11 +167,11 @@ func TestGaiaCLIGasPrices(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIFeesDeduction(t *testing.T) {
func TestKavaCLIFeesDeduction(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server with minimum fees
// start kavad server with minimum fees
minGasPrice, _ := sdk.NewDecFromStr("0.000006")
proc := f.GDStart(fmt.Sprintf("--minimum-gas-prices=%s", sdk.NewDecCoinFromDec(feeDenom, minGasPrice)))
defer proc.Stop(false)
@ -221,11 +220,11 @@ func TestGaiaCLIFeesDeduction(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLISend(t *testing.T) {
func TestKavaCLISend(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -258,7 +257,7 @@ func TestGaiaCLISend(t *testing.T) {
)
require.Empty(t, stderr)
require.True(t, success)
msg := unmarshalStdTx(f.T, stdout)
msg := f.unmarshalStdTx(f.T, stdout)
require.NotZero(t, msg.Fee.Gas)
require.Len(t, msg.Msgs, 1)
require.Len(t, msg.GetSignatures(), 0)
@ -290,12 +289,12 @@ func TestGaiaCLISend(t *testing.T) {
f.Cleanup()
}
// Note: this was removed from gaia due to update in sdk PR#4062 but is now working
func TestGaiaCLIConfirmTx(t *testing.T) {
// Note: this was removed from kava due to update in sdk PR#4062 but is now working
func TestKavaCLIConfirmTx(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -325,13 +324,13 @@ func TestGaiaCLIConfirmTx(t *testing.T) {
require.Equal(t, sendTokens, barAcc.GetCoins().AmountOf(denom))
}
func TestGaiaCLIGasAuto(t *testing.T) {
func TestKavaCLIGasAuto(t *testing.T) {
// https://github.com/cosmos/cosmos-sdk/pull/5179
t.Skip()
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -387,18 +386,19 @@ func TestGaiaCLIGasAuto(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLICreateValidator(t *testing.T) {
func TestKavaCLICreateValidator(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
barAddr := f.KeyAddress(keyBar)
barVal := sdk.ValAddress(barAddr)
consPubKey := sdk.MustBech32ifyConsPub(ed25519.GenPrivKey().PubKey())
consPubKey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeAccPub, ed25519.GenPrivKey().PubKey())
require.NoError(t, err)
sendTokens := sdk.TokensFromConsensusPower(10)
f.TxSend(keyFoo, barAddr, sdk.NewCoin(denom, sendTokens), "-y")
@ -412,7 +412,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
require.True(f.T, success)
require.Empty(f.T, stderr)
msg := unmarshalStdTx(f.T, stdout)
msg := f.unmarshalStdTx(f.T, stdout)
require.NotZero(t, msg.Fee.Gas)
require.Equal(t, len(msg.Msgs), 1)
require.Equal(t, 0, len(msg.GetSignatures()))
@ -460,7 +460,7 @@ func TestGaiaCLICreateValidator(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIQueryRewards(t *testing.T) {
func TestKavaCLIQueryRewards(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
cdc := app.MakeCodec()
@ -476,13 +476,13 @@ func TestGaiaCLIQueryRewards(t *testing.T) {
require.NoError(t, err)
genesisState[mint.ModuleName] = mintDataBz
genFile := filepath.Join(f.GaiadHome, "config", "genesis.json")
genFile := filepath.Join(f.KavadHome, "config", "genesis.json")
genDoc, err := tmtypes.GenesisDocFromFile(genFile)
require.NoError(t, err)
genDoc.AppState, err = cdc.MarshalJSON(genesisState)
require.NoError(t, genDoc.SaveAs(genFile))
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -493,11 +493,11 @@ func TestGaiaCLIQueryRewards(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIQuerySupply(t *testing.T) {
func TestKavaCLIQuerySupply(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -510,11 +510,11 @@ func TestGaiaCLIQuerySupply(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLISubmitProposal(t *testing.T) {
func TestKavaCLISubmitProposal(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -537,7 +537,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
fooAddr.String(), "Text", "Test", "test", sdk.NewCoin(denom, proposalTokens), "--generate-only", "-y")
require.True(t, success)
require.Empty(t, stderr)
msg := unmarshalStdTx(t, stdout)
msg := f.unmarshalStdTx(t, stdout)
require.NotZero(t, msg.Fee.Gas)
require.Equal(t, len(msg.Msgs), 1)
require.Equal(t, 0, len(msg.GetSignatures()))
@ -576,7 +576,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
success, stdout, stderr = f.TxGovDeposit(1, fooAddr.String(), sdk.NewCoin(denom, depositTokens), "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg = unmarshalStdTx(t, stdout)
msg = f.unmarshalStdTx(t, stdout)
require.NotZero(t, msg.Fee.Gas)
require.Equal(t, len(msg.Msgs), 1)
require.Equal(t, 0, len(msg.GetSignatures()))
@ -611,7 +611,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
success, stdout, stderr = f.TxGovVote(1, gov.OptionYes, fooAddr.String(), "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg = unmarshalStdTx(t, stdout)
msg = f.unmarshalStdTx(t, stdout)
require.NotZero(t, msg.Fee.Gas)
require.Equal(t, len(msg.Msgs), 1)
require.Equal(t, 0, len(msg.GetSignatures()))
@ -654,7 +654,7 @@ func TestGaiaCLISubmitProposal(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLISubmitParamChangeProposal(t *testing.T) {
func TestKavaCLISubmitParamChangeProposal(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
@ -718,7 +718,7 @@ func TestGaiaCLISubmitParamChangeProposal(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLISubmitCommunityPoolSpendProposal(t *testing.T) {
func TestKavaCLISubmitCommunityPoolSpendProposal(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
@ -735,7 +735,7 @@ func TestGaiaCLISubmitCommunityPoolSpendProposal(t *testing.T) {
require.NoError(t, err)
genesisState[mint.ModuleName] = mintDataBz
genFile := filepath.Join(f.GaiadHome, "config", "genesis.json")
genFile := filepath.Join(f.KavadHome, "config", "genesis.json")
genDoc, err := tmtypes.GenesisDocFromFile(genFile)
require.NoError(t, err)
genDoc.AppState, err = cdc.MarshalJSON(genesisState)
@ -802,11 +802,11 @@ func TestGaiaCLISubmitCommunityPoolSpendProposal(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIQueryTxPagination(t *testing.T) {
func TestKavaCLIQueryTxPagination(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -852,11 +852,11 @@ func TestGaiaCLIQueryTxPagination(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIValidateSignatures(t *testing.T) {
func TestKavaCLIValidateSignatures(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -876,7 +876,7 @@ func TestGaiaCLIValidateSignatures(t *testing.T) {
success, stdout, stderr = f.TxSign(keyFoo, unsignedTxFile.Name())
require.True(t, success)
require.Empty(t, stderr)
stdTx := unmarshalStdTx(t, stdout)
stdTx := f.unmarshalStdTx(t, stdout)
require.Equal(t, len(stdTx.Msgs), 1)
require.Equal(t, 1, len(stdTx.GetSignatures()))
require.Equal(t, fooAddr.String(), stdTx.GetSigners()[0].String())
@ -891,7 +891,7 @@ func TestGaiaCLIValidateSignatures(t *testing.T) {
// modify the transaction
stdTx.Memo = "MODIFIED-ORIGINAL-TX-BAD"
bz := marshalStdTx(t, stdTx)
bz := f.marshalStdTx(t, stdTx)
modSignedTxFile := WriteToNewTempFile(t, string(bz))
defer os.Remove(modSignedTxFile.Name())
@ -902,11 +902,11 @@ func TestGaiaCLIValidateSignatures(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
func TestKavaCLISendGenerateSignAndBroadcast(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -918,8 +918,8 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
success, stdout, stderr := f.TxSend(fooAddr.String(), barAddr, sdk.NewCoin(denom, sendTokens), "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg := unmarshalStdTx(t, stdout)
require.Equal(t, msg.Fee.Gas, uint64(client.DefaultGasLimit))
msg := f.unmarshalStdTx(t, stdout)
require.Equal(t, msg.Fee.Gas, uint64(flags.DefaultGasLimit))
require.Equal(t, len(msg.Msgs), 1)
require.Equal(t, 0, len(msg.GetSignatures()))
@ -927,7 +927,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
success, stdout, stderr = f.TxSend(fooAddr.String(), barAddr, sdk.NewCoin(denom, sendTokens), "--gas=100", "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg = unmarshalStdTx(t, stdout)
msg = f.unmarshalStdTx(t, stdout)
require.Equal(t, msg.Fee.Gas, uint64(100))
require.Equal(t, len(msg.Msgs), 1)
require.Equal(t, 0, len(msg.GetSignatures()))
@ -936,7 +936,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
success, stdout, stderr = f.TxSend(fooAddr.String(), barAddr, sdk.NewCoin(denom, sendTokens), "--generate-only")
require.True(t, success)
require.Empty(t, stderr)
msg = unmarshalStdTx(t, stdout)
msg = f.unmarshalStdTx(t, stdout)
require.True(t, msg.Fee.Gas > 0)
require.Equal(t, len(msg.Msgs), 1)
@ -952,7 +952,7 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
// Test sign
success, stdout, _ = f.TxSign(keyFoo, unsignedTxFile.Name())
require.True(t, success)
msg = unmarshalStdTx(t, stdout)
msg = f.unmarshalStdTx(t, stdout)
require.Equal(t, len(msg.Msgs), 1)
require.Equal(t, 1, len(msg.GetSignatures()))
require.Equal(t, fooAddr.String(), msg.GetSigners()[0].String())
@ -986,11 +986,11 @@ func TestGaiaCLISendGenerateSignAndBroadcast(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIMultisignInsufficientCosigners(t *testing.T) {
func TestKavaCLIMultisignInsufficientCosigners(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server with minimum fees
// start kavad server with minimum fees
proc := f.GDStart()
defer proc.Stop(false)
@ -1039,11 +1039,11 @@ func TestGaiaCLIMultisignInsufficientCosigners(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIEncode(t *testing.T) {
func TestKavaCLIEncode(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
@ -1077,11 +1077,11 @@ func TestGaiaCLIEncode(t *testing.T) {
require.Equal(t, "deadbeef", decodedTx.Memo)
}
func TestGaiaCLIMultisignSortSignatures(t *testing.T) {
func TestKavaCLIMultisignSortSignatures(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server with minimum fees
// start kavad server with minimum fees
proc := f.GDStart()
defer proc.Stop(false)
@ -1142,11 +1142,11 @@ func TestGaiaCLIMultisignSortSignatures(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIMultisign(t *testing.T) {
func TestKavaCLIMultisign(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server with minimum fees
// start kavad server with minimum fees
proc := f.GDStart()
defer proc.Stop(false)
@ -1208,7 +1208,7 @@ func TestGaiaCLIMultisign(t *testing.T) {
f.Cleanup()
}
func TestGaiaCLIConfig(t *testing.T) {
func TestKavaCLIConfig(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
node := fmt.Sprintf("%s:%s", f.RPCAddr, f.Port)
@ -1222,7 +1222,7 @@ func TestGaiaCLIConfig(t *testing.T) {
f.CLIConfig("trace", "false")
f.CLIConfig("indent", "true")
config, err := ioutil.ReadFile(path.Join(f.GaiacliHome, "config", "config.toml"))
config, err := ioutil.ReadFile(path.Join(f.KavacliHome, "config", "config.toml"))
require.NoError(t, err)
expectedConfig := fmt.Sprintf(`broadcast-mode = "block"
chain-id = "%s"
@ -1237,7 +1237,7 @@ trust-node = true
f.Cleanup()
}
func TestGaiadCollectGentxs(t *testing.T) {
func TestKavadCollectGentxs(t *testing.T) {
t.Parallel()
var customMaxBytes, customMaxGas int64 = 99999999, 1234567
f := NewFixtures(t)
@ -1285,7 +1285,7 @@ func TestGaiadCollectGentxs(t *testing.T) {
f.Cleanup(gentxDir)
}
func TestGaiadAddGenesisAccount(t *testing.T) {
func TestKavadAddGenesisAccount(t *testing.T) {
t.Parallel()
f := NewFixtures(t)
@ -1334,12 +1334,11 @@ func TestSlashingGetParams(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)
params := f.QuerySlashingParams()
require.Equal(t, time.Duration(120000000000), params.MaxEvidenceAge)
require.Equal(t, int64(100), params.SignedBlocksWindow)
require.Equal(t, sdk.NewDecWithPrec(5, 1), params.MinSignedPerWindow)
@ -1355,7 +1354,7 @@ func TestValidateGenesis(t *testing.T) {
t.Parallel()
f := InitFixtures(t)
// start gaiad server
// start kavad server
proc := f.GDStart()
defer proc.Stop(false)

View File

@ -76,15 +76,17 @@ func init() {
type Fixtures struct {
BuildDir string
RootDir string
GaiadBinary string
GaiacliBinary string
KavadBinary string
KavacliBinary string
ChainID string
RPCAddr string
Port string
GaiadHome string
GaiacliHome string
KavadHome string
KavacliHome string
P2PAddr string
T *testing.T
cdc *codec.Codec
}
// NewFixtures creates a new instance of Fixtures with many vars set
@ -104,26 +106,29 @@ func NewFixtures(t *testing.T) *Fixtures {
require.NoError(t, err)
}
cdc := app.MakeCodec()
return &Fixtures{
T: t,
BuildDir: buildDir,
RootDir: tmpDir,
GaiadBinary: filepath.Join(buildDir, "kvd"),
GaiacliBinary: filepath.Join(buildDir, "kvcli"),
GaiadHome: filepath.Join(tmpDir, ".kvd"),
GaiacliHome: filepath.Join(tmpDir, ".kvcli"),
KavadBinary: filepath.Join(buildDir, "kvd"),
KavacliBinary: filepath.Join(buildDir, "kvcli"),
KavadHome: filepath.Join(tmpDir, ".kvd"),
KavacliHome: filepath.Join(tmpDir, ".kvcli"),
RPCAddr: servAddr,
P2PAddr: p2pAddr,
Port: port,
cdc: cdc,
}
}
// GenesisFile returns the path of the genesis file
func (f Fixtures) GenesisFile() string {
return filepath.Join(f.GaiadHome, "config", "genesis.json")
return filepath.Join(f.KavadHome, "config", "genesis.json")
}
// GenesisFile returns the application's genesis state
// GenesisState returns the application's genesis state
func (f Fixtures) GenesisState() simapp.GenesisState {
cdc := codec.New()
genDoc, err := tmtypes.GenesisDocFromFile(f.GenesisFile())
@ -189,24 +194,24 @@ func (f *Fixtures) Cleanup(dirs ...string) {
// Flags returns the flags necessary for making most CLI calls
func (f *Fixtures) Flags() string {
return fmt.Sprintf("--home=%s --node=%s", f.GaiacliHome, f.RPCAddr)
return fmt.Sprintf("--home=%s --node=%s", f.KavacliHome, f.RPCAddr)
}
//___________________________________________________________________________________
// gaiad
// kavad
// UnsafeResetAll is gaiad unsafe-reset-all
// UnsafeResetAll is kavad unsafe-reset-all
func (f *Fixtures) UnsafeResetAll(flags ...string) {
cmd := fmt.Sprintf("%s --home=%s unsafe-reset-all", f.GaiadBinary, f.GaiadHome)
cmd := fmt.Sprintf("%s --home=%s unsafe-reset-all", f.KavadBinary, f.KavadHome)
executeWrite(f.T, addFlags(cmd, flags))
err := os.RemoveAll(filepath.Join(f.GaiadHome, "config", "gentx"))
err := os.RemoveAll(filepath.Join(f.KavadHome, "config", "gentx"))
require.NoError(f.T, err)
}
// GDInit is gaiad init
// GDInit is kavad init
// NOTE: GDInit sets the ChainID for the Fixtures instance
func (f *Fixtures) GDInit(moniker string, flags ...string) {
cmd := fmt.Sprintf("%s init -o --home=%s %s", f.GaiadBinary, f.GaiadHome, moniker)
cmd := fmt.Sprintf("%s init -o --home=%s %s", f.KavadBinary, f.KavadHome, moniker)
_, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
var chainID string
@ -221,78 +226,83 @@ func (f *Fixtures) GDInit(moniker string, flags ...string) {
f.ChainID = chainID
}
// AddGenesisAccount is gaiad add-genesis-account
// AddGenesisAccount is kavad add-genesis-account
func (f *Fixtures) AddGenesisAccount(address sdk.AccAddress, coins sdk.Coins, flags ...string) {
cmd := fmt.Sprintf("%s add-genesis-account %s %s --home=%s", f.GaiadBinary, address, coins, f.GaiadHome)
cmd := fmt.Sprintf("%s add-genesis-account %s %s --home=%s --keyring-backend=test", f.KavadBinary, address, coins, f.KavadHome)
executeWriteCheckErr(f.T, addFlags(cmd, flags))
}
// GenTx is gaiad gentx
// GenTx is kavad gentx
func (f *Fixtures) GenTx(name string, flags ...string) {
cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s", f.GaiadBinary, name, f.GaiadHome, f.GaiacliHome)
executeWriteCheckErr(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
cmd := fmt.Sprintf("%s gentx --name=%s --home=%s --home-client=%s --keyring-backend=test", f.KavadBinary, name, f.KavadHome, f.KavacliHome)
executeWriteCheckErr(f.T, addFlags(cmd, flags))
}
// CollectGenTxs is gaiad collect-gentxs
// CollectGenTxs is kavad collect-gentxs
func (f *Fixtures) CollectGenTxs(flags ...string) {
cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.GaiadBinary, f.GaiadHome)
executeWriteCheckErr(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.KavadBinary, f.KavadHome)
executeWriteCheckErr(f.T, addFlags(cmd, flags))
}
// GDStart runs gaiad start with the appropriate flags and returns a process
// GDStart runs kavad start with the appropriate flags and returns a process
func (f *Fixtures) GDStart(flags ...string) *tests.Process {
cmd := fmt.Sprintf("%s start --home=%s --rpc.laddr=%v --p2p.laddr=%v", f.GaiadBinary, f.GaiadHome, f.RPCAddr, f.P2PAddr)
cmd := fmt.Sprintf("%s start --home=%s --rpc.laddr=%v --p2p.laddr=%v", f.KavadBinary, f.KavadHome, f.RPCAddr, f.P2PAddr)
proc := tests.GoExecuteTWithStdout(f.T, addFlags(cmd, flags))
tests.WaitForTMStart(f.Port)
tests.WaitForNextNBlocksTM(1, f.Port)
return proc
}
// GDTendermint returns the results of gaiad tendermint [query]
// GDTendermint returns the results of kavad tendermint [query]
func (f *Fixtures) GDTendermint(query string) string {
cmd := fmt.Sprintf("%s tendermint %s --home=%s", f.GaiadBinary, query, f.GaiadHome)
cmd := fmt.Sprintf("%s tendermint %s --home=%s", f.KavadBinary, query, f.KavadHome)
success, stdout, stderr := executeWriteRetStdStreams(f.T, cmd)
require.Empty(f.T, stderr)
require.True(f.T, success)
return strings.TrimSpace(stdout)
}
// ValidateGenesis runs gaiad validate-genesis
// ValidateGenesis runs kavad validate-genesis
func (f *Fixtures) ValidateGenesis() {
cmd := fmt.Sprintf("%s validate-genesis --home=%s", f.GaiadBinary, f.GaiadHome)
cmd := fmt.Sprintf("%s validate-genesis --home=%s", f.KavadBinary, f.KavadHome)
executeWriteCheckErr(f.T, cmd)
}
//___________________________________________________________________________________
// gaiacli keys
// kavacli keys
// KeysDelete is gaiacli keys delete
// KeysDelete is kavacli keys delete
func (f *Fixtures) KeysDelete(name string, flags ...string) {
cmd := fmt.Sprintf("%s keys delete --home=%s %s", f.GaiacliBinary, f.GaiacliHome, name)
cmd := fmt.Sprintf("%s keys delete --keyring-backend=test --home=%s %s", f.KavacliBinary,
f.KavacliHome, name)
executeWrite(f.T, addFlags(cmd, append(append(flags, "-y"), "-f")))
}
// KeysAdd is gaiacli keys add
// KeysAdd is kavacli keys add
func (f *Fixtures) KeysAdd(name string, flags ...string) {
cmd := fmt.Sprintf("%s keys add --home=%s %s", f.GaiacliBinary, f.GaiacliHome, name)
executeWriteCheckErr(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s %s", f.KavacliBinary,
f.KavacliHome, name)
executeWriteCheckErr(f.T, addFlags(cmd, flags))
}
// KeysAddRecover prepares gaiacli keys add --recover
// KeysAddRecover prepares kavacli keys add --recover
func (f *Fixtures) KeysAddRecover(name, mnemonic string, flags ...string) (exitSuccess bool, stdout, stderr string) {
cmd := fmt.Sprintf("%s keys add --home=%s --recover %s", f.GaiacliBinary, f.GaiacliHome, name)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass, mnemonic)
cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s --recover %s",
f.KavacliBinary, f.KavacliHome, name)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), mnemonic)
}
// KeysAddRecoverHDPath prepares gaiacli keys add --recover --account --index
// KeysAddRecoverHDPath prepares kavacli keys add --recover --account --index
func (f *Fixtures) KeysAddRecoverHDPath(name, mnemonic string, account uint32, index uint32, flags ...string) {
cmd := fmt.Sprintf("%s keys add --home=%s --recover %s --account %d --index %d", f.GaiacliBinary, f.GaiacliHome, name, account, index)
executeWriteCheckErr(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass, mnemonic)
cmd := fmt.Sprintf("%s keys add --keyring-backend=test --home=%s --recover %s --account %d"+
" --index %d", f.KavacliBinary, f.KavacliHome, name, account, index)
executeWriteCheckErr(f.T, addFlags(cmd, flags), mnemonic)
}
// KeysShow is gaiacli keys show
// KeysShow is kavacli keys show
func (f *Fixtures) KeysShow(name string, flags ...string) keys.KeyOutput {
cmd := fmt.Sprintf("%s keys show --home=%s %s", f.GaiacliBinary, f.GaiacliHome, name)
cmd := fmt.Sprintf("%s keys show --keyring-backend=test --home=%s %s", f.KavacliBinary,
f.KavacliHome, name)
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var ko keys.KeyOutput
err := clientkeys.UnmarshalJSON([]byte(out), &ko)
@ -309,88 +319,101 @@ func (f *Fixtures) KeyAddress(name string) sdk.AccAddress {
}
//___________________________________________________________________________________
// gaiacli config
// kavacli config
// CLIConfig is gaiacli config
// CLIConfig is kavacli config
func (f *Fixtures) CLIConfig(key, value string, flags ...string) {
cmd := fmt.Sprintf("%s config --home=%s %s %s", f.GaiacliBinary, f.GaiacliHome, key, value)
cmd := fmt.Sprintf("%s config --home=%s %s %s", f.KavacliBinary, f.KavacliHome, key, value)
executeWriteCheckErr(f.T, addFlags(cmd, flags))
}
//___________________________________________________________________________________
// gaiacli tx send/sign/broadcast
// kavacli tx send/sign/broadcast
// TxSend is gaiacli tx send
// Status is kavacli status
func (f *Fixtures) Status(flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s status %s", f.KavacliBinary, f.Flags())
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
// TxSend is kavacli tx send
func (f *Fixtures) TxSend(from string, to sdk.AccAddress, amount sdk.Coin, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx send %s %s %s %v", f.GaiacliBinary, from, to, amount, f.Flags())
cmd := fmt.Sprintf("%s tx send --keyring-backend=test %s %s %s %v", f.KavacliBinary, from,
to, amount, f.Flags())
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
// TxSign is gaiacli tx sign
// TxSign is kavacli tx sign
func (f *Fixtures) TxSign(signer, fileName string, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx sign %v --from=%s %v", f.GaiacliBinary, f.Flags(), signer, fileName)
cmd := fmt.Sprintf("%s tx sign %v --keyring-backend=test --from=%s %v", f.KavacliBinary,
f.Flags(), signer, fileName)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
// TxBroadcast is gaiacli tx broadcast
// TxBroadcast is kavacli tx broadcast
func (f *Fixtures) TxBroadcast(fileName string, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx broadcast %v %v", f.GaiacliBinary, f.Flags(), fileName)
cmd := fmt.Sprintf("%s tx broadcast %v %v", f.KavacliBinary, f.Flags(), fileName)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
// TxEncode is gaiacli tx encode
// TxEncode is kavacli tx encode
func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx encode %v %v", f.GaiacliBinary, f.Flags(), fileName)
cmd := fmt.Sprintf("%s tx encode %v %v", f.KavacliBinary, f.Flags(), fileName)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
// TxMultisign is gaiacli tx multisign
// TxMultisign is kavacli tx multisign
func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string,
flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx multisign %v %s %s %s", f.GaiacliBinary, f.Flags(),
cmd := fmt.Sprintf("%s tx multisign --keyring-backend=test %v %s %s %s", f.KavacliBinary, f.Flags(),
fileName, name, strings.Join(signaturesFiles, " "),
)
return executeWriteRetStdStreams(f.T, cmd)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags))
}
//___________________________________________________________________________________
// gaiacli tx staking
// kavacli tx staking
// TxStakingCreateValidator is gaiacli tx staking create-validator
// TxStakingCreateValidator is kavacli tx staking create-validator
func (f *Fixtures) TxStakingCreateValidator(from, consPubKey string, amount sdk.Coin, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx staking create-validator %v --from=%s --pubkey=%s", f.GaiacliBinary, f.Flags(), from, consPubKey)
cmd := fmt.Sprintf("%s tx staking create-validator %v --keyring-backend=test --from=%s"+
" --pubkey=%s", f.KavacliBinary, 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")
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
// TxStakingUnbond is gaiacli tx staking unbond
// TxStakingUnbond is kavacli tx staking unbond
func (f *Fixtures) TxStakingUnbond(from, shares string, validator sdk.ValAddress, flags ...string) bool {
cmd := fmt.Sprintf("%s tx staking unbond %s %v --from=%s %v", f.GaiacliBinary, validator, shares, from, f.Flags())
cmd := fmt.Sprintf("%s tx staking unbond --keyring-backend=test %s %v --from=%s %v",
f.KavacliBinary, validator, shares, from, f.Flags())
return executeWrite(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
//___________________________________________________________________________________
// gaiacli tx gov
// kavacli tx gov
// TxGovSubmitProposal is gaiacli tx gov submit-proposal
// TxGovSubmitProposal is kavacli tx gov submit-proposal
func (f *Fixtures) TxGovSubmitProposal(from, typ, title, description string, deposit sdk.Coin, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx gov submit-proposal %v --from=%s --type=%s", f.GaiacliBinary, f.Flags(), from, typ)
cmd := fmt.Sprintf("%s tx gov submit-proposal %v --keyring-backend=test --from=%s --type=%s",
f.KavacliBinary, f.Flags(), from, typ)
cmd += fmt.Sprintf(" --title=%s --description=%s --deposit=%s", title, description, deposit)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
// TxGovDeposit is gaiacli tx gov deposit
// TxGovDeposit is kavacli tx gov deposit
func (f *Fixtures) TxGovDeposit(proposalID int, from string, amount sdk.Coin, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx gov deposit %d %s --from=%s %v", f.GaiacliBinary, proposalID, amount, from, f.Flags())
cmd := fmt.Sprintf("%s tx gov deposit %d %s --keyring-backend=test --from=%s %v",
f.KavacliBinary, proposalID, amount, from, f.Flags())
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
// TxGovVote is gaiacli tx gov vote
// TxGovVote is kavacli tx gov vote
func (f *Fixtures) TxGovVote(proposalID int, option gov.VoteOption, from string, flags ...string) (bool, string, string) {
cmd := fmt.Sprintf("%s tx gov vote %d %s --from=%s %v", f.GaiacliBinary, proposalID, option, from, f.Flags())
cmd := fmt.Sprintf("%s tx gov vote %d %s --keyring-backend=test --from=%s %v",
f.KavacliBinary, proposalID, option, from, f.Flags())
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
@ -401,8 +424,8 @@ func (f *Fixtures) TxGovSubmitParamChangeProposal(
) (bool, string, string) {
cmd := fmt.Sprintf(
"%s tx gov submit-proposal param-change %s --from=%s %v",
f.GaiacliBinary, proposalPath, from, f.Flags(),
"%s tx gov submit-proposal param-change %s --keyring-backend=test --from=%s %v",
f.KavacliBinary, proposalPath, from, f.Flags(),
)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
@ -415,19 +438,19 @@ func (f *Fixtures) TxGovSubmitCommunityPoolSpendProposal(
) (bool, string, string) {
cmd := fmt.Sprintf(
"%s tx gov submit-proposal community-pool-spend %s --from=%s %v",
f.GaiacliBinary, proposalPath, from, f.Flags(),
"%s tx gov submit-proposal community-pool-spend %s --keyring-backend=test --from=%s %v",
f.KavacliBinary, proposalPath, from, f.Flags(),
)
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), clientkeys.DefaultKeyPass)
}
//___________________________________________________________________________________
// gaiacli query account
// kavacli query account
// QueryAccount is gaiacli query account
// QueryAccount is kavacli query account
func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.BaseAccount {
cmd := fmt.Sprintf("%s query account %s %v", f.GaiacliBinary, address, f.Flags())
cmd := fmt.Sprintf("%s query account %s %v", f.KavacliBinary, address, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var initRes map[string]json.RawMessage
err := json.Unmarshal([]byte(out), &initRes)
@ -442,186 +465,186 @@ func (f *Fixtures) QueryAccount(address sdk.AccAddress, flags ...string) auth.Ba
}
//___________________________________________________________________________________
// gaiacli query txs
// kavacli query txs
// QueryTxs is gaiacli query txs
func (f *Fixtures) QueryTxs(page, limit int, tags ...string) *sdk.SearchTxsResult {
cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --tags='%s' %v", f.GaiacliBinary, page, limit, queryTags(tags), f.Flags())
// QueryTxs is kavacli query txs
func (f *Fixtures) QueryTxs(page, limit int, events ...string) *sdk.SearchTxsResult {
cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.KavacliBinary, page, limit, queryEvents(events), f.Flags())
out, _ := tests.ExecuteT(f.T, cmd, "")
var result sdk.SearchTxsResult
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &result)
err := f.cdc.UnmarshalJSON([]byte(out), &result)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return &result
}
// QueryTxsInvalid query txs with wrong parameters and compare expected error
func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, tags ...string) {
cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --tags='%s' %v", f.GaiacliBinary, page, limit, queryTags(tags), f.Flags())
func (f *Fixtures) QueryTxsInvalid(expectedErr error, page, limit int, events ...string) {
cmd := fmt.Sprintf("%s query txs --page=%d --limit=%d --events='%s' %v", f.KavacliBinary, page, limit, queryEvents(events), f.Flags())
_, err := tests.ExecuteT(f.T, cmd, "")
require.EqualError(f.T, expectedErr, err)
}
//___________________________________________________________________________________
// gaiacli query staking
// kavacli query staking
// QueryStakingValidator is gaiacli query staking validator
// QueryStakingValidator is kavacli query staking validator
func (f *Fixtures) QueryStakingValidator(valAddr sdk.ValAddress, flags ...string) staking.Validator {
cmd := fmt.Sprintf("%s query staking validator %s %v", f.GaiacliBinary, valAddr, f.Flags())
cmd := fmt.Sprintf("%s query staking validator %s %v", f.KavacliBinary, valAddr, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var validator staking.Validator
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &validator)
err := f.cdc.UnmarshalJSON([]byte(out), &validator)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return validator
}
// QueryStakingUnbondingDelegationsFrom is gaiacli query staking unbonding-delegations-from
// QueryStakingUnbondingDelegationsFrom is kavacli query staking unbonding-delegations-from
func (f *Fixtures) QueryStakingUnbondingDelegationsFrom(valAddr sdk.ValAddress, flags ...string) []staking.UnbondingDelegation {
cmd := fmt.Sprintf("%s query staking unbonding-delegations-from %s %v", f.GaiacliBinary, valAddr, f.Flags())
cmd := fmt.Sprintf("%s query staking unbonding-delegations-from %s %v", f.KavacliBinary, valAddr, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var ubds []staking.UnbondingDelegation
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &ubds)
err := f.cdc.UnmarshalJSON([]byte(out), &ubds)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return ubds
}
// QueryStakingDelegationsTo is gaiacli query staking delegations-to
// QueryStakingDelegationsTo is kavacli query staking delegations-to
func (f *Fixtures) QueryStakingDelegationsTo(valAddr sdk.ValAddress, flags ...string) []staking.Delegation {
cmd := fmt.Sprintf("%s query staking delegations-to %s %v", f.GaiacliBinary, valAddr, f.Flags())
cmd := fmt.Sprintf("%s query staking delegations-to %s %v", f.KavacliBinary, valAddr, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var delegations []staking.Delegation
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &delegations)
err := f.cdc.UnmarshalJSON([]byte(out), &delegations)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return delegations
}
// QueryStakingPool is gaiacli query staking pool
// QueryStakingPool is kavacli query staking pool
func (f *Fixtures) QueryStakingPool(flags ...string) staking.Pool {
cmd := fmt.Sprintf("%s query staking pool %v", f.GaiacliBinary, f.Flags())
cmd := fmt.Sprintf("%s query staking pool %v", f.KavacliBinary, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var pool staking.Pool
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &pool)
err := f.cdc.UnmarshalJSON([]byte(out), &pool)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return pool
}
// QueryStakingParameters is gaiacli query staking parameters
// QueryStakingParameters is kavacli query staking parameters
func (f *Fixtures) QueryStakingParameters(flags ...string) staking.Params {
cmd := fmt.Sprintf("%s query staking params %v", f.GaiacliBinary, f.Flags())
cmd := fmt.Sprintf("%s query staking params %v", f.KavacliBinary, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var params staking.Params
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &params)
err := f.cdc.UnmarshalJSON([]byte(out), &params)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return params
}
//___________________________________________________________________________________
// gaiacli query gov
// kavacli query gov
// QueryGovParamDeposit is gaiacli query gov param deposit
// QueryGovParamDeposit is kavacli query gov param deposit
func (f *Fixtures) QueryGovParamDeposit() gov.DepositParams {
cmd := fmt.Sprintf("%s query gov param deposit %s", f.GaiacliBinary, f.Flags())
cmd := fmt.Sprintf("%s query gov param deposit %s", f.KavacliBinary, f.Flags())
out, _ := tests.ExecuteT(f.T, cmd, "")
var depositParam gov.DepositParams
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &depositParam)
err := f.cdc.UnmarshalJSON([]byte(out), &depositParam)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return depositParam
}
// QueryGovParamVoting is gaiacli query gov param voting
// QueryGovParamVoting is kavacli query gov param voting
func (f *Fixtures) QueryGovParamVoting() gov.VotingParams {
cmd := fmt.Sprintf("%s query gov param voting %s", f.GaiacliBinary, f.Flags())
cmd := fmt.Sprintf("%s query gov param voting %s", f.KavacliBinary, f.Flags())
out, _ := tests.ExecuteT(f.T, cmd, "")
var votingParam gov.VotingParams
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &votingParam)
err := f.cdc.UnmarshalJSON([]byte(out), &votingParam)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return votingParam
}
// QueryGovParamTallying is gaiacli query gov param tallying
// QueryGovParamTallying is kavacli query gov param tallying
func (f *Fixtures) QueryGovParamTallying() gov.TallyParams {
cmd := fmt.Sprintf("%s query gov param tallying %s", f.GaiacliBinary, f.Flags())
cmd := fmt.Sprintf("%s query gov param tallying %s", f.KavacliBinary, f.Flags())
out, _ := tests.ExecuteT(f.T, cmd, "")
var tallyingParam gov.TallyParams
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &tallyingParam)
err := f.cdc.UnmarshalJSON([]byte(out), &tallyingParam)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return tallyingParam
}
// QueryGovProposals is gaiacli query gov proposals
// QueryGovProposals is kavacli query gov proposals
func (f *Fixtures) QueryGovProposals(flags ...string) gov.Proposals {
cmd := fmt.Sprintf("%s query gov proposals %v", f.GaiacliBinary, f.Flags())
cmd := fmt.Sprintf("%s query gov proposals %v", f.KavacliBinary, f.Flags())
stdout, stderr := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
if strings.Contains(stderr, "no matching proposals found") {
return gov.Proposals{}
}
require.Empty(f.T, stderr)
var out gov.Proposals
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(stdout), &out)
err := f.cdc.UnmarshalJSON([]byte(stdout), &out)
require.NoError(f.T, err)
return out
}
// QueryGovProposal is gaiacli query gov proposal
// QueryGovProposal is kavacli query gov proposal
func (f *Fixtures) QueryGovProposal(proposalID int, flags ...string) gov.Proposal {
cmd := fmt.Sprintf("%s query gov proposal %d %v", f.GaiacliBinary, proposalID, f.Flags())
cmd := fmt.Sprintf("%s query gov proposal %d %v", f.KavacliBinary, proposalID, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var proposal gov.Proposal
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &proposal)
err := f.cdc.UnmarshalJSON([]byte(out), &proposal)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return proposal
}
// QueryGovVote is gaiacli query gov vote
// QueryGovVote is kavacli query gov vote
func (f *Fixtures) QueryGovVote(proposalID int, voter sdk.AccAddress, flags ...string) gov.Vote {
cmd := fmt.Sprintf("%s query gov vote %d %s %v", f.GaiacliBinary, proposalID, voter, f.Flags())
cmd := fmt.Sprintf("%s query gov vote %d %s %v", f.KavacliBinary, proposalID, voter, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var vote gov.Vote
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &vote)
err := f.cdc.UnmarshalJSON([]byte(out), &vote)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return vote
}
// QueryGovVotes is gaiacli query gov votes
// QueryGovVotes is kavacli query gov votes
func (f *Fixtures) QueryGovVotes(proposalID int, flags ...string) []gov.Vote {
cmd := fmt.Sprintf("%s query gov votes %d %v", f.GaiacliBinary, proposalID, f.Flags())
cmd := fmt.Sprintf("%s query gov votes %d %v", f.KavacliBinary, proposalID, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var votes []gov.Vote
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &votes)
err := f.cdc.UnmarshalJSON([]byte(out), &votes)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return votes
}
// QueryGovDeposit is gaiacli query gov deposit
// QueryGovDeposit is kavacli query gov deposit
func (f *Fixtures) QueryGovDeposit(proposalID int, depositor sdk.AccAddress, flags ...string) gov.Deposit {
cmd := fmt.Sprintf("%s query gov deposit %d %s %v", f.GaiacliBinary, proposalID, depositor, f.Flags())
cmd := fmt.Sprintf("%s query gov deposit %d %s %v", f.KavacliBinary, proposalID, depositor, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var deposit gov.Deposit
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &deposit)
err := f.cdc.UnmarshalJSON([]byte(out), &deposit)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return deposit
}
// QueryGovDeposits is gaiacli query gov deposits
// QueryGovDeposits is kavacli query gov deposits
func (f *Fixtures) QueryGovDeposits(propsalID int, flags ...string) []gov.Deposit {
cmd := fmt.Sprintf("%s query gov deposits %d %v", f.GaiacliBinary, propsalID, f.Flags())
cmd := fmt.Sprintf("%s query gov deposits %d %v", f.KavacliBinary, propsalID, f.Flags())
out, _ := tests.ExecuteT(f.T, addFlags(cmd, flags), "")
var deposits []gov.Deposit
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(out), &deposits)
err := f.cdc.UnmarshalJSON([]byte(out), &deposits)
require.NoError(f.T, err, "out %v\n, err %v", out, err)
return deposits
}
@ -631,24 +654,24 @@ 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("%s query slashing signing-info %s %s", f.GaiacliBinary, val, f.Flags())
cmd := fmt.Sprintf("%s query slashing signing-info %s %s", f.KavacliBinary, val, f.Flags())
res, errStr := tests.ExecuteT(f.T, cmd, "")
require.Empty(f.T, errStr)
cdc := app.MakeCodec()
var sinfo slashing.ValidatorSigningInfo
err := cdc.UnmarshalJSON([]byte(res), &sinfo)
err := f.cdc.UnmarshalJSON([]byte(res), &sinfo)
require.NoError(f.T, err)
return sinfo
}
// QuerySlashingParams is gaiacli query slashing params
// QuerySlashingParams is kavacli query slashing params
func (f *Fixtures) QuerySlashingParams() slashing.Params {
cmd := fmt.Sprintf("%s query slashing params %s", f.GaiacliBinary, f.Flags())
cmd := fmt.Sprintf("%s query slashing params %s", f.KavacliBinary, f.Flags())
res, errStr := tests.ExecuteT(f.T, cmd, "")
require.Empty(f.T, errStr)
cdc := app.MakeCodec()
var params slashing.Params
err := cdc.UnmarshalJSON([]byte(res), &params)
err := f.cdc.UnmarshalJSON([]byte(res), &params)
require.NoError(f.T, err)
return params
}
@ -658,12 +681,12 @@ func (f *Fixtures) QuerySlashingParams() slashing.Params {
// QueryRewards returns the rewards of a delegator
func (f *Fixtures) QueryRewards(delAddr sdk.AccAddress, flags ...string) distribution.QueryDelegatorTotalRewardsResponse {
cmd := fmt.Sprintf("%s query distribution rewards %s %s", f.GaiacliBinary, delAddr, f.Flags())
cmd := fmt.Sprintf("%s query distribution rewards %s %s", f.KavacliBinary, delAddr, f.Flags())
res, errStr := tests.ExecuteT(f.T, cmd, "")
require.Empty(f.T, errStr)
cdc := app.MakeCodec()
var rewards distribution.QueryDelegatorTotalRewardsResponse
err := cdc.UnmarshalJSON([]byte(res), &rewards)
err := f.cdc.UnmarshalJSON([]byte(res), &rewards)
require.NoError(f.T, err)
return rewards
}
@ -673,23 +696,23 @@ func (f *Fixtures) QueryRewards(delAddr sdk.AccAddress, flags ...string) distrib
// 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())
cmd := fmt.Sprintf("%s query bank total %s", f.KavacliBinary, f.Flags())
res, errStr := tests.ExecuteT(f.T, cmd, "")
require.Empty(f.T, errStr)
cdc := app.MakeCodec()
err := cdc.UnmarshalJSON([]byte(res), &totalSupply)
err := f.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())
cmd := fmt.Sprintf("%s query bank total %s %s", f.KavacliBinary, 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)
err := f.cdc.UnmarshalJSON([]byte(res), &supplyOf)
require.NoError(f.T, err)
return supplyOf
}
@ -746,9 +769,9 @@ func addFlags(cmd string, flags []string) string {
return strings.TrimSpace(cmd)
}
func queryTags(tags []string) (out string) {
for _, tag := range tags {
out += tag + "&"
func queryEvents(events []string) (out string) {
for _, event := range events {
out += event + "&"
}
return strings.TrimSuffix(out, "&")
}
@ -762,15 +785,15 @@ func WriteToNewTempFile(t *testing.T, s string) *os.File {
return fp
}
func marshalStdTx(t *testing.T, stdTx auth.StdTx) []byte {
cdc := app.MakeCodec()
bz, err := cdc.MarshalBinaryBare(stdTx)
//nolint:deadcode,unused
func (f *Fixtures) marshalStdTx(t *testing.T, stdTx auth.StdTx) []byte {
bz, err := f.cdc.MarshalBinaryBare(stdTx)
require.NoError(t, err)
return bz
}
func unmarshalStdTx(t *testing.T, s string) (stdTx auth.StdTx) {
cdc := app.MakeCodec()
require.Nil(t, cdc.UnmarshalJSON([]byte(s), &stdTx))
//nolint:deadcode,unused
func (f *Fixtures) unmarshalStdTx(t *testing.T, s string) (stdTx auth.StdTx) {
require.Nil(t, f.cdc.UnmarshalJSON([]byte(s), &stdTx))
return
}