Merge pull request #222 from 8aff8265aa/fixtransactiongaslimit

Fixing transaction tests
This commit is contained in:
Roman Mandeleil 2015-02-11 13:31:43 +02:00
commit 15ea0c17c4
3 changed files with 28 additions and 9 deletions

View File

@ -18,6 +18,8 @@ import org.spongycastle.util.encoders.Hex;
import java.math.BigInteger;
import java.lang.Long;
import java.util.List;
import static org.ethereum.config.SystemProperties.CONFIG;
@ -100,6 +102,16 @@ public class TransactionExecutor {
return;
}
BigInteger startGasUsed = new BigInteger( Long.toString( this.currentBlock.getGasUsed() ) );
BigInteger startGasLimit = new BigInteger( Long.toString( this.currentBlock.getGasLimit() ) );
if( startGasUsed.add(gasLimit).compareTo( startGasLimit ) == 1) {
logger.debug("Too much gas used in this block: require={}", startGasLimit.toString());
receipt.setCumulativeGas(0);
this.receipt = receipt;
return;
}
// GET TOTAL ETHER VALUE AVAILABLE FOR TX FEE
BigInteger gasPrice = new BigInteger(1, tx.getGasPrice());
BigInteger gasDebit = new BigInteger(1, tx.getGasLimit()).multiply(gasPrice);

View File

@ -1,6 +1,7 @@
package org.ethereum.jsontestsuite;
import org.ethereum.core.BlockchainImpl;
import org.ethereum.core.Block;
import org.ethereum.core.TransactionExecutor;
import org.ethereum.db.*;
import org.ethereum.facade.Repository;
@ -82,6 +83,21 @@ public class TestRunner {
byte[] coinbase = testCase.getEnv().getCurrentCoinbase();
ProgramInvokeFactory invokeFactory = new TestProgramInvokeFactory(testCase.getEnv());
Block block = new Block(
ByteUtil.EMPTY_BYTE_ARRAY,
ByteUtil.EMPTY_BYTE_ARRAY,
coinbase,
ByteUtil.EMPTY_BYTE_ARRAY,
testCase.getEnv().getCurrentDifficulty(),
new BigInteger(1, testCase.getEnv().getCurrentNumber()).longValue(),
new BigInteger(1, testCase.getEnv().getCurrentGasLimit()).longValue(),
0L,
new BigInteger(1, testCase.getEnv().getCurrentTimestamp()).longValue(),
ByteUtil.ZERO_BYTE_ARRAY,
ByteUtil.ZERO_BYTE_ARRAY,
null, null);
blockchain.setBestBlock(block);
blockchain.setProgramInvokeFactory(invokeFactory);
blockchain.startTracking();

View File

@ -26,8 +26,6 @@ public class GitHubStateTest {
public void runWithExcludedTest() throws ParseException {
Set<String> excluded = new HashSet<>();
String json = JSONReader.loadJSON("StateTests/stPreCompiledContracts.json");
GitHubJSONTestSuite.runGitHubJsonStateTest(json, excluded);
}
@ -44,7 +42,6 @@ public class GitHubStateTest {
public void stInitCodeTest() throws ParseException { // [V]
Set<String> excluded = new HashSet<>();
String json = JSONReader.loadJSON("StateTests/stInitCodeTest.json");
GitHubJSONTestSuite.runGitHubJsonStateTest(json, excluded);
}
@ -98,10 +95,6 @@ public class GitHubStateTest {
public void stSystemOperationsTest() throws ParseException {
Set<String> excluded = new HashSet<>();
excluded.add("createNameRegistratorZeroMem2");
excluded.add("testVMtest");
excluded.add("createWithInvalidOpcode");
excluded.add("testRandomTest");
String json = JSONReader.loadJSON("StateTests/stSystemOperationsTest.json");
@ -114,8 +107,6 @@ public class GitHubStateTest {
Set<String> excluded = new HashSet<>();
//todo: it goes OOG, because no gasLimit is given. So it does not change the state.
excluded.add("TransactionFromCoinbaseHittingBlockGasLimit1");
String json = JSONReader.loadJSON("StateTests/stTransactionTest.json");
GitHubJSONTestSuite.runGitHubJsonStateTest(json, excluded);
}