From e6ec782f0c7c0536d748e7e9dc9453b771d6210c Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 17 Apr 2017 17:47:00 -0400 Subject: [PATCH] minor cleanup --- app/app_test.go | 12 ++++++------ state/execution_test.go | 10 +++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/app_test.go b/app/app_test.go index b4e1200228..4ce7210534 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -70,8 +70,8 @@ func (at *appTest) reset() { // 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) { - initBalFoo := at.app.GetState().GetAccount(at.accIn.Account.PubKey.Address()).Balance - initBalBar := at.app.GetState().GetAccount(at.accOut.Account.PubKey.Address()).Balance + initBalIn := at.app.GetState().GetAccount(at.accIn.Account.PubKey.Address()).Balance + initBalOut := at.app.GetState().GetAccount(at.accOut.Account.PubKey.Address()).Balance txBytes := []byte(wire.BinaryBytes(struct{ types.Tx }{tx})) if checkTx { @@ -80,10 +80,10 @@ func (at *appTest) exec(tx *types.SendTx, checkTx bool) (res abci.Result, inputG res = at.app.DeliverTx(txBytes) } - endBalFoo := at.app.GetState().GetAccount(at.accIn.Account.PubKey.Address()).Balance - endBalBar := at.app.GetState().GetAccount(at.accOut.Account.PubKey.Address()).Balance - decrBalFooExp := tx.Outputs[0].Coins.Plus(types.Coins{tx.Fee}) - return res, endBalFoo, initBalFoo.Minus(decrBalFooExp), endBalBar, initBalBar.Plus(tx.Outputs[0].Coins) + endBalIn := at.app.GetState().GetAccount(at.accIn.Account.PubKey.Address()).Balance + endBalOut := at.app.GetState().GetAccount(at.accOut.Account.PubKey.Address()).Balance + decrBalInExp := tx.Outputs[0].Coins.Plus(types.Coins{tx.Fee}) + return res, endBalIn, initBalIn.Minus(decrBalInExp), endBalOut, initBalOut.Plus(tx.Outputs[0].Coins) } //-------------------------------------------------------- diff --git a/state/execution_test.go b/state/execution_test.go index f2a0073956..a6648e90b6 100644 --- a/state/execution_test.go +++ b/state/execution_test.go @@ -65,6 +65,10 @@ func (et *execTest) reset() { et.store = types.NewMemKVStore() et.state = NewState(et.store) 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) 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() txs1 := types.Accs2TxOutputs(et.accIn) txs2 := types.Accs2TxOutputs(et.accOut) @@ -207,11 +211,11 @@ func TestValidateOutputsAdvanced(t *testing.T) { //validateOutputsBasic txs := types.Accs2TxOutputs(et.accIn) 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 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) {