Fixing transaction tests

This commit is contained in:
Faiz Khan 2015-02-08 20:55:52 -06:00
parent 87c97652b6
commit ba3b1c34b3
3 changed files with 28 additions and 2 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.BlockStoreDummy;
import org.ethereum.db.ByteArrayWrapper;
@ -84,6 +85,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(testCase.getEnv().getCurrentNumber()).longValue(),
new BigInteger(testCase.getEnv().getCurrentGasLimit()).longValue(),
0L,
new BigInteger(testCase.getEnv().getCurrentTimestamp()).longValue(),
ByteUtil.ZERO_BYTE_ARRAY,
ByteUtil.ZERO_BYTE_ARRAY,
null, null);
blockchain.setBestBlock(block);
blockchain.setProgramInvokeFactory(invokeFactory);
blockchain.startTracking();

View File

@ -114,8 +114,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);
}