Remove all sequence from coin, fixed cli tests

This commit is contained in:
Ethan Frey 2017-07-12 19:24:59 +02:00
parent 1cc671108e
commit 137f8a9ce1
7 changed files with 20 additions and 24 deletions

View File

@ -15,16 +15,14 @@ import (
type GenesisAccount struct {
Address data.Bytes `json:"address"`
// this from types.Account (don't know how to embed this properly)
PubKey crypto.PubKey `json:"pub_key"` // May be nil, if not known.
Sequence int `json:"sequence"`
Balance Coins `json:"coins"`
PubKey crypto.PubKey `json:"pub_key"` // May be nil, if not known.
Balance Coins `json:"coins"`
}
// ToAccount - GenesisAccount struct to a basecoin Account
func (g GenesisAccount) ToAccount() Account {
return Account{
Sequence: g.Sequence,
Coins: g.Balance,
Coins: g.Balance,
}
}

View File

@ -39,9 +39,8 @@ func (a *AccountWithKey) Actor() basecoin.Actor {
// This is intended for use in test cases
func (a *AccountWithKey) MakeOption() string {
info := GenesisAccount{
Address: a.Address(),
Sequence: a.Sequence,
Balance: a.Coins,
Address: a.Address(),
Balance: a.Coins,
}
js, err := data.ToJSON(info)
if err != nil {

View File

@ -63,8 +63,7 @@ func updateCoins(store state.KVStore, addr basecoin.Actor, coins Coins) (acct Ac
// Account - coin account structure
type Account struct {
Coins Coins `json:"coins"`
Sequence int `json:"sequence"`
Coins Coins `json:"coins"`
}
func loadAccount(store state.KVStore, key []byte) (acct Account, err error) {

View File

@ -23,7 +23,7 @@ test00GetAccount() {
assertFalse "requires arg" "${CLIENT_EXE} query account"
checkAccount $SENDER "0" "9007199254740992"
checkAccount $SENDER "9007199254740992"
ACCT2=$(${CLIENT_EXE} query account $RECV 2>/dev/null)
assertFalse "has no genesis account" $?
@ -40,10 +40,10 @@ test01SendTx() {
HASH=$(echo $TX | jq .hash | tr -d \")
TX_HEIGHT=$(echo $TX | jq .height)
checkAccount $SENDER "1" "9007199254740000"
checkAccount $SENDER "9007199254740000"
# make sure 0x prefix also works
checkAccount "0x$SENDER" "1" "9007199254740000"
checkAccount $RECV "0" "992"
checkAccount "0x$SENDER" "9007199254740000"
checkAccount $RECV "992"
# Make sure tx is indexed
checkSendTx $HASH $TX_HEIGHT $SENDER "992"

View File

@ -124,6 +124,7 @@ getAddr() {
echo $RAW | cut -d' ' -f2
}
# XXX Ex Usage: checkAccount $ADDR $AMOUNT
# Desc: Assumes just one coin, checks the balance of first coin in any case
checkAccount() {
# make sure sender goes down
@ -133,8 +134,7 @@ checkAccount() {
fi
if [ -n "$DEBUG" ]; then echo $ACCT; echo; fi
assertEquals "proper sequence" "$2" $(echo $ACCT | jq .data.sequence)
assertEquals "proper money" "$3" $(echo $ACCT | jq .data.coins[0].amount)
assertEquals "proper money" "$2" $(echo $ACCT | jq .data.coins[0].amount)
return $?
}

View File

@ -23,7 +23,7 @@ test00GetAccount() {
assertFalse "requires arg" "${CLIENT_EXE} query account"
checkAccount $SENDER "0" "9007199254740992"
checkAccount $SENDER "9007199254740992"
ACCT2=$(${CLIENT_EXE} query account $RECV 2>/dev/null)
assertFalse "has no genesis account" $?
@ -40,8 +40,8 @@ test01SendTx() {
HASH=$(echo $TX | jq .hash | tr -d \")
TX_HEIGHT=$(echo $TX | jq .height)
checkAccount $SENDER "1" "9007199254740000"
checkAccount $RECV "0" "992"
checkAccount $SENDER "9007199254740000"
checkAccount $RECV "992"
# make sure tx is indexed
checkSendTx $HASH $TX_HEIGHT $SENDER "992"
@ -76,7 +76,7 @@ test03AddCount() {
checkCounter "1" "10"
# make sure the account was debited
checkAccount $SENDER "2" "9007199254739990"
checkAccount $SENDER "9007199254739990"
# make sure tx is indexed
TX=$(${CLIENT_EXE} query tx $HASH --trace)

View File

@ -26,8 +26,8 @@ test00PreRestart() {
HASH=$(echo $TX | jq .hash | tr -d \")
TX_HEIGHT=$(echo $TX | jq .height)
checkAccount $SENDER "1" "9007199254740000"
checkAccount $RECV "0" "992"
checkAccount $SENDER "9007199254740000"
checkAccount $RECV "992"
# make sure tx is indexed
checkSendTx $HASH $TX_HEIGHT $SENDER "992"
@ -63,8 +63,8 @@ test01OnRestart() {
# make sure queries still work properly, with all 3 tx now executed
echo "Checking state after restart..."
checkAccount $SENDER "3" "9007199254710000"
checkAccount $RECV "0" "30992"
checkAccount $SENDER "9007199254710000"
checkAccount $RECV "30992"
# make sure tx is indexed
checkSendTx $HASH $TX_HEIGHT $SENDER "10000"