From 36ea2069f42ce6eba31147f3a7b3c8231d6fe9d1 Mon Sep 17 00:00:00 2001 From: Faiz Khan Date: Fri, 23 Jan 2015 20:33:16 -0600 Subject: [PATCH] Add fix for emptyTransaction test --- .../java/org/ethereum/core/TransactionExecutor.java | 10 ++++++++++ .../test/ethereum/jsontestsuite/GitHubStateTest.java | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java index 8afa81a4..e912f073 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/TransactionExecutor.java @@ -89,6 +89,16 @@ public class TransactionExecutor { return; } + //Insert gas cost protection + BigInteger gasLimit = new BigInteger(1, tx.getGasLimit()); + if (gasLimit.compareTo(BigInteger.ZERO) == 0) { + logger.debug("No gas limit set on transaction: hash={}", + Hex.toHexString(tx.getHash())); + + receipt.setCumulativeGas(0); + this.receipt = receipt; + return; + } // FIND OUT THE TRANSACTION TYPE final byte[] receiverAddress; diff --git a/ethereumj-core/src/test/java/test/ethereum/jsontestsuite/GitHubStateTest.java b/ethereumj-core/src/test/java/test/ethereum/jsontestsuite/GitHubStateTest.java index 07e08a8d..adc61ef8 100644 --- a/ethereumj-core/src/test/java/test/ethereum/jsontestsuite/GitHubStateTest.java +++ b/ethereumj-core/src/test/java/test/ethereum/jsontestsuite/GitHubStateTest.java @@ -110,12 +110,10 @@ public class GitHubStateTest { GitHubJSONTestSuite.runGitHubJsonStateTest(json, excluded); } - @Test // todo: fix: excluded test public void stTransactionTest() throws ParseException { Set excluded = new HashSet<>(); - excluded.add("EmptyTransaction"); //todo: it goes OOG, because no gasLimit is given. So it does not change the state.