Drop on-disk keybase in favor of keyring (#164)
* Port to new keyring * modify add-genesis-account to use keyring * Adapt lcd tests to use keyring * Attempt to fix localnet ci job * Revert "Attempt to fix localnet ci job" This reverts commit c299dd9ffb2a77a1f3b9b33bb71ef104261ed1fc. * Try pass env var to docker container * localnet does need COSMOS_SDK_TEST_KEYRING to function properly * Revert tiny change * Simplify tests * Refresh against sdk's respective branch latest commit * Refresh against sdk branch's latest commit * Attempt to reduce diff size * Refresh against latest commit * Update against latest commit * Refresh against sdk's latest master * Avoid create temporary keybase * Revert "Avoid create temporary keybase" This reverts commit c3f6d77f373370fea521edabe60c532c676cd9a6. * Update docs * Remove unnecessary arguments * Remove unnecessary arguments * Code cleanup * Refresh sdk module, add upgrade module * Refresh deps * Fix merge * Cleanup, AddrSeed does not need Password anymore
This commit is contained in:
committed by
Federico Kunze
parent
967fc43f1a
commit
71f3b4f0fc
3
Makefile
3
Makefile
@@ -7,6 +7,7 @@ LEDGER_ENABLED ?= true
|
|||||||
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
|
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
|
||||||
|
|
||||||
export GO111MODULE = on
|
export GO111MODULE = on
|
||||||
|
export COSMOS_SDK_TEST_KEYRING = y
|
||||||
|
|
||||||
# process build tags
|
# process build tags
|
||||||
|
|
||||||
@@ -157,7 +158,7 @@ build-docker-gaiadnode:
|
|||||||
|
|
||||||
# Run a 4-node testnet locally
|
# Run a 4-node testnet locally
|
||||||
localnet-start: build-linux localnet-stop
|
localnet-start: build-linux localnet-stop
|
||||||
@if ! [ -f build/node0/gaiad/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/gaiad:Z tendermint/gaiadnode testnet --v 4 -o . --starting-ip-address 192.168.10.2 ; fi
|
@if ! [ -f build/node0/gaiad/config/genesis.json ]; then docker run -e COSMOS_SDK_TEST_KEYRING=y --rm -v $(CURDIR)/build:/gaiad:Z tendermint/gaiadnode testnet --v 4 -o . --starting-ip-address 192.168.10.2 ; fi
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
|
|
||||||
# Stop testnet
|
# Stop testnet
|
||||||
|
|||||||
@@ -828,9 +828,8 @@ func TestGaiaCLIValidateSignatures(t *testing.T) {
|
|||||||
defer os.Remove(unsignedTxFile.Name())
|
defer os.Remove(unsignedTxFile.Name())
|
||||||
|
|
||||||
// validate we can successfully sign
|
// validate we can successfully sign
|
||||||
success, stdout, stderr = f.TxSign(keyFoo, unsignedTxFile.Name())
|
success, stdout, _ = f.TxSign(keyFoo, unsignedTxFile.Name())
|
||||||
require.True(t, success)
|
require.True(t, success)
|
||||||
require.Empty(t, stderr)
|
|
||||||
stdTx := unmarshalStdTx(t, stdout)
|
stdTx := unmarshalStdTx(t, stdout)
|
||||||
require.Equal(t, len(stdTx.Msgs), 1)
|
require.Equal(t, len(stdTx.Msgs), 1)
|
||||||
require.Equal(t, 1, len(stdTx.GetSignatures()))
|
require.Equal(t, 1, len(stdTx.GetSignatures()))
|
||||||
|
|||||||
@@ -226,13 +226,13 @@ func (f *Fixtures) AddGenesisAccount(address sdk.AccAddress, coins sdk.Coins, fl
|
|||||||
// GenTx is gaiad gentx
|
// GenTx is gaiad gentx
|
||||||
func (f *Fixtures) GenTx(name string, flags ...string) {
|
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)
|
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), client.DefaultKeyPass)
|
executeWriteCheckErr(f.T, addFlags(cmd, flags))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CollectGenTxs is gaiad collect-gentxs
|
// CollectGenTxs is gaiad collect-gentxs
|
||||||
func (f *Fixtures) CollectGenTxs(flags ...string) {
|
func (f *Fixtures) CollectGenTxs(flags ...string) {
|
||||||
cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.GaiadBinary, f.GaiadHome)
|
cmd := fmt.Sprintf("%s collect-gentxs --home=%s", f.GaiadBinary, f.GaiadHome)
|
||||||
executeWriteCheckErr(f.T, addFlags(cmd, flags), client.DefaultKeyPass)
|
executeWriteCheckErr(f.T, addFlags(cmd, flags))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GDStart runs gaiad start with the appropriate flags and returns a process
|
// GDStart runs gaiad start with the appropriate flags and returns a process
|
||||||
@@ -271,19 +271,19 @@ func (f *Fixtures) KeysDelete(name string, flags ...string) {
|
|||||||
// KeysAdd is gaiacli keys add
|
// KeysAdd is gaiacli keys add
|
||||||
func (f *Fixtures) KeysAdd(name string, flags ...string) {
|
func (f *Fixtures) KeysAdd(name string, flags ...string) {
|
||||||
cmd := fmt.Sprintf("%s keys add --home=%s %s", f.GaiacliBinary, f.GaiacliHome, name)
|
cmd := fmt.Sprintf("%s keys add --home=%s %s", f.GaiacliBinary, f.GaiacliHome, name)
|
||||||
executeWriteCheckErr(f.T, addFlags(cmd, flags), client.DefaultKeyPass)
|
executeWriteCheckErr(f.T, addFlags(cmd, flags))
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeysAddRecover prepares gaiacli keys add --recover
|
// KeysAddRecover prepares gaiacli keys add --recover
|
||||||
func (f *Fixtures) KeysAddRecover(name, mnemonic string, flags ...string) (exitSuccess bool, stdout, stderr string) {
|
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)
|
cmd := fmt.Sprintf("%s keys add --home=%s --recover %s", f.GaiacliBinary, f.GaiacliHome, name)
|
||||||
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), client.DefaultKeyPass, mnemonic)
|
return executeWriteRetStdStreams(f.T, addFlags(cmd, flags), mnemonic)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeysAddRecoverHDPath prepares gaiacli keys add --recover --account --index
|
// KeysAddRecoverHDPath prepares gaiacli keys add --recover --account --index
|
||||||
func (f *Fixtures) KeysAddRecoverHDPath(name, mnemonic string, account uint32, index uint32, flags ...string) {
|
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)
|
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), client.DefaultKeyPass, mnemonic)
|
executeWriteCheckErr(f.T, addFlags(cmd, flags), mnemonic)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeysShow is gaiacli keys show
|
// KeysShow is gaiacli keys show
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ func main() {
|
|||||||
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
|
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
|
||||||
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
|
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
|
||||||
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
|
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
|
||||||
|
config.SetKeyringServiceName("gaia")
|
||||||
config.Seal()
|
config.Seal()
|
||||||
|
|
||||||
// TODO: setup keybase, viper object, etc. to be passed into
|
// TODO: setup keybase, viper object, etc. to be passed into
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
@@ -40,14 +41,15 @@ the address will be looked up in the local Keybase. The list of initial tokens m
|
|||||||
contain valid denominations. Accounts may optionally be supplied with vesting parameters.
|
contain valid denominations. Accounts may optionally be supplied with vesting parameters.
|
||||||
`,
|
`,
|
||||||
Args: cobra.ExactArgs(2),
|
Args: cobra.ExactArgs(2),
|
||||||
RunE: func(_ *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
config := ctx.Config
|
config := ctx.Config
|
||||||
config.SetRoot(viper.GetString(cli.HomeFlag))
|
config.SetRoot(viper.GetString(cli.HomeFlag))
|
||||||
|
|
||||||
addr, err := sdk.AccAddressFromBech32(args[0])
|
addr, err := sdk.AccAddressFromBech32(args[0])
|
||||||
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// attempt to lookup address from Keybase if no address was provided
|
// attempt to lookup address from Keybase if no address was provided
|
||||||
kb, err := keys.NewKeyBaseFromDir(viper.GetString(flagClientHome))
|
kb, err := keys.NewKeyringFromDir(viper.GetString(flagClientHome), inBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ func main() {
|
|||||||
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
|
config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub)
|
||||||
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
|
config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub)
|
||||||
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
|
config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub)
|
||||||
|
config.SetKeyringServiceName("gaia")
|
||||||
config.Seal()
|
config.Seal()
|
||||||
|
|
||||||
ctx := server.NewDefaultContext()
|
ctx := server.NewDefaultContext()
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ func InitTestnet(cmd *cobra.Command, config *tmconfig.Config, cdc *codec.Codec,
|
|||||||
genFiles []string
|
genFiles []string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
inBuf := bufio.NewReader(cmd.InOrStdin())
|
||||||
// generate private keys, node IDs, and initial transactions
|
// generate private keys, node IDs, and initial transactions
|
||||||
for i := 0; i < numValidators; i++ {
|
for i := 0; i < numValidators; i++ {
|
||||||
nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i)
|
nodeDirName := fmt.Sprintf("%s%d", nodeDirPrefix, i)
|
||||||
@@ -157,24 +158,13 @@ func InitTestnet(cmd *cobra.Command, config *tmconfig.Config, cdc *codec.Codec,
|
|||||||
memo := fmt.Sprintf("%s@%s:26656", nodeIDs[i], ip)
|
memo := fmt.Sprintf("%s@%s:26656", nodeIDs[i], ip)
|
||||||
genFiles = append(genFiles, config.GenesisFile())
|
genFiles = append(genFiles, config.GenesisFile())
|
||||||
|
|
||||||
buf := bufio.NewReader(cmd.InOrStdin())
|
kb, err := keys.NewKeyringFromDir(clientDir, inBuf)
|
||||||
prompt := fmt.Sprintf(
|
if err != nil {
|
||||||
"Password for account '%s' (default %s):", nodeDirName, client.DefaultKeyPass,
|
|
||||||
)
|
|
||||||
|
|
||||||
keyPass, err := client.GetPassword(prompt, buf)
|
|
||||||
if err != nil && keyPass != "" {
|
|
||||||
// An error was returned that either failed to read the password from
|
|
||||||
// STDIN or the given password is not empty but failed to meet minimum
|
|
||||||
// length requirements.
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if keyPass == "" {
|
keyPass := client.DefaultKeyPass
|
||||||
keyPass = client.DefaultKeyPass
|
addr, secret, err := server.GenerateSaveCoinKey(kb, nodeDirName, keyPass, true)
|
||||||
}
|
|
||||||
|
|
||||||
addr, secret, err := server.GenerateSaveCoinKey(clientDir, nodeDirName, keyPass, true)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = os.RemoveAll(outputDir)
|
_ = os.RemoveAll(outputDir)
|
||||||
return err
|
return err
|
||||||
@@ -210,13 +200,8 @@ func InitTestnet(cmd *cobra.Command, config *tmconfig.Config, cdc *codec.Codec,
|
|||||||
sdk.OneInt(),
|
sdk.OneInt(),
|
||||||
)
|
)
|
||||||
|
|
||||||
kb, err := keys.NewKeyBaseFromDir(clientDir)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
tx := auth.NewStdTx([]sdk.Msg{msg}, auth.StdFee{}, []auth.StdSignature{}, memo)
|
tx := auth.NewStdTx([]sdk.Msg{msg}, auth.StdFee{}, []auth.StdSignature{}, memo)
|
||||||
txBldr := auth.NewTxBuilderFromCLI().WithChainID(chainID).WithMemo(memo).WithKeybase(kb)
|
txBldr := auth.NewTxBuilderFromCLI(inBuf).WithChainID(chainID).WithMemo(memo).WithKeybase(kb)
|
||||||
|
|
||||||
signedTx, err := txBldr.SignStdTx(nodeDirName, client.DefaultKeyPass, tx, false)
|
signedTx, err := txBldr.SignStdTx(nodeDirName, client.DefaultKeyPass, tx, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -150,11 +150,20 @@ To restore an account using a fundraiser mnemonic and store the associated encry
|
|||||||
gaiacli keys add <yourKeyName> --recover
|
gaiacli keys add <yourKeyName> --recover
|
||||||
```
|
```
|
||||||
|
|
||||||
You will be prompted to input a passphrase that is used to encrypt the private key of account `0` on disk. Each time you want to send a transaction, this password will be required. If you lose the password, you can always recover the private key with the mnemonic.
|
|
||||||
|
|
||||||
- `<yourKeyName>` is the name of the account. It is a reference to the account number used to derive the key pair from the mnemonic. You will use this name to identify your account when you want to send a transaction.
|
- `<yourKeyName>` is the name of the account. It is a reference to the account number used to derive the key pair from the mnemonic. You will use this name to identify your account when you want to send a transaction.
|
||||||
- You can add the optional `--account` flag to specify the path (`0`, `1`, `2`, ...) you want to use to generate your account. By default, account `0` is generated.
|
- You can add the optional `--account` flag to specify the path (`0`, `1`, `2`, ...) you want to use to generate your account. By default, account `0` is generated.
|
||||||
|
|
||||||
|
The private key of account `0` will be saved in your operating system's credentials storage.
|
||||||
|
Each time you want to send a transaction, you will need to unlock your system's credentials store.
|
||||||
|
If you lose access to your credentials storage, you can always recover the private key with the
|
||||||
|
mnemonic.
|
||||||
|
|
||||||
|
::: tip
|
||||||
|
**You may not be prompted for password each time you send a transaction since most operating systems
|
||||||
|
unlock user's credentials store upon login by default. If you want to change your credentials
|
||||||
|
store security policies please refer to your operating system manual.**
|
||||||
|
:::
|
||||||
|
|
||||||
### Creating an Account
|
### Creating an Account
|
||||||
|
|
||||||
To create an account, you just need to have `gaiacli` installed. Before creating it, you need to know where you intend to store and interact with your private keys. The best options are to store them in an offline dedicated computer or a ledger device. Storing them on your regular online computer involves more risk, since anyone who infiltrates your computer through the internet could exfiltrate your private keys and steal your funds.
|
To create an account, you just need to have `gaiacli` installed. Before creating it, you need to know where you intend to store and interact with your private keys. The best options are to store them in an offline dedicated computer or a ledger device. Storing them on your regular online computer involves more risk, since anyone who infiltrates your computer through the internet could exfiltrate your private keys and steal your funds.
|
||||||
@@ -197,7 +206,17 @@ To generate an account, just use the following command:
|
|||||||
gaiacli keys add <yourKeyName>
|
gaiacli keys add <yourKeyName>
|
||||||
```
|
```
|
||||||
|
|
||||||
The command will generate a 24-words mnemonic and save the private and public keys for account `0` at the same time. You will be prompted to input a passphrase that is used to encrypt the private key of account `0` on disk. Each time you want to send a transaction, this password will be required. If you lose the password, you can always recover the private key with the mnemonic.
|
The command will generate a 24-words mnemonic and save the private and public keys for account `0`
|
||||||
|
at the same time.
|
||||||
|
Each time you want to send a transaction, you will need to unlock your system's credentials store.
|
||||||
|
If you lose access to your credentials storage, you can always recover the private key with the
|
||||||
|
mnemonic.
|
||||||
|
|
||||||
|
::: tip
|
||||||
|
**You may not be prompted for password each time you send a transaction since most operating systems
|
||||||
|
unlock user's credentials store upon login by default. If you want to change your credentials
|
||||||
|
store security policies please refer to your operating system manual.**
|
||||||
|
:::
|
||||||
|
|
||||||
::: danger
|
::: danger
|
||||||
**Do not lose or share your 12 words with anyone. To prevent theft or loss of funds, it is best to ensure that you keep multiple copies of your mnemonic, and store it in a safe, secure place and that only you know how to access. If someone is able to gain access to your mnemonic, they will be able to gain access to your private keys and control the accounts associated with them.**
|
**Do not lose or share your 12 words with anyone. To prevent theft or loss of funds, it is best to ensure that you keep multiple copies of your mnemonic, and store it in a safe, secure place and that only you know how to access. If someone is able to gain access to your mnemonic, they will be able to gain access to your private keys and control the accounts associated with them.**
|
||||||
|
|||||||
@@ -62,6 +62,19 @@ There are three types of key representations that are used:
|
|||||||
- Get this value with `gaiad tendermint show-validator`
|
- Get this value with `gaiad tendermint show-validator`
|
||||||
- e.g. `cosmosvalconspub1zcjduepq0ms2738680y72v44tfyqm3c9ppduku8fs6sr73fx7m666sjztznqzp2emf`
|
- e.g. `cosmosvalconspub1zcjduepq0ms2738680y72v44tfyqm3c9ppduku8fs6sr73fx7m666sjztznqzp2emf`
|
||||||
|
|
||||||
|
#### Migrate Keys From Legacy On-Disk Keybase To OS Built-in Secret Store
|
||||||
|
|
||||||
|
Older versions of `gaiacli` used store keys in the user's home directory. If you are migrating
|
||||||
|
from an old version of `gaiacli` you will need to migrate your old keys into your operating system's
|
||||||
|
credentials storage by running the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
gaiacli keys migrate
|
||||||
|
```
|
||||||
|
|
||||||
|
The command will prompt for every passphrase. If a passphrase is incorrect, it will skip the
|
||||||
|
respective key.
|
||||||
|
|
||||||
#### Generate Keys
|
#### Generate Keys
|
||||||
|
|
||||||
You'll need an account private and public key pair \(a.k.a. `sk, pk` respectively\) to be able to receive funds, send txs, bond tx, etc.
|
You'll need an account private and public key pair \(a.k.a. `sk, pk` respectively\) to be able to receive funds, send txs, bond tx, etc.
|
||||||
@@ -72,10 +85,10 @@ To generate a new _secp256k1_ key:
|
|||||||
gaiacli keys add <account_name>
|
gaiacli keys add <account_name>
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, you will have to create a passphrase to protect the key on disk. The output of the above
|
The output of the above command will contain a _seed phrase_. It is recommended to save the _seed
|
||||||
command will contain a _seed phrase_. It is recommended to save the _seed phrase_ in a safe
|
phrase_ in a safe place so that in case you forget the password of the operating system's
|
||||||
place so that in case you forget the password, you could eventually regenerate the key from
|
credentials store, you could eventually regenerate the key from the seed phrase with the
|
||||||
the seed phrase with the following command:
|
following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
gaiacli keys add --recover
|
gaiacli keys add --recover
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -4,7 +4,7 @@ go 1.13
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect
|
github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect
|
||||||
github.com/cosmos/cosmos-sdk v0.34.4-0.20191108144056-d81d46192a0c
|
github.com/cosmos/cosmos-sdk v0.34.4-0.20191114141721-d4c831e63ad3
|
||||||
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d // indirect
|
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d // indirect
|
||||||
github.com/golang/mock v1.3.1 // indirect
|
github.com/golang/mock v1.3.1 // indirect
|
||||||
github.com/onsi/ginkgo v1.8.0 // indirect
|
github.com/onsi/ginkgo v1.8.0 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -40,8 +40,8 @@ github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8Nz
|
|||||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
github.com/cosmos/cosmos-sdk v0.34.4-0.20191108144056-d81d46192a0c h1:XYIUjgiFabdbRTvhqeY9Dc7k95bvFbgC47mv/Dk13S8=
|
github.com/cosmos/cosmos-sdk v0.34.4-0.20191114141721-d4c831e63ad3 h1:vjzTX8arh3cEAHSbxazdRRLS67Gl4JoNY6tcNyjqmms=
|
||||||
github.com/cosmos/cosmos-sdk v0.34.4-0.20191108144056-d81d46192a0c/go.mod h1:0sLtjU+qex1OfpGQHjWhJByx74IoH78R742PEAdoQJk=
|
github.com/cosmos/cosmos-sdk v0.34.4-0.20191114141721-d4c831e63ad3/go.mod h1:0sLtjU+qex1OfpGQHjWhJByx74IoH78R742PEAdoQJk=
|
||||||
github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
|
github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
|
||||||
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
|
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
|
||||||
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
|
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
|
||||||
|
|||||||
@@ -371,19 +371,19 @@ func init() {
|
|||||||
|
|
||||||
// CreateAddr adds an address to the key store and returns an address and seed.
|
// CreateAddr adds an address to the key store and returns an address and seed.
|
||||||
// It also requires that the key could be created.
|
// It also requires that the key could be created.
|
||||||
func CreateAddr(name, password string, kb crkeys.Keybase) (sdk.AccAddress, string, error) {
|
func CreateAddr(name string, kb crkeys.Keybase) (sdk.AccAddress, string, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
info crkeys.Info
|
info crkeys.Info
|
||||||
seed string
|
seed string
|
||||||
)
|
)
|
||||||
info, seed, err = kb.CreateMnemonic(name, crkeys.English, password, crkeys.Secp256k1)
|
info, seed, err = kb.CreateMnemonic(name, crkeys.English, client.DefaultKeyPass, crkeys.Secp256k1)
|
||||||
return sdk.AccAddress(info.GetPubKey().Address()), seed, err
|
return sdk.AccAddress(info.GetPubKey().Address()), seed, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateAddr adds multiple address to the key store and returns the addresses and associated seeds in lexographical order by address.
|
// CreateAddr adds multiple address to the key store and returns the addresses and associated seeds in lexographical order by address.
|
||||||
// It also requires that the keys could be created.
|
// It also requires that the keys could be created.
|
||||||
func CreateAddrs(kb crkeys.Keybase, numAddrs int) (addrs []sdk.AccAddress, seeds, names, passwords []string, errs []error) {
|
func CreateAddrs(kb crkeys.Keybase, numAddrs int) (addrs []sdk.AccAddress, seeds, names []string, errs []error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
info crkeys.Info
|
info crkeys.Info
|
||||||
@@ -394,12 +394,11 @@ func CreateAddrs(kb crkeys.Keybase, numAddrs int) (addrs []sdk.AccAddress, seeds
|
|||||||
|
|
||||||
for i := 0; i < numAddrs; i++ {
|
for i := 0; i < numAddrs; i++ {
|
||||||
name := fmt.Sprintf("test%d", i)
|
name := fmt.Sprintf("test%d", i)
|
||||||
password := "1234567890"
|
info, seed, err = kb.CreateMnemonic(name, crkeys.English, client.DefaultKeyPass, crkeys.Secp256k1)
|
||||||
info, seed, err = kb.CreateMnemonic(name, crkeys.English, password, crkeys.Secp256k1)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
addrSeeds = append(addrSeeds, AddrSeed{Address: sdk.AccAddress(info.GetPubKey().Address()), Seed: seed, Name: name, Password: password})
|
addrSeeds = append(addrSeeds, AddrSeed{Address: sdk.AccAddress(info.GetPubKey().Address()), Seed: seed, Name: name})
|
||||||
}
|
}
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return
|
return
|
||||||
@@ -411,10 +410,9 @@ func CreateAddrs(kb crkeys.Keybase, numAddrs int) (addrs []sdk.AccAddress, seeds
|
|||||||
addrs = append(addrs, addrSeeds[i].Address)
|
addrs = append(addrs, addrSeeds[i].Address)
|
||||||
seeds = append(seeds, addrSeeds[i].Seed)
|
seeds = append(seeds, addrSeeds[i].Seed)
|
||||||
names = append(names, addrSeeds[i].Name)
|
names = append(names, addrSeeds[i].Name)
|
||||||
passwords = append(passwords, addrSeeds[i].Password)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return addrs, seeds, names, passwords, errs
|
return addrs, seeds, names, errs
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddrSeed combines an Address with the mnemonic of the private key to that address
|
// AddrSeed combines an Address with the mnemonic of the private key to that address
|
||||||
@@ -422,7 +420,6 @@ type AddrSeed struct {
|
|||||||
Address sdk.AccAddress
|
Address sdk.AccAddress
|
||||||
Seed string
|
Seed string
|
||||||
Name string
|
Name string
|
||||||
Password string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddrSeedSlice implements `Interface` in sort package.
|
// AddrSeedSlice implements `Interface` in sort package.
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
clientkeys "github.com/cosmos/cosmos-sdk/client/keys"
|
||||||
"github.com/cosmos/cosmos-sdk/client/rpc"
|
"github.com/cosmos/cosmos-sdk/client/rpc"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
"github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||||
crkeys "github.com/cosmos/cosmos-sdk/crypto/keys"
|
crkeys "github.com/cosmos/cosmos-sdk/crypto/keys"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
@@ -213,61 +211,6 @@ func doKeysPost(t *testing.T, port, name, password, mnemonic string, account int
|
|||||||
return resp
|
return resp
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /keys/seed Create a new seed to create a new account defaultValidFor
|
|
||||||
func getKeysSeed(t *testing.T, port string) string {
|
|
||||||
res, body := Request(t, port, "GET", "/keys/seed", nil)
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
|
||||||
reg := regexp.MustCompile(`([a-z]+ ){12}`)
|
|
||||||
match := reg.MatchString(body)
|
|
||||||
require.True(t, match, "Returned seed has wrong format", body)
|
|
||||||
|
|
||||||
return body
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST /keys/{name}/recove Recover a account from a seed
|
|
||||||
func doRecoverKey(t *testing.T, port, recoverName, recoverPassword, mnemonic string, account uint32, index uint32) {
|
|
||||||
pk := clientkeys.NewRecoverKey(recoverPassword, mnemonic, int(account), int(index))
|
|
||||||
req, err := cdc.MarshalJSON(pk)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
res, body := Request(t, port, "POST", fmt.Sprintf("/keys/%s/recover", recoverName), req)
|
|
||||||
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
|
||||||
var resp keys.KeyOutput
|
|
||||||
err = codec.Cdc.UnmarshalJSON([]byte(body), &resp)
|
|
||||||
require.Nil(t, err, body)
|
|
||||||
|
|
||||||
addr1Bech32 := resp.Address
|
|
||||||
_, err = sdk.AccAddressFromBech32(addr1Bech32)
|
|
||||||
require.NoError(t, err, "Failed to return a correct bech32 address")
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET /keys/{name} Get a certain locally stored account
|
|
||||||
func getKey(t *testing.T, port, name string) keys.KeyOutput {
|
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/keys/%s", name), nil)
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
|
||||||
var resp keys.KeyOutput
|
|
||||||
err := cdc.UnmarshalJSON([]byte(body), &resp)
|
|
||||||
require.Nil(t, err)
|
|
||||||
|
|
||||||
return resp
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT /keys/{name} Update the password for this account in the KMS
|
|
||||||
func updateKey(t *testing.T, port, name, oldPassword, newPassword string, fail bool) {
|
|
||||||
kr := clientkeys.NewUpdateKeyReq(oldPassword, newPassword)
|
|
||||||
req, err := cdc.MarshalJSON(kr)
|
|
||||||
require.NoError(t, err)
|
|
||||||
keyEndpoint := fmt.Sprintf("/keys/%s", name)
|
|
||||||
res, body := Request(t, port, "PUT", keyEndpoint, req)
|
|
||||||
if fail {
|
|
||||||
require.Equal(t, http.StatusUnauthorized, res.StatusCode, body)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET /auth/accounts/{address} Get the account information on blockchain
|
// GET /auth/accounts/{address} Get the account information on blockchain
|
||||||
func getAccount(t *testing.T, port string, addr sdk.AccAddress) (acc authexported.Account) {
|
func getAccount(t *testing.T, port string, addr sdk.AccAddress) (acc authexported.Account) {
|
||||||
res, body := Request(t, port, "GET", fmt.Sprintf("/auth/accounts/%s", addr.String()), nil)
|
res, body := Request(t, port, "GET", fmt.Sprintf("/auth/accounts/%s", addr.String()), nil)
|
||||||
@@ -294,12 +237,11 @@ func doBroadcast(t *testing.T, port string, tx auth.StdTx) (*http.Response, stri
|
|||||||
// doTransfer performs a balance transfer with auto gas calculation. It also signs
|
// doTransfer performs a balance transfer with auto gas calculation. It also signs
|
||||||
// the tx and broadcasts it.
|
// the tx and broadcasts it.
|
||||||
func doTransfer(
|
func doTransfer(
|
||||||
t *testing.T, port, seed, name, memo, pwd string, addr sdk.AccAddress, fees sdk.Coins,
|
t *testing.T, port, name, memo string, addr sdk.AccAddress, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) (sdk.AccAddress, sdk.TxResponse) {
|
) (sdk.AccAddress, sdk.TxResponse) {
|
||||||
|
|
||||||
resp, body, recvAddr := doTransferWithGas(
|
resp, body, recvAddr := doTransferWithGas(t, port, name, memo, addr, "", 1.0, false, true, fees, kb)
|
||||||
t, port, seed, name, memo, pwd, addr, "", 1.0, false, true, fees,
|
|
||||||
)
|
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -314,14 +256,15 @@ func doTransfer(
|
|||||||
// signed and broadcasted. The sending account's number and sequence are
|
// signed and broadcasted. The sending account's number and sequence are
|
||||||
// determined prior to generating the tx.
|
// determined prior to generating the tx.
|
||||||
func doTransferWithGas(
|
func doTransferWithGas(
|
||||||
t *testing.T, port, seed, name, memo, pwd string, addr sdk.AccAddress,
|
t *testing.T, port, name, memo string, addr sdk.AccAddress,
|
||||||
gas string, gasAdjustment float64, simulate, broadcast bool, fees sdk.Coins,
|
gas string, gasAdjustment float64, simulate, broadcast bool, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) (resp *http.Response, body string, receiveAddr sdk.AccAddress) {
|
) (resp *http.Response, body string, receiveAddr sdk.AccAddress) {
|
||||||
|
|
||||||
// create receive address
|
// create receive address
|
||||||
kb := crkeys.NewInMemory()
|
kb2 := crkeys.NewInMemory()
|
||||||
|
|
||||||
receiveInfo, _, err := kb.CreateMnemonic(
|
receiveInfo, _, err := kb2.CreateMnemonic(
|
||||||
"receive_address", crkeys.English, client.DefaultKeyPass, crkeys.SigningAlgo("secp256k1"),
|
"receive_address", crkeys.English, client.DefaultKeyPass, crkeys.SigningAlgo("secp256k1"),
|
||||||
)
|
)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -352,7 +295,7 @@ func doTransferWithGas(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sign and broadcast
|
// sign and broadcast
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, gasAdjustment, simulate)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, gasAdjustment, simulate, kb)
|
||||||
return resp, body, receiveAddr
|
return resp, body, receiveAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,15 +303,16 @@ func doTransferWithGas(
|
|||||||
// automatically determines the account's number and sequence when generating the
|
// automatically determines the account's number and sequence when generating the
|
||||||
// tx.
|
// tx.
|
||||||
func doTransferWithGasAccAuto(
|
func doTransferWithGasAccAuto(
|
||||||
t *testing.T, port, seed, name, memo, pwd string, addr sdk.AccAddress,
|
t *testing.T, port, name, memo string, addr sdk.AccAddress,
|
||||||
gas string, gasAdjustment float64, simulate, broadcast bool, fees sdk.Coins,
|
gas string, gasAdjustment float64, simulate, broadcast bool, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) (resp *http.Response, body string, receiveAddr sdk.AccAddress) {
|
) (resp *http.Response, body string, receiveAddr sdk.AccAddress) {
|
||||||
|
|
||||||
// create receive address
|
// create receive address
|
||||||
kb := crkeys.NewInMemory()
|
kb2 := crkeys.NewInMemory()
|
||||||
acc := getAccount(t, port, addr)
|
acc := getAccount(t, port, addr)
|
||||||
|
|
||||||
receiveInfo, _, err := kb.CreateMnemonic(
|
receiveInfo, _, err := kb2.CreateMnemonic(
|
||||||
"receive_address", crkeys.English, client.DefaultKeyPass, crkeys.SigningAlgo("secp256k1"),
|
"receive_address", crkeys.English, client.DefaultKeyPass, crkeys.SigningAlgo("secp256k1"),
|
||||||
)
|
)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
@@ -395,14 +339,15 @@ func doTransferWithGasAccAuto(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sign and broadcast
|
// sign and broadcast
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, gasAdjustment, simulate)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, gasAdjustment, simulate, kb)
|
||||||
return resp, body, receiveAddr
|
return resp, body, receiveAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
// signAndBroadcastGenTx accepts a successfully generated unsigned tx, signs it,
|
// signAndBroadcastGenTx accepts a successfully generated unsigned tx, signs it,
|
||||||
// and broadcasts it.
|
// and broadcasts it.
|
||||||
func signAndBroadcastGenTx(
|
func signAndBroadcastGenTx(
|
||||||
t *testing.T, port, name, pwd, genTx string, acc authexported.Account, gasAdjustment float64, simulate bool,
|
t *testing.T, port, name, genTx string, acc authexported.Account,
|
||||||
|
gasAdjustment float64, simulate bool, kb crkeys.Keybase,
|
||||||
) (resp *http.Response, body string) {
|
) (resp *http.Response, body string) {
|
||||||
|
|
||||||
chainID := viper.GetString(client.FlagChainID)
|
chainID := viper.GetString(client.FlagChainID)
|
||||||
@@ -422,9 +367,9 @@ func signAndBroadcastGenTx(
|
|||||||
tx.Memo,
|
tx.Memo,
|
||||||
tx.Fee.Amount,
|
tx.Fee.Amount,
|
||||||
nil,
|
nil,
|
||||||
)
|
).WithKeybase(kb)
|
||||||
|
|
||||||
signedTx, err := txbldr.SignStdTx(name, pwd, tx, false)
|
signedTx, err := txbldr.SignStdTx(name, client.DefaultKeyPass, tx, false)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return doBroadcast(t, port, signedTx)
|
return doBroadcast(t, port, signedTx)
|
||||||
@@ -436,8 +381,9 @@ func signAndBroadcastGenTx(
|
|||||||
|
|
||||||
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
|
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
|
||||||
func doDelegate(
|
func doDelegate(
|
||||||
t *testing.T, port, name, pwd string, delAddr sdk.AccAddress,
|
t *testing.T, port, name string, delAddr sdk.AccAddress,
|
||||||
valAddr sdk.ValAddress, amount sdk.Int, fees sdk.Coins,
|
valAddr sdk.ValAddress, amount sdk.Int, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
acc := getAccount(t, port, delAddr)
|
acc := getAccount(t, port, delAddr)
|
||||||
@@ -461,7 +407,7 @@ func doDelegate(
|
|||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
// sign and broadcast
|
// sign and broadcast
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, kb)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -473,8 +419,9 @@ func doDelegate(
|
|||||||
|
|
||||||
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
|
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
|
||||||
func doUndelegate(
|
func doUndelegate(
|
||||||
t *testing.T, port, name, pwd string, delAddr sdk.AccAddress,
|
t *testing.T, port, name string, delAddr sdk.AccAddress,
|
||||||
valAddr sdk.ValAddress, amount sdk.Int, fees sdk.Coins,
|
valAddr sdk.ValAddress, amount sdk.Int, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
acc := getAccount(t, port, delAddr)
|
acc := getAccount(t, port, delAddr)
|
||||||
@@ -497,7 +444,7 @@ func doUndelegate(
|
|||||||
resp, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/unbonding_delegations", delAddr), req)
|
resp, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/unbonding_delegations", delAddr), req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, kb)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -509,8 +456,9 @@ func doUndelegate(
|
|||||||
|
|
||||||
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
|
// POST /staking/delegators/{delegatorAddr}/delegations Submit delegation
|
||||||
func doBeginRedelegation(
|
func doBeginRedelegation(
|
||||||
t *testing.T, port, name, pwd string, delAddr sdk.AccAddress, valSrcAddr,
|
t *testing.T, port, name string, delAddr sdk.AccAddress, valSrcAddr,
|
||||||
valDstAddr sdk.ValAddress, amount sdk.Int, fees sdk.Coins,
|
valDstAddr sdk.ValAddress, amount sdk.Int, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
acc := getAccount(t, port, delAddr)
|
acc := getAccount(t, port, delAddr)
|
||||||
@@ -534,7 +482,7 @@ func doBeginRedelegation(
|
|||||||
resp, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/redelegations", delAddr), req)
|
resp, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/redelegations", delAddr), req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, kb)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -722,8 +670,9 @@ func getValidatorUnbondingDelegations(t *testing.T, port string, validatorAddr s
|
|||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// POST /gov/proposals Submit a proposal
|
// POST /gov/proposals Submit a proposal
|
||||||
func doSubmitProposal(
|
func doSubmitProposal(
|
||||||
t *testing.T, port, seed, name, pwd string, proposerAddr sdk.AccAddress,
|
t *testing.T, port, name string, proposerAddr sdk.AccAddress,
|
||||||
amount sdk.Int, fees sdk.Coins,
|
amount sdk.Int, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
acc := getAccount(t, port, proposerAddr)
|
acc := getAccount(t, port, proposerAddr)
|
||||||
@@ -749,7 +698,7 @@ func doSubmitProposal(
|
|||||||
resp, body := Request(t, port, "POST", "/gov/proposals", req)
|
resp, body := Request(t, port, "POST", "/gov/proposals", req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, kb)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -760,8 +709,9 @@ func doSubmitProposal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doSubmitParamChangeProposal(
|
func doSubmitParamChangeProposal(
|
||||||
t *testing.T, port, seed, name, pwd string, proposerAddr sdk.AccAddress,
|
t *testing.T, port, name string, proposerAddr sdk.AccAddress,
|
||||||
amount sdk.Int, fees sdk.Coins,
|
amount sdk.Int, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
acc := getAccount(t, port, proposerAddr)
|
acc := getAccount(t, port, proposerAddr)
|
||||||
@@ -788,7 +738,7 @@ func doSubmitParamChangeProposal(
|
|||||||
resp, body := Request(t, port, "POST", "/gov/proposals/param_change", req)
|
resp, body := Request(t, port, "POST", "/gov/proposals/param_change", req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, kb)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -799,8 +749,9 @@ func doSubmitParamChangeProposal(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doSubmitCommunityPoolSpendProposal(
|
func doSubmitCommunityPoolSpendProposal(
|
||||||
t *testing.T, port, seed, name, pwd string, proposerAddr sdk.AccAddress,
|
t *testing.T, port, name string, proposerAddr sdk.AccAddress,
|
||||||
amount sdk.Int, fees sdk.Coins,
|
amount sdk.Int, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
acc := getAccount(t, port, proposerAddr)
|
acc := getAccount(t, port, proposerAddr)
|
||||||
@@ -826,7 +777,7 @@ func doSubmitCommunityPoolSpendProposal(
|
|||||||
resp, body := Request(t, port, "POST", "/gov/proposals/community_pool_spend", req)
|
resp, body := Request(t, port, "POST", "/gov/proposals/community_pool_spend", req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, kb)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -893,8 +844,9 @@ func getProposalsFilterStatus(t *testing.T, port string, status gov.ProposalStat
|
|||||||
|
|
||||||
// POST /gov/proposals/{proposalId}/deposits Deposit tokens to a proposal
|
// POST /gov/proposals/{proposalId}/deposits Deposit tokens to a proposal
|
||||||
func doDeposit(
|
func doDeposit(
|
||||||
t *testing.T, port, seed, name, pwd string, proposerAddr sdk.AccAddress,
|
t *testing.T, port, name string, proposerAddr sdk.AccAddress,
|
||||||
proposalID uint64, amount sdk.Int, fees sdk.Coins,
|
proposalID uint64, amount sdk.Int, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
acc := getAccount(t, port, proposerAddr)
|
acc := getAccount(t, port, proposerAddr)
|
||||||
@@ -916,7 +868,7 @@ func doDeposit(
|
|||||||
resp, body := Request(t, port, "POST", fmt.Sprintf("/gov/proposals/%d/deposits", proposalID), req)
|
resp, body := Request(t, port, "POST", fmt.Sprintf("/gov/proposals/%d/deposits", proposalID), req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, kb)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -950,8 +902,9 @@ func getTally(t *testing.T, port string, proposalID uint64) gov.TallyResult {
|
|||||||
|
|
||||||
// POST /gov/proposals/{proposalId}/votes Vote a proposal
|
// POST /gov/proposals/{proposalId}/votes Vote a proposal
|
||||||
func doVote(
|
func doVote(
|
||||||
t *testing.T, port, seed, name, pwd string, proposerAddr sdk.AccAddress,
|
t *testing.T, port, name string, proposerAddr sdk.AccAddress,
|
||||||
proposalID uint64, option string, fees sdk.Coins,
|
proposalID uint64, option string, fees sdk.Coins,
|
||||||
|
kb crkeys.Keybase,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
// get the account to get the sequence
|
// get the account to get the sequence
|
||||||
@@ -974,7 +927,7 @@ func doVote(
|
|||||||
resp, body := Request(t, port, "POST", fmt.Sprintf("/gov/proposals/%d/votes", proposalID), req)
|
resp, body := Request(t, port, "POST", fmt.Sprintf("/gov/proposals/%d/votes", proposalID), req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, kb)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -1109,7 +1062,7 @@ func getSigningInfoList(t *testing.T, port string) []slashing.ValidatorSigningIn
|
|||||||
// TODO: Test this functionality, it is not currently in any of the tests
|
// TODO: Test this functionality, it is not currently in any of the tests
|
||||||
// POST /slashing/validators/{validatorAddr}/unjail Unjail a jailed validator
|
// POST /slashing/validators/{validatorAddr}/unjail Unjail a jailed validator
|
||||||
func doUnjail(
|
func doUnjail(
|
||||||
t *testing.T, port, seed, name, pwd string, valAddr sdk.ValAddress, fees sdk.Coins,
|
t *testing.T, port, name string, valAddr sdk.ValAddress, fees sdk.Coins,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
|
|
||||||
acc := getAccount(t, port, sdk.AccAddress(valAddr.Bytes()))
|
acc := getAccount(t, port, sdk.AccAddress(valAddr.Bytes()))
|
||||||
@@ -1126,7 +1079,7 @@ func doUnjail(
|
|||||||
resp, body := Request(t, port, "POST", fmt.Sprintf("/slashing/validators/%s/unjail", valAddr.String()), req)
|
resp, body := Request(t, port, "POST", fmt.Sprintf("/slashing/validators/%s/unjail", valAddr.String()), req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, nil)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -1140,7 +1093,7 @@ func doUnjail(
|
|||||||
|
|
||||||
// POST /distribution/delegators/{delgatorAddr}/rewards Withdraw delegator rewards
|
// POST /distribution/delegators/{delgatorAddr}/rewards Withdraw delegator rewards
|
||||||
func doWithdrawDelegatorAllRewards(
|
func doWithdrawDelegatorAllRewards(
|
||||||
t *testing.T, port, seed, name, pwd string, delegatorAddr sdk.AccAddress, fees sdk.Coins,
|
t *testing.T, port, name string, delegatorAddr sdk.AccAddress, fees sdk.Coins,
|
||||||
) sdk.TxResponse {
|
) sdk.TxResponse {
|
||||||
// get the account to get the sequence
|
// get the account to get the sequence
|
||||||
acc := getAccount(t, port, delegatorAddr)
|
acc := getAccount(t, port, delegatorAddr)
|
||||||
@@ -1159,7 +1112,7 @@ func doWithdrawDelegatorAllRewards(
|
|||||||
resp, body := Request(t, port, "POST", fmt.Sprintf("/distribution/delegators/%s/rewards", delegatorAddr), req)
|
resp, body := Request(t, port, "POST", fmt.Sprintf("/distribution/delegators/%s/rewards", delegatorAddr), req)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
resp, body = signAndBroadcastGenTx(t, port, name, pwd, body, acc, client.DefaultGasAdjustment, false)
|
resp, body = signAndBroadcastGenTx(t, port, name, body, acc, client.DefaultGasAdjustment, false, nil)
|
||||||
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
require.Equal(t, http.StatusOK, resp.StatusCode, body)
|
||||||
|
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ import (
|
|||||||
const (
|
const (
|
||||||
name1 = "test1"
|
name1 = "test1"
|
||||||
memo = "LCD test tx"
|
memo = "LCD test tx"
|
||||||
pw = client.DefaultKeyPass
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var fees = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)}
|
var fees = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 5)}
|
||||||
@@ -45,6 +44,11 @@ func init() {
|
|||||||
version.Version = os.Getenv("VERSION")
|
version.Version = os.Getenv("VERSION")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
os.Setenv("COSMOS_SDK_TEST_KEYRING", "y")
|
||||||
|
os.Exit(m.Run())
|
||||||
|
}
|
||||||
|
|
||||||
func TestNodeStatus(t *testing.T) {
|
func TestNodeStatus(t *testing.T) {
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -74,9 +78,9 @@ func TestValidators(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCoinSend(t *testing.T) {
|
func TestCoinSend(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -94,7 +98,7 @@ func TestCoinSend(t *testing.T) {
|
|||||||
initialBalance := acc.GetCoins()
|
initialBalance := acc.GetCoins()
|
||||||
|
|
||||||
// create TX
|
// create TX
|
||||||
receiveAddr, resultTx := doTransfer(t, port, seed, name1, memo, pw, addr, fees)
|
receiveAddr, resultTx := doTransfer(t, port, name1, memo, addr, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
@@ -116,30 +120,28 @@ func TestCoinSend(t *testing.T) {
|
|||||||
require.Equal(t, int64(1), coins2[0].Amount.Int64())
|
require.Equal(t, int64(1), coins2[0].Amount.Int64())
|
||||||
|
|
||||||
// test failure with too little gas
|
// test failure with too little gas
|
||||||
res, body, _ = doTransferWithGas(t, port, seed, name1, memo, pw, addr, "100", 0, false, true, fees)
|
res, body, _ = doTransferWithGas(t, port, name1, memo, addr, "100", 0, false, true, fees, kb)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
// test failure with negative gas
|
// test failure with negative gas
|
||||||
res, body, _ = doTransferWithGas(t, port, seed, name1, memo, pw, addr, "-200", 0, false, false, fees)
|
res, body, _ = doTransferWithGas(t, port, name1, memo, addr, "-200", 0, false, false, fees, kb)
|
||||||
require.Equal(t, http.StatusBadRequest, res.StatusCode, body)
|
require.Equal(t, http.StatusBadRequest, res.StatusCode, body)
|
||||||
|
|
||||||
// test failure with negative adjustment
|
// test failure with negative adjustment
|
||||||
res, body, _ = doTransferWithGas(t, port, seed, name1, memo, pw, addr, "10000", -0.1, true, false, fees)
|
res, body, _ = doTransferWithGas(t, port, name1, memo, addr, "10000", -0.1, true, false, fees, kb)
|
||||||
require.Equal(t, http.StatusBadRequest, res.StatusCode, body)
|
require.Equal(t, http.StatusBadRequest, res.StatusCode, body)
|
||||||
|
|
||||||
// test failure with 0 gas
|
// test failure with 0 gas
|
||||||
res, body, _ = doTransferWithGas(t, port, seed, name1, memo, pw, addr, "0", 0, false, true, fees)
|
res, body, _ = doTransferWithGas(t, port, name1, memo, addr, "0", 0, false, true, fees, kb)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
// test failure with wrong adjustment
|
// test failure with wrong adjustment
|
||||||
res, body, _ = doTransferWithGas(t, port, seed, name1, memo, pw, addr, client.GasFlagAuto, 0.1, false, true, fees)
|
res, body, _ = doTransferWithGas(t, port, name1, memo, addr, client.GasFlagAuto, 0.1, false, true, fees, kb)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
// run simulation and test success with estimated gas
|
// run simulation and test success with estimated gas
|
||||||
res, body, _ = doTransferWithGas(
|
res, body, _ = doTransferWithGas(t, port, name1, memo, addr, "10000", 1.0, true, false, fees, kb)
|
||||||
t, port, seed, name1, memo, pw, addr, "10000", 1.0, true, false, fees,
|
|
||||||
)
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var gasEstResp rest.GasEstimateResponse
|
var gasEstResp rest.GasEstimateResponse
|
||||||
@@ -151,7 +153,7 @@ func TestCoinSend(t *testing.T) {
|
|||||||
|
|
||||||
// run successful tx
|
// run successful tx
|
||||||
gas := fmt.Sprintf("%d", gasEstResp.GasEstimate)
|
gas := fmt.Sprintf("%d", gasEstResp.GasEstimate)
|
||||||
res, body, _ = doTransferWithGas(t, port, seed, name1, memo, pw, addr, gas, 1.0, false, true, fees)
|
res, body, _ = doTransferWithGas(t, port, name1, memo, addr, gas, 1.0, false, true, fees, kb)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
err = cdc.UnmarshalJSON([]byte(body), &resultTx)
|
err = cdc.UnmarshalJSON([]byte(body), &resultTx)
|
||||||
@@ -166,9 +168,9 @@ func TestCoinSend(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCoinSendAccAuto(t *testing.T) {
|
func TestCoinSendAccAuto(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -179,7 +181,7 @@ func TestCoinSendAccAuto(t *testing.T) {
|
|||||||
|
|
||||||
// send a transfer tx without specifying account number and sequence
|
// send a transfer tx without specifying account number and sequence
|
||||||
res, body, _ := doTransferWithGasAccAuto(
|
res, body, _ := doTransferWithGasAccAuto(
|
||||||
t, port, seed, name1, memo, pw, addr, "200000", 1.0, false, true, fees,
|
t, port, name1, memo, addr, "200000", 1.0, false, true, fees, kb,
|
||||||
)
|
)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
@@ -193,16 +195,16 @@ func TestCoinSendAccAuto(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCoinMultiSendGenerateOnly(t *testing.T) {
|
func TestCoinMultiSendGenerateOnly(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
// generate only
|
// generate only
|
||||||
res, body, _ := doTransferWithGas(t, port, seed, "", memo, "", addr, "200000", 1, false, false, fees)
|
res, body, _ := doTransferWithGas(t, port, "", memo, addr, "200000", 1, false, false, fees, kb)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var stdTx auth.StdTx
|
var stdTx auth.StdTx
|
||||||
@@ -218,9 +220,9 @@ func TestCoinMultiSendGenerateOnly(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {
|
func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -228,9 +230,7 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {
|
|||||||
acc := getAccount(t, port, addr)
|
acc := getAccount(t, port, addr)
|
||||||
|
|
||||||
// simulate tx
|
// simulate tx
|
||||||
res, body, _ := doTransferWithGas(
|
res, body, _ := doTransferWithGas(t, port, name1, memo, addr, client.GasFlagAuto, 1.0, true, false, fees, kb)
|
||||||
t, port, seed, name1, memo, "", addr, client.GasFlagAuto, 1.0, true, false, fees,
|
|
||||||
)
|
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var gasEstResp rest.GasEstimateResponse
|
var gasEstResp rest.GasEstimateResponse
|
||||||
@@ -239,7 +239,7 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {
|
|||||||
|
|
||||||
// generate tx
|
// generate tx
|
||||||
gas := fmt.Sprintf("%d", gasEstResp.GasEstimate)
|
gas := fmt.Sprintf("%d", gasEstResp.GasEstimate)
|
||||||
res, body, _ = doTransferWithGas(t, port, seed, name1, memo, "", addr, gas, 1, false, false, fees)
|
res, body, _ = doTransferWithGas(t, port, name1, memo, addr, gas, 1, false, false, fees, kb)
|
||||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||||
|
|
||||||
var tx auth.StdTx
|
var tx auth.StdTx
|
||||||
@@ -252,7 +252,7 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {
|
|||||||
require.NotZero(t, tx.Fee.Gas)
|
require.NotZero(t, tx.Fee.Gas)
|
||||||
|
|
||||||
gasEstimate := int64(tx.Fee.Gas)
|
gasEstimate := int64(tx.Fee.Gas)
|
||||||
_, body = signAndBroadcastGenTx(t, port, name1, pw, body, acc, 1.0, false)
|
_, body = signAndBroadcastGenTx(t, port, name1, body, acc, 1.0, false, kb)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
var txResp sdk.TxResponse
|
var txResp sdk.TxResponse
|
||||||
@@ -262,15 +262,15 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEncodeTx(t *testing.T) {
|
func TestEncodeTx(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
_, body, _ := doTransferWithGas(t, port, seed, name1, memo, "", addr, "2", 1, false, false, fees)
|
_, body, _ := doTransferWithGas(t, port, name1, memo, addr, "2", 1, false, false, fees, kb)
|
||||||
var tx auth.StdTx
|
var tx auth.StdTx
|
||||||
require.Nil(t, cdc.UnmarshalJSON([]byte(body), &tx))
|
require.Nil(t, cdc.UnmarshalJSON([]byte(body), &tx))
|
||||||
|
|
||||||
@@ -298,9 +298,9 @@ func TestEncodeTx(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTxs(t *testing.T) {
|
func TestTxs(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -322,7 +322,7 @@ func TestTxs(t *testing.T) {
|
|||||||
require.Equal(t, emptyTxs, txResult.Txs)
|
require.Equal(t, emptyTxs, txResult.Txs)
|
||||||
|
|
||||||
// create tx
|
// create tx
|
||||||
receiveAddr, resultTx := doTransfer(t, port, seed, name1, memo, pw, addr, fees)
|
receiveAddr, resultTx := doTransfer(t, port, name1, memo, addr, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx is queryable
|
// check if tx is queryable
|
||||||
@@ -384,9 +384,9 @@ func TestValidatorQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBonding(t *testing.T) {
|
func TestBonding(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, _, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cleanup, valPubKeys, operAddrs, port, err := InitializeLCD(2, []sdk.AccAddress{addr}, false)
|
cleanup, valPubKeys, operAddrs, port, err := InitializeLCD(2, []sdk.AccAddress{addr}, false)
|
||||||
@@ -406,7 +406,7 @@ func TestBonding(t *testing.T) {
|
|||||||
|
|
||||||
// create bond TX
|
// create bond TX
|
||||||
delTokens := sdk.TokensFromConsensusPower(60)
|
delTokens := sdk.TokensFromConsensusPower(60)
|
||||||
resultTx := doDelegate(t, port, name1, pw, addr, operAddrs[0], delTokens, fees)
|
resultTx := doDelegate(t, port, name1, addr, operAddrs[0], delTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
require.Equal(t, uint32(0), resultTx.Code)
|
require.Equal(t, uint32(0), resultTx.Code)
|
||||||
@@ -448,7 +448,7 @@ func TestBonding(t *testing.T) {
|
|||||||
|
|
||||||
// testing unbonding
|
// testing unbonding
|
||||||
unbondingTokens := sdk.TokensFromConsensusPower(30)
|
unbondingTokens := sdk.TokensFromConsensusPower(30)
|
||||||
resultTx = doUndelegate(t, port, name1, pw, addr, operAddrs[0], unbondingTokens, fees)
|
resultTx = doUndelegate(t, port, name1, addr, operAddrs[0], unbondingTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
require.Equal(t, uint32(0), resultTx.Code)
|
require.Equal(t, uint32(0), resultTx.Code)
|
||||||
@@ -478,7 +478,7 @@ func TestBonding(t *testing.T) {
|
|||||||
|
|
||||||
// test redelegation
|
// test redelegation
|
||||||
rdTokens := sdk.TokensFromConsensusPower(30)
|
rdTokens := sdk.TokensFromConsensusPower(30)
|
||||||
resultTx = doBeginRedelegation(t, port, name1, pw, addr, operAddrs[0], operAddrs[1], rdTokens, fees)
|
resultTx = doBeginRedelegation(t, port, name1, addr, operAddrs[0], operAddrs[1], rdTokens, fees, kb)
|
||||||
require.Equal(t, uint32(0), resultTx.Code)
|
require.Equal(t, uint32(0), resultTx.Code)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
@@ -549,9 +549,9 @@ func TestBonding(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSubmitProposal(t *testing.T) {
|
func TestSubmitProposal(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -562,7 +562,7 @@ func TestSubmitProposal(t *testing.T) {
|
|||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
proposalTokens := sdk.TokensFromConsensusPower(5)
|
proposalTokens := sdk.TokensFromConsensusPower(5)
|
||||||
resultTx := doSubmitProposal(t, port, seed, name1, pw, addr, proposalTokens, fees)
|
resultTx := doSubmitProposal(t, port, name1, addr, proposalTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
@@ -587,9 +587,9 @@ func TestSubmitProposal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSubmitCommunityPoolSpendProposal(t *testing.T) {
|
func TestSubmitCommunityPoolSpendProposal(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -600,7 +600,7 @@ func TestSubmitCommunityPoolSpendProposal(t *testing.T) {
|
|||||||
|
|
||||||
// create proposal tx
|
// create proposal tx
|
||||||
proposalTokens := sdk.TokensFromConsensusPower(5)
|
proposalTokens := sdk.TokensFromConsensusPower(5)
|
||||||
resultTx := doSubmitCommunityPoolSpendProposal(t, port, seed, name1, pw, addr, proposalTokens, fees)
|
resultTx := doSubmitCommunityPoolSpendProposal(t, port, name1, addr, proposalTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
@@ -625,9 +625,9 @@ func TestSubmitCommunityPoolSpendProposal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSubmitParamChangeProposal(t *testing.T) {
|
func TestSubmitParamChangeProposal(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -638,7 +638,7 @@ func TestSubmitParamChangeProposal(t *testing.T) {
|
|||||||
|
|
||||||
// create proposal tx
|
// create proposal tx
|
||||||
proposalTokens := sdk.TokensFromConsensusPower(5)
|
proposalTokens := sdk.TokensFromConsensusPower(5)
|
||||||
resultTx := doSubmitParamChangeProposal(t, port, seed, name1, pw, addr, proposalTokens, fees)
|
resultTx := doSubmitParamChangeProposal(t, port, name1, addr, proposalTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
@@ -663,9 +663,9 @@ func TestSubmitParamChangeProposal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeposit(t *testing.T) {
|
func TestDeposit(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -676,7 +676,7 @@ func TestDeposit(t *testing.T) {
|
|||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
proposalTokens := sdk.TokensFromConsensusPower(5)
|
proposalTokens := sdk.TokensFromConsensusPower(5)
|
||||||
resultTx := doSubmitProposal(t, port, seed, name1, pw, addr, proposalTokens, fees)
|
resultTx := doSubmitProposal(t, port, name1, addr, proposalTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
@@ -699,7 +699,7 @@ func TestDeposit(t *testing.T) {
|
|||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
depositTokens := sdk.TokensFromConsensusPower(5)
|
depositTokens := sdk.TokensFromConsensusPower(5)
|
||||||
resultTx = doDeposit(t, port, seed, name1, pw, addr, proposalID, depositTokens, fees)
|
resultTx = doDeposit(t, port, name1, addr, proposalID, depositTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// verify balance after deposit and fee
|
// verify balance after deposit and fee
|
||||||
@@ -723,9 +723,9 @@ func TestDeposit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVote(t *testing.T) {
|
func TestVote(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, operAddrs, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, operAddrs, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -736,7 +736,7 @@ func TestVote(t *testing.T) {
|
|||||||
|
|
||||||
// create SubmitProposal TX
|
// create SubmitProposal TX
|
||||||
proposalTokens := sdk.TokensFromConsensusPower(10)
|
proposalTokens := sdk.TokensFromConsensusPower(10)
|
||||||
resultTx := doSubmitProposal(t, port, seed, name1, pw, addr, proposalTokens, fees)
|
resultTx := doSubmitProposal(t, port, name1, addr, proposalTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check if tx was committed
|
// check if tx was committed
|
||||||
@@ -759,7 +759,7 @@ func TestVote(t *testing.T) {
|
|||||||
require.Equal(t, gov.StatusVotingPeriod, proposal.Status)
|
require.Equal(t, gov.StatusVotingPeriod, proposal.Status)
|
||||||
|
|
||||||
// vote
|
// vote
|
||||||
resultTx = doVote(t, port, seed, name1, pw, addr, proposalID, "Yes", fees)
|
resultTx = doVote(t, port, name1, addr, proposalID, "Yes", fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// verify balance after vote and fee
|
// verify balance after vote and fee
|
||||||
@@ -783,7 +783,7 @@ func TestVote(t *testing.T) {
|
|||||||
|
|
||||||
// create bond TX
|
// create bond TX
|
||||||
delTokens := sdk.TokensFromConsensusPower(60)
|
delTokens := sdk.TokensFromConsensusPower(60)
|
||||||
resultTx = doDelegate(t, port, name1, pw, addr, operAddrs[0], delTokens, fees)
|
resultTx = doDelegate(t, port, name1, addr, operAddrs[0], delTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// verify balance
|
// verify balance
|
||||||
@@ -797,7 +797,7 @@ func TestVote(t *testing.T) {
|
|||||||
require.Equal(t, delTokens, tally.Yes, "tally should be equal to the amount delegated")
|
require.Equal(t, delTokens, tally.Yes, "tally should be equal to the amount delegated")
|
||||||
|
|
||||||
// change vote option
|
// change vote option
|
||||||
resultTx = doVote(t, port, seed, name1, pw, addr, proposalID, "No", fees)
|
resultTx = doVote(t, port, name1, addr, proposalID, "No", fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// verify balance
|
// verify balance
|
||||||
@@ -811,9 +811,9 @@ func TestVote(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUnjail(t *testing.T) {
|
func TestUnjail(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, _, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, valPubKeys, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, valPubKeys, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -833,9 +833,9 @@ func TestUnjail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestProposalsQuery(t *testing.T) {
|
func TestProposalsQuery(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addrs, seeds, names, passwords, errors := CreateAddrs(kb, 2)
|
addrs, _, names, errors := CreateAddrs(kb, 2)
|
||||||
require.Empty(t, errors)
|
require.Empty(t, errors)
|
||||||
|
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addrs[0], addrs[1]}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addrs[0], addrs[1]}, true)
|
||||||
@@ -848,14 +848,14 @@ func TestProposalsQuery(t *testing.T) {
|
|||||||
getTallyingParam(t, port)
|
getTallyingParam(t, port)
|
||||||
|
|
||||||
// Addr1 proposes (and deposits) proposals #1 and #2
|
// Addr1 proposes (and deposits) proposals #1 and #2
|
||||||
resultTx := doSubmitProposal(t, port, seeds[0], names[0], passwords[0], addrs[0], halfMinDeposit, fees)
|
resultTx := doSubmitProposal(t, port, names[0], addrs[0], halfMinDeposit, fees, kb)
|
||||||
bz, err := hex.DecodeString(resultTx.Data)
|
bz, err := hex.DecodeString(resultTx.Data)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
proposalID1 := gov.GetProposalIDFromBytes(bz)
|
proposalID1 := gov.GetProposalIDFromBytes(bz)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
resultTx = doSubmitProposal(t, port, seeds[0], names[0], passwords[0], addrs[0], halfMinDeposit, fees)
|
resultTx = doSubmitProposal(t, port, names[0], addrs[0], halfMinDeposit, fees, kb)
|
||||||
bz, err = hex.DecodeString(resultTx.Data)
|
bz, err = hex.DecodeString(resultTx.Data)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -863,7 +863,7 @@ func TestProposalsQuery(t *testing.T) {
|
|||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// Addr2 proposes (and deposits) proposals #3
|
// Addr2 proposes (and deposits) proposals #3
|
||||||
resultTx = doSubmitProposal(t, port, seeds[1], names[1], passwords[1], addrs[1], halfMinDeposit, fees)
|
resultTx = doSubmitProposal(t, port, names[1], addrs[1], halfMinDeposit, fees, kb)
|
||||||
bz, err = hex.DecodeString(resultTx.Data)
|
bz, err = hex.DecodeString(resultTx.Data)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -871,10 +871,10 @@ func TestProposalsQuery(t *testing.T) {
|
|||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// Addr2 deposits on proposals #2 & #3
|
// Addr2 deposits on proposals #2 & #3
|
||||||
resultTx = doDeposit(t, port, seeds[1], names[1], passwords[1], addrs[1], proposalID2, halfMinDeposit, fees)
|
resultTx = doDeposit(t, port, names[1], addrs[1], proposalID2, halfMinDeposit, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
resultTx = doDeposit(t, port, seeds[1], names[1], passwords[1], addrs[1], proposalID3, halfMinDeposit, fees)
|
resultTx = doDeposit(t, port, names[1], addrs[1], proposalID3, halfMinDeposit, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// check deposits match proposal and individual deposits
|
// check deposits match proposal and individual deposits
|
||||||
@@ -897,7 +897,7 @@ func TestProposalsQuery(t *testing.T) {
|
|||||||
|
|
||||||
// increasing the amount of the deposit should update the existing one
|
// increasing the amount of the deposit should update the existing one
|
||||||
depositTokens := sdk.TokensFromConsensusPower(1)
|
depositTokens := sdk.TokensFromConsensusPower(1)
|
||||||
resultTx = doDeposit(t, port, seeds[0], names[0], passwords[0], addrs[0], proposalID1, depositTokens, fees)
|
resultTx = doDeposit(t, port, names[0], addrs[0], proposalID1, depositTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
deposits = getDeposits(t, port, proposalID1)
|
deposits = getDeposits(t, port, proposalID1)
|
||||||
@@ -915,13 +915,13 @@ func TestProposalsQuery(t *testing.T) {
|
|||||||
require.Equal(t, proposalID3, proposals[1].ProposalID)
|
require.Equal(t, proposalID3, proposals[1].ProposalID)
|
||||||
|
|
||||||
// Addr1 votes on proposals #2 & #3
|
// Addr1 votes on proposals #2 & #3
|
||||||
resultTx = doVote(t, port, seeds[0], names[0], passwords[0], addrs[0], proposalID2, "Yes", fees)
|
resultTx = doVote(t, port, names[0], addrs[0], proposalID2, "Yes", fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
resultTx = doVote(t, port, seeds[0], names[0], passwords[0], addrs[0], proposalID3, "Yes", fees)
|
resultTx = doVote(t, port, names[0], addrs[0], proposalID3, "Yes", fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// Addr2 votes on proposal #3
|
// Addr2 votes on proposal #3
|
||||||
resultTx = doVote(t, port, seeds[1], names[1], passwords[1], addrs[1], proposalID3, "Yes", fees)
|
resultTx = doVote(t, port, names[1], addrs[1], proposalID3, "Yes", fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
|
|
||||||
// Test query all proposals
|
// Test query all proposals
|
||||||
@@ -988,9 +988,9 @@ func TestDistributionGetParams(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDistributionFlow(t *testing.T) {
|
func TestDistributionFlow(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, seed, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, valAddrs, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, valAddrs, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1012,12 +1012,12 @@ func TestDistributionFlow(t *testing.T) {
|
|||||||
|
|
||||||
// Delegate some coins
|
// Delegate some coins
|
||||||
delTokens := sdk.TokensFromConsensusPower(60)
|
delTokens := sdk.TokensFromConsensusPower(60)
|
||||||
resultTx := doDelegate(t, port, name1, pw, addr, valAddr, delTokens, fees)
|
resultTx := doDelegate(t, port, name1, addr, valAddr, delTokens, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+1, port)
|
tests.WaitForHeight(resultTx.Height+1, port)
|
||||||
require.Equal(t, uint32(0), resultTx.Code)
|
require.Equal(t, uint32(0), resultTx.Code)
|
||||||
|
|
||||||
// send some coins
|
// send some coins
|
||||||
_, resultTx = doTransfer(t, port, seed, name1, memo, pw, addr, fees)
|
_, resultTx = doTransfer(t, port, name1, memo, addr, fees, kb)
|
||||||
tests.WaitForHeight(resultTx.Height+5, port)
|
tests.WaitForHeight(resultTx.Height+5, port)
|
||||||
require.Equal(t, uint32(0), resultTx.Code)
|
require.Equal(t, uint32(0), resultTx.Code)
|
||||||
|
|
||||||
@@ -1061,14 +1061,14 @@ func TestDistributionFlow(t *testing.T) {
|
|||||||
require.Equal(t, operAddr.String(), withdrawAddr)
|
require.Equal(t, operAddr.String(), withdrawAddr)
|
||||||
|
|
||||||
// Withdraw delegator's rewards
|
// Withdraw delegator's rewards
|
||||||
resultTx = doWithdrawDelegatorAllRewards(t, port, seed, name1, pw, addr, fees)
|
resultTx = doWithdrawDelegatorAllRewards(t, port, name1, addr, fees)
|
||||||
require.Equal(t, uint32(0), resultTx.Code)
|
require.Equal(t, uint32(0), resultTx.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMintingQueries(t *testing.T) {
|
func TestMintingQueries(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, _, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@@ -1094,9 +1094,9 @@ func TestMintingQueries(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAccountBalanceQuery(t *testing.T) {
|
func TestAccountBalanceQuery(t *testing.T) {
|
||||||
kb, err := keys.NewKeyBaseFromDir(InitClientHome(""))
|
kb, err := keys.NewKeyringFromDir(InitClientHome(""), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
addr, _, err := CreateAddr(name1, pw, kb)
|
addr, _, err := CreateAddr(name1, kb)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
cleanup, _, _, port, err := InitializeLCD(1, []sdk.AccAddress{addr}, true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user