works?
This commit is contained in:
@@ -28,7 +28,7 @@ func TestStdTx(t *testing.T) {
|
||||
|
||||
func TestStdSignBytes(t *testing.T) {
|
||||
priv := crypto.GenPrivKeyEd25519()
|
||||
addr := priv.PubKey().Address()
|
||||
addr := sdk.AccAddress(priv.PubKey().Address())
|
||||
msgs := []sdk.Msg{sdk.NewTestMsg(addr)}
|
||||
fee := newStdFee()
|
||||
signMsg := StdSignMsg{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -37,11 +37,9 @@ func SendTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
bech32From := sdk.MustBech32ifyAcc(from)
|
||||
// Check if account was found
|
||||
if fromAcc == nil {
|
||||
return errors.New("No account with address " + bech32From +
|
||||
" was found in the state.\nAre you sure there has been a transaction involving it?")
|
||||
return errors.Errorf("No account with address %s was found in the state.\nAre you sure there has been a transaction involving it?", from)
|
||||
}
|
||||
|
||||
toStr := viper.GetString(flagTo)
|
||||
@@ -63,8 +61,7 @@ func SendTxCmd(cdc *wire.Codec) *cobra.Command {
|
||||
return err
|
||||
}
|
||||
if !account.GetCoins().IsGTE(coins) {
|
||||
return errors.New("Address " + bech32From +
|
||||
" doesn't have enough coins to pay for this transaction.")
|
||||
return errors.Errorf("Address %s doesn't have enough coins to pay for this transaction.", from)
|
||||
}
|
||||
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
|
||||
@@ -58,7 +58,7 @@ func TotalCoinsInvariant(t *testing.T, app *mock.App, log string) {
|
||||
// accounts already exist.
|
||||
func TestAndRunSingleInputMsgSend(t *testing.T, r *rand.Rand, app *mock.App, ctx sdk.Context, keys []crypto.PrivKey, log string) (action string, err sdk.Error) {
|
||||
fromKey := keys[r.Intn(len(keys))]
|
||||
fromAddr := fromKey.PubKey().Address()
|
||||
fromAddr := sdk.AccAddress(fromKey.PubKey().Address())
|
||||
toKey := keys[r.Intn(len(keys))]
|
||||
// Disallow sending money to yourself
|
||||
for {
|
||||
@@ -67,7 +67,7 @@ func TestAndRunSingleInputMsgSend(t *testing.T, r *rand.Rand, app *mock.App, ctx
|
||||
}
|
||||
toKey = keys[r.Intn(len(keys))]
|
||||
}
|
||||
toAddr := toKey.PubKey().Address()
|
||||
toAddr := sdk.AccAddress(toKey.PubKey().Address())
|
||||
initFromCoins := app.AccountMapper.GetAccount(ctx, fromAddr).GetCoins()
|
||||
|
||||
denomIndex := r.Intn(len(initFromCoins))
|
||||
|
||||
+6
-6
@@ -95,11 +95,11 @@ func (app *App) InitChainer(ctx sdk.Context, _ abci.RequestInitChain) abci.Respo
|
||||
|
||||
// CreateGenAccounts generates genesis accounts loaded with coins, and returns
|
||||
// their addresses, pubkeys, and privkeys.
|
||||
func CreateGenAccounts(numAccs int, genCoins sdk.Coins) (genAccs []auth.Account, addrs []sdk.Address, pubKeys []crypto.PubKey, privKeys []crypto.PrivKey) {
|
||||
func CreateGenAccounts(numAccs int, genCoins sdk.Coins) (genAccs []auth.Account, addrs []sdk.AccAddress, pubKeys []crypto.PubKey, privKeys []crypto.PrivKey) {
|
||||
for i := 0; i < numAccs; i++ {
|
||||
privKey := crypto.GenPrivKeyEd25519()
|
||||
pubKey := privKey.PubKey()
|
||||
addr := pubKey.Address()
|
||||
addr := sdk.AccAddress(pubKey.Address())
|
||||
|
||||
genAcc := &auth.BaseAccount{
|
||||
Address: addr,
|
||||
@@ -166,19 +166,19 @@ func GeneratePrivKeys(n int) (keys []crypto.PrivKey) {
|
||||
|
||||
// GeneratePrivKeyAddressPairs generates a total of n private key, address
|
||||
// pairs.
|
||||
func GeneratePrivKeyAddressPairs(n int) (keys []crypto.PrivKey, addrs []sdk.Address) {
|
||||
func GeneratePrivKeyAddressPairs(n int) (keys []crypto.PrivKey, addrs []sdk.AccAddress) {
|
||||
keys = make([]crypto.PrivKey, n, n)
|
||||
addrs = make([]sdk.Address, n, n)
|
||||
addrs = make([]sdk.AccAddress, n, n)
|
||||
for i := 0; i < n; i++ {
|
||||
keys[i] = crypto.GenPrivKeyEd25519()
|
||||
addrs[i] = keys[i].PubKey().Address()
|
||||
addrs[i] = sdk.AccAddress(keys[i].PubKey().Address())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// RandomSetGenesis set genesis accounts with random coin values using the
|
||||
// provided addresses and coin denominations.
|
||||
func RandomSetGenesis(r *rand.Rand, app *App, addrs []sdk.Address, denoms []string) {
|
||||
func RandomSetGenesis(r *rand.Rand, app *App, addrs []sdk.AccAddress, denoms []string) {
|
||||
accts := make([]auth.Account, len(addrs), len(addrs))
|
||||
randCoinIntervals := []BigInterval{
|
||||
{sdk.NewIntWithDecimal(1, 0), sdk.NewIntWithDecimal(1, 1)},
|
||||
|
||||
+5
-5
@@ -19,7 +19,7 @@ var (
|
||||
|
||||
// testMsg is a mock transaction that has a validation which can fail.
|
||||
type testMsg struct {
|
||||
signers []sdk.Address
|
||||
signers []sdk.AccAddress
|
||||
positiveNum int64
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func (tx testMsg) Type() string { return msgType }
|
||||
func (tx testMsg) GetMsg() sdk.Msg { return tx }
|
||||
func (tx testMsg) GetMemo() string { return "" }
|
||||
func (tx testMsg) GetSignBytes() []byte { return nil }
|
||||
func (tx testMsg) GetSigners() []sdk.Address { return tx.signers }
|
||||
func (tx testMsg) GetSigners() []sdk.AccAddress { return tx.signers }
|
||||
func (tx testMsg) GetSignatures() []auth.StdSignature { return nil }
|
||||
func (tx testMsg) ValidateBasic() sdk.Error {
|
||||
if tx.positiveNum >= 0 {
|
||||
@@ -53,7 +53,7 @@ func TestCheckAndDeliverGenTx(t *testing.T) {
|
||||
SetGenesis(mApp, accs)
|
||||
ctxCheck := mApp.BaseApp.NewContext(true, abci.Header{})
|
||||
|
||||
msg := testMsg{signers: []sdk.Address{addrs[0]}, positiveNum: 1}
|
||||
msg := testMsg{signers: []sdk.AccAddress{addrs[0]}, positiveNum: 1}
|
||||
|
||||
acct := mApp.AccountMapper.GetAccount(ctxCheck, addrs[0])
|
||||
require.Equal(t, accs[0], acct.(*auth.BaseAccount))
|
||||
@@ -86,14 +86,14 @@ func TestCheckGenTx(t *testing.T) {
|
||||
|
||||
SetGenesis(mApp, accs)
|
||||
|
||||
msg1 := testMsg{signers: []sdk.Address{addrs[0]}, positiveNum: 1}
|
||||
msg1 := testMsg{signers: []sdk.AccAddress{addrs[0]}, positiveNum: 1}
|
||||
CheckGenTx(
|
||||
t, mApp.BaseApp, []sdk.Msg{msg1},
|
||||
[]int64{accs[0].GetAccountNumber()}, []int64{accs[0].GetSequence()},
|
||||
true, privKeys[0],
|
||||
)
|
||||
|
||||
msg2 := testMsg{signers: []sdk.Address{addrs[0]}, positiveNum: -1}
|
||||
msg2 := testMsg{signers: []sdk.AccAddress{addrs[0]}, positiveNum: -1}
|
||||
CheckGenTx(
|
||||
t, mApp.BaseApp, []sdk.Msg{msg2},
|
||||
[]int64{accs[0].GetAccountNumber()}, []int64{accs[0].GetSequence()},
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// CheckBalance checks the balance of an account.
|
||||
func CheckBalance(t *testing.T, app *App, addr sdk.Address, exp sdk.Coins) {
|
||||
func CheckBalance(t *testing.T, app *App, addr sdk.AccAddress, exp sdk.Coins) {
|
||||
ctxCheck := app.BaseApp.NewContext(true, abci.Header{})
|
||||
res := app.AccountMapper.GetAccount(ctxCheck, addr)
|
||||
|
||||
|
||||
@@ -29,9 +29,9 @@ var (
|
||||
newPubKey("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AFB52"),
|
||||
}
|
||||
addrs = []sdk.AccAddress{
|
||||
pks[0].Address(),
|
||||
pks[1].Address(),
|
||||
pks[2].Address(),
|
||||
sdk.AccAddress(pks[0].Address()),
|
||||
sdk.AccAddress(pks[1].Address()),
|
||||
sdk.AccAddress(pks[2].Address()),
|
||||
}
|
||||
initCoins sdk.Int = sdk.NewInt(200)
|
||||
)
|
||||
|
||||
@@ -93,11 +93,7 @@ func (k Keeper) GetUnbondingDelegation(ctx sdk.Context,
|
||||
}
|
||||
|
||||
// load all unbonding delegations from a particular validator
|
||||
<<<<<<< HEAD
|
||||
func (k Keeper) GetUnbondingDelegationsFromValidator(ctx sdk.Context, valAddr sdk.Address) (ubds []types.UnbondingDelegation) {
|
||||
=======
|
||||
func (k Keeper) GetUnbondingDelegationsFromValidator(ctx sdk.Context, valAddr sdk.AccAddress) (unbondingDelegations []types.UnbondingDelegation) {
|
||||
>>>>>>> asdf
|
||||
func (k Keeper) GetUnbondingDelegationsFromValidator(ctx sdk.Context, valAddr sdk.AccAddress) (ubds []types.UnbondingDelegation) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
iterator := sdk.KVStorePrefixIterator(store, GetUBDsByValIndexKey(valAddr))
|
||||
for {
|
||||
@@ -149,11 +145,7 @@ func (k Keeper) GetRedelegation(ctx sdk.Context,
|
||||
}
|
||||
|
||||
// load all redelegations from a particular validator
|
||||
<<<<<<< HEAD
|
||||
func (k Keeper) GetRedelegationsFromValidator(ctx sdk.Context, valAddr sdk.Address) (reds []types.Redelegation) {
|
||||
=======
|
||||
func (k Keeper) GetRedelegationsFromValidator(ctx sdk.Context, valAddr sdk.AccAddress) (redelegations []types.Redelegation) {
|
||||
>>>>>>> asdf
|
||||
func (k Keeper) GetRedelegationsFromValidator(ctx sdk.Context, valAddr sdk.AccAddress) (reds []types.Redelegation) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
iterator := sdk.KVStorePrefixIterator(store, GetREDsFromValSrcIndexKey(valAddr))
|
||||
for {
|
||||
|
||||
@@ -225,7 +225,7 @@ func GetREDsToValDstIndexKey(validatorDstAddr sdk.AccAddress) []byte {
|
||||
|
||||
// get the prefix keyspace for all redelegations redelegating towards a destination validator
|
||||
// from a particular delegator
|
||||
func GetREDsByDelToValDstIndexKey(delegatorAddr sdk.Address, validatorDstAddr sdk.AccAddress) []byte {
|
||||
func GetREDsByDelToValDstIndexKey(delegatorAddr, validatorDstAddr sdk.AccAddress) []byte {
|
||||
return append(
|
||||
GetREDsToValDstIndexKey(validatorDstAddr),
|
||||
delegatorAddr.Bytes()...)
|
||||
|
||||
@@ -55,8 +55,8 @@ func UnmarshalDelegation(cdc *wire.Codec, key, value []byte) (delegation Delegat
|
||||
err = errors.New("unexpected key length")
|
||||
return
|
||||
}
|
||||
delAddr := sdk.Address(addrs[:sdk.AddrLen])
|
||||
valAddr := sdk.Address(addrs[sdk.AddrLen:])
|
||||
delAddr := sdk.AccAddress(addrs[:sdk.AddrLen])
|
||||
valAddr := sdk.AccAddress(addrs[sdk.AddrLen:])
|
||||
|
||||
return Delegation{
|
||||
DelegatorAddr: delAddr,
|
||||
@@ -145,8 +145,8 @@ func UnmarshalUBD(cdc *wire.Codec, key, value []byte) (ubd UnbondingDelegation,
|
||||
err = errors.New("unexpected key length")
|
||||
return
|
||||
}
|
||||
delAddr := sdk.Address(addrs[:sdk.AddrLen])
|
||||
valAddr := sdk.Address(addrs[sdk.AddrLen:])
|
||||
delAddr := sdk.AccAddress(addrs[:sdk.AddrLen])
|
||||
valAddr := sdk.AccAddress(addrs[sdk.AddrLen:])
|
||||
|
||||
return UnbondingDelegation{
|
||||
DelegatorAddr: delAddr,
|
||||
@@ -237,9 +237,9 @@ func UnmarshalRED(cdc *wire.Codec, key, value []byte) (red Redelegation, err err
|
||||
err = errors.New("unexpected key length")
|
||||
return
|
||||
}
|
||||
delAddr := sdk.Address(addrs[:sdk.AddrLen])
|
||||
valSrcAddr := sdk.Address(addrs[sdk.AddrLen : 2*sdk.AddrLen])
|
||||
valDstAddr := sdk.Address(addrs[2*sdk.AddrLen:])
|
||||
delAddr := sdk.AccAddress(addrs[:sdk.AddrLen])
|
||||
valSrcAddr := sdk.AccAddress(addrs[sdk.AddrLen : 2*sdk.AddrLen])
|
||||
valDstAddr := sdk.AccAddress(addrs[2*sdk.AddrLen:])
|
||||
|
||||
return Redelegation{
|
||||
DelegatorAddr: delAddr,
|
||||
|
||||
Reference in New Issue
Block a user