Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuchman committed Sep 22, 2017
1 parent 3c9accd commit a74445c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 8 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,19 +209,18 @@ func (app *EthermintApplication) Query(query abciTypes.RequestQuery) abciTypes.R
// validateTx checks the validity of a tx against the blockchain's current state.
// it duplicates the logic in ethereum's tx_pool
func (app *EthermintApplication) validateTx(tx *ethTypes.Transaction) abciTypes.Result {
currentState := app.checkTxState

var signer ethTypes.Signer = ethTypes.FrontierSigner{}
if tx.Protected() {
signer = ethTypes.NewEIP155Signer(tx.ChainId())
}

// Heuristic limit, reject transactions over 32KB to prevent DOS attacks
if tx.Size() > maxTransactionSize {
return abciTypes.ErrInternalError.
AppendLog(core.ErrOversizedData.Error())
}

var signer ethTypes.Signer = ethTypes.FrontierSigner{}
if tx.Protected() {
signer = ethTypes.NewEIP155Signer(tx.ChainId())
}

// Make sure the transaction is signed properly
from, err := ethTypes.Sender(signer, tx)
if err != nil {
Expand All @@ -236,8 +235,9 @@ func (app *EthermintApplication) validateTx(tx *ethTypes.Transaction) abciTypes.
AppendLog(core.ErrNegativeValue.Error())
}

// Make sure the account exist. Non existent accounts
// haven't got funds and well therefor never pass.
currentState := app.checkTxState

// Make sure the account exist - cant send from non-existing account.
if !currentState.Exist(from) {
return abciTypes.ErrBaseUnknownAddress.
AppendLog(core.ErrInvalidSender.Error())
Expand Down
12 changes: 5 additions & 7 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func setupTestCase(t *testing.T, addresses []common.Address) (tearDown func(t *t

tearDown = func(t *testing.T) {
t.Log("Tearing down test case")
os.RemoveAll(temporaryDirectory)
node.Stop()
os.RemoveAll(temporaryDirectory)
}

return
Expand All @@ -61,15 +61,13 @@ func TestStrictlyIncrementingNonces(t *testing.T) {
defer teardownTestCase(t)

height := uint64(1)
nonceOne := uint64(0)
nonceTwo := uint64(1)
nonceThree := uint64(2)

tx1 := createTxBytes(t, privateKey, nonceOne,
// create txs with different nonces
tx1 := createTxBytes(t, privateKey, 0,
receiverAddress, amount, gasLimit, gasPrice, nil)
tx2 := createTxBytes(t, privateKey, nonceTwo,
tx2 := createTxBytes(t, privateKey, 1,
receiverAddress, amount, gasLimit, gasPrice, nil)
tx3 := createTxBytes(t, privateKey, nonceThree,
tx3 := createTxBytes(t, privateKey, 2,
receiverAddress, amount, gasLimit, gasPrice, nil)

assert.Equal(t, abciTypes.OK, app.CheckTx(tx1))
Expand Down

0 comments on commit a74445c

Please sign in to comment.