minor cleanup
This commit is contained in:
parent
f857f6218b
commit
e6ec782f0c
|
@ -70,8 +70,8 @@ func (at *appTest) reset() {
|
||||||
// returns the final balance and expected balance for input and output accounts
|
// returns the final balance and expected balance for input and output accounts
|
||||||
func (at *appTest) exec(tx *types.SendTx, checkTx bool) (res abci.Result, inputGot, inputExp, outputGot, outputExpected types.Coins) {
|
func (at *appTest) exec(tx *types.SendTx, checkTx bool) (res abci.Result, inputGot, inputExp, outputGot, outputExpected types.Coins) {
|
||||||
|
|
||||||
initBalFoo := at.app.GetState().GetAccount(at.accIn.Account.PubKey.Address()).Balance
|
initBalIn := at.app.GetState().GetAccount(at.accIn.Account.PubKey.Address()).Balance
|
||||||
initBalBar := at.app.GetState().GetAccount(at.accOut.Account.PubKey.Address()).Balance
|
initBalOut := at.app.GetState().GetAccount(at.accOut.Account.PubKey.Address()).Balance
|
||||||
|
|
||||||
txBytes := []byte(wire.BinaryBytes(struct{ types.Tx }{tx}))
|
txBytes := []byte(wire.BinaryBytes(struct{ types.Tx }{tx}))
|
||||||
if checkTx {
|
if checkTx {
|
||||||
|
@ -80,10 +80,10 @@ func (at *appTest) exec(tx *types.SendTx, checkTx bool) (res abci.Result, inputG
|
||||||
res = at.app.DeliverTx(txBytes)
|
res = at.app.DeliverTx(txBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
endBalFoo := at.app.GetState().GetAccount(at.accIn.Account.PubKey.Address()).Balance
|
endBalIn := at.app.GetState().GetAccount(at.accIn.Account.PubKey.Address()).Balance
|
||||||
endBalBar := at.app.GetState().GetAccount(at.accOut.Account.PubKey.Address()).Balance
|
endBalOut := at.app.GetState().GetAccount(at.accOut.Account.PubKey.Address()).Balance
|
||||||
decrBalFooExp := tx.Outputs[0].Coins.Plus(types.Coins{tx.Fee})
|
decrBalInExp := tx.Outputs[0].Coins.Plus(types.Coins{tx.Fee})
|
||||||
return res, endBalFoo, initBalFoo.Minus(decrBalFooExp), endBalBar, initBalBar.Plus(tx.Outputs[0].Coins)
|
return res, endBalIn, initBalIn.Minus(decrBalInExp), endBalOut, initBalOut.Plus(tx.Outputs[0].Coins)
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
|
|
|
@ -65,6 +65,10 @@ func (et *execTest) reset() {
|
||||||
et.store = types.NewMemKVStore()
|
et.store = types.NewMemKVStore()
|
||||||
et.state = NewState(et.store)
|
et.state = NewState(et.store)
|
||||||
et.state.SetChainID(et.chainID)
|
et.state.SetChainID(et.chainID)
|
||||||
|
|
||||||
|
// NOTE we dont run acc2State here
|
||||||
|
// so we can test non-existing accounts
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------
|
//--------------------------------------------------------
|
||||||
|
@ -111,7 +115,7 @@ func TestGetOrMakeOutputs(t *testing.T) {
|
||||||
_, res = getOrMakeOutputs(et.state, nil, txs)
|
_, res = getOrMakeOutputs(et.state, nil, txs)
|
||||||
assert.True(res.IsErr(), "getOrMakeOutputs: expected error when sending duplicate accounts")
|
assert.True(res.IsErr(), "getOrMakeOutputs: expected error when sending duplicate accounts")
|
||||||
|
|
||||||
//test sending to existing/new account account
|
//test sending to existing/new account
|
||||||
et.reset()
|
et.reset()
|
||||||
txs1 := types.Accs2TxOutputs(et.accIn)
|
txs1 := types.Accs2TxOutputs(et.accIn)
|
||||||
txs2 := types.Accs2TxOutputs(et.accOut)
|
txs2 := types.Accs2TxOutputs(et.accOut)
|
||||||
|
@ -207,11 +211,11 @@ func TestValidateOutputsAdvanced(t *testing.T) {
|
||||||
//validateOutputsBasic
|
//validateOutputsBasic
|
||||||
txs := types.Accs2TxOutputs(et.accIn)
|
txs := types.Accs2TxOutputs(et.accIn)
|
||||||
res := validateOutputsBasic(txs)
|
res := validateOutputsBasic(txs)
|
||||||
assert.True(res.IsOK(), fmt.Sprintf("validateOutputsBasic: expected no error on good tx input. Error: %v", res.Error()))
|
assert.True(res.IsOK(), fmt.Sprintf("validateOutputsBasic: expected no error on good tx output. Error: %v", res.Error()))
|
||||||
|
|
||||||
txs[0].Coins[0].Amount = 0
|
txs[0].Coins[0].Amount = 0
|
||||||
res = validateOutputsBasic(txs)
|
res = validateOutputsBasic(txs)
|
||||||
assert.True(res.IsErr(), fmt.Sprintf("validateInputBasic: expected error on bad tx inputi. Error: %v", res.Error()))
|
assert.True(res.IsErr(), fmt.Sprintf("validateInputBasic: expected error on bad tx output. Error: %v", res.Error()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSumOutput(t *testing.T) {
|
func TestSumOutput(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue