Merge branch 'master' of https://github.com/ethereum/ethereumj into fixtransactiongaslimit
This commit is contained in:
commit
9f5678c769
|
@ -2,7 +2,6 @@
|
|||
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/ethereum/ethereumj?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[![Build Status](https://travis-ci.org/ethereum/ethereumj.svg?branch=master)](https://travis-ci.org/ethereum/ethereumj)
|
||||
[![Coverage Status](https://coveralls.io/repos/ethereum/ethereumj/badge.png?branch=master)](https://coveralls.io/r/ethereum/ethereumj?branch=master)
|
||||
[![Stories in Progress](https://badge.waffle.io/ethereum/ethereumj.png?title=In%20Progress&label=in_progress)](https://waffle.io/ethereum/ethereumj)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* @author Roman Mandeleil
|
||||
* @since 08.01.2015
|
||||
* @since 10.02.2015
|
||||
*/
|
||||
public class BlockStoreDummy implements BlockStore {
|
||||
|
||||
|
|
|
@ -23,12 +23,15 @@ import static org.ethereum.util.ByteUtil.wrap;
|
|||
* @author Roman Mandeleil
|
||||
* @since 17.11.2014
|
||||
*/
|
||||
public class RepositoryDummy implements Repository {
|
||||
public class RepositoryDummy extends RepositoryImpl {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("repository");
|
||||
private Map<ByteArrayWrapper, AccountState> worldState = new HashMap<>();
|
||||
private Map<ByteArrayWrapper, ContractDetails> detailsDB = new HashMap<>();
|
||||
|
||||
public RepositoryDummy() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.io.IOException;
|
|||
import java.math.BigInteger;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -54,17 +55,20 @@ public class RepositoryImpl implements Repository {
|
|||
|
||||
KeyValueDataSource detailsDS = null;
|
||||
KeyValueDataSource stateDS = null;
|
||||
|
||||
|
||||
public RepositoryImpl() {
|
||||
this(DETAILS_DB, STATE_DB);
|
||||
}
|
||||
|
||||
public RepositoryImpl(boolean createDb){
|
||||
}
|
||||
|
||||
public RepositoryImpl(KeyValueDataSource detailsDS, KeyValueDataSource stateDS) {
|
||||
|
||||
detailsDS.setName(DETAILS_DB);
|
||||
detailsDS.init();
|
||||
this.detailsDS = detailsDS;
|
||||
|
||||
|
||||
stateDS.setName(STATE_DB);
|
||||
stateDS.init();
|
||||
this.stateDS = stateDS;
|
||||
|
@ -73,7 +77,7 @@ public class RepositoryImpl implements Repository {
|
|||
stateDB = new DatabaseImpl(stateDS);
|
||||
worldState = new TrieImpl(stateDB.getDb());
|
||||
}
|
||||
|
||||
|
||||
public RepositoryImpl(String detailsDbName, String stateDbName) {
|
||||
detailsDB = new DatabaseImpl(detailsDbName);
|
||||
stateDB = new DatabaseImpl(stateDbName);
|
||||
|
@ -87,7 +91,7 @@ public class RepositoryImpl implements Repository {
|
|||
|
||||
detailsDS.init();
|
||||
detailsDB = new DatabaseImpl(detailsDS);
|
||||
|
||||
|
||||
stateDS.init();
|
||||
stateDB = new DatabaseImpl(stateDS);
|
||||
worldState = new TrieImpl(stateDB.getDb());
|
||||
|
@ -461,6 +465,12 @@ public class RepositoryImpl implements Repository {
|
|||
cacheDetails.put(wrap(addr), details);
|
||||
}
|
||||
|
||||
public Set<ByteArrayWrapper> getFullAddressSet() {
|
||||
Set<ByteArrayWrapper> setKeys = new HashSet<>(detailsDB.dumpKeys());
|
||||
return setKeys;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] getRoot() {
|
||||
return worldState.getRootHash();
|
||||
|
|
|
@ -0,0 +1,305 @@
|
|||
package org.ethereum.db;
|
||||
|
||||
import org.ethereum.core.AccountState;
|
||||
import org.ethereum.core.Block;
|
||||
import org.ethereum.facade.Repository;
|
||||
import org.ethereum.vm.DataWord;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.ethereum.crypto.SHA3Helper.sha3;
|
||||
import static org.ethereum.util.ByteUtil.wrap;
|
||||
|
||||
/**
|
||||
* @author Roman Mandeleil
|
||||
* @since 10.02.2015
|
||||
*/
|
||||
public class RepositoryVMTestDummy extends RepositoryImpl{
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger("repository");
|
||||
private Map<ByteArrayWrapper, AccountState> worldState = new HashMap<>();
|
||||
private Map<ByteArrayWrapper, ContractDetails> detailsDB = new HashMap<>();
|
||||
|
||||
public RepositoryVMTestDummy() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
worldState.clear();
|
||||
detailsDB.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateBatch(HashMap<ByteArrayWrapper, AccountState> stateCache, HashMap<ByteArrayWrapper,
|
||||
ContractDetails> detailsCache) {
|
||||
|
||||
for (ByteArrayWrapper hash : stateCache.keySet()) {
|
||||
|
||||
AccountState accountState = stateCache.get(hash);
|
||||
ContractDetails contractDetails = detailsCache.get(hash);
|
||||
|
||||
if (accountState.isDeleted()) {
|
||||
worldState.remove(hash);
|
||||
detailsDB.remove(hash);
|
||||
|
||||
logger.debug("delete: [{}]",
|
||||
Hex.toHexString(hash.getData()));
|
||||
|
||||
} else {
|
||||
|
||||
if (accountState.isDirty() || contractDetails.isDirty()) {
|
||||
detailsDB.put(hash, contractDetails);
|
||||
accountState.setStateRoot(contractDetails.getStorageHash());
|
||||
accountState.setCodeHash(sha3(contractDetails.getCode()));
|
||||
worldState.put(hash, accountState);
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("update: [{}],nonce: [{}] balance: [{}] \n [{}]",
|
||||
Hex.toHexString(hash.getData()),
|
||||
accountState.getNonce(),
|
||||
accountState.getBalance(),
|
||||
contractDetails.getStorage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
stateCache.clear();
|
||||
detailsCache.clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rollback() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void syncToRoot(byte[] root) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Repository startTracking() {
|
||||
return new RepositoryTrack(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dumpState(Block block, long gasUsed, int txNumber, byte[] txHash) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> getAccountsKeys() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<ByteArrayWrapper> getFullAddressSet() {
|
||||
return worldState.keySet();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BigInteger addBalance(byte[] addr, BigInteger value) {
|
||||
AccountState account = getAccountState(addr);
|
||||
|
||||
if (account == null)
|
||||
account = createAccount(addr);
|
||||
|
||||
BigInteger result = account.addToBalance(value);
|
||||
worldState.put(wrap(addr), account);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getBalance(byte[] addr) {
|
||||
AccountState account = getAccountState(addr);
|
||||
|
||||
if (account== null){
|
||||
account = createAccount(addr);
|
||||
}
|
||||
|
||||
return account.getBalance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataWord getStorageValue(byte[] addr, DataWord key) {
|
||||
ContractDetails details = getContractDetails(addr);
|
||||
|
||||
if (details == null){
|
||||
createAccount(addr);
|
||||
details = getContractDetails(addr);
|
||||
}
|
||||
|
||||
return details.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addStorageRow(byte[] addr, DataWord key, DataWord value) {
|
||||
ContractDetails details = getContractDetails(addr);
|
||||
|
||||
if (details == null) {
|
||||
createAccount(addr);
|
||||
details = getContractDetails(addr);
|
||||
}
|
||||
|
||||
details.put(key, value);
|
||||
detailsDB.put(wrap(addr), details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getCode(byte[] addr) {
|
||||
ContractDetails details = getContractDetails(addr);
|
||||
|
||||
if (details == null){
|
||||
createAccount(addr);
|
||||
details = getContractDetails(addr);
|
||||
}
|
||||
|
||||
return details.getCode();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveCode(byte[] addr, byte[] code) {
|
||||
ContractDetails details = getContractDetails(addr);
|
||||
|
||||
if (details == null) {
|
||||
createAccount(addr);
|
||||
details = getContractDetails(addr);
|
||||
}
|
||||
|
||||
details.setCode(code);
|
||||
detailsDB.put(wrap(addr), details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getNonce(byte[] addr) {
|
||||
AccountState account = getAccountState(addr);
|
||||
|
||||
if (account == null)
|
||||
account = createAccount(addr);
|
||||
|
||||
return account.getNonce();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger increaseNonce(byte[] addr) {
|
||||
AccountState account = getAccountState(addr);
|
||||
|
||||
if (account == null)
|
||||
account = createAccount(addr);
|
||||
|
||||
account.incrementNonce();
|
||||
worldState.put(wrap(addr), account);
|
||||
|
||||
return account.getNonce();
|
||||
}
|
||||
|
||||
public BigInteger setNonce(byte[] addr, BigInteger nonce) {
|
||||
|
||||
AccountState account = getAccountState(addr);
|
||||
|
||||
if (account == null)
|
||||
account = createAccount(addr);
|
||||
|
||||
account.setNonce(nonce);
|
||||
worldState.put(wrap(addr), account);
|
||||
|
||||
return account.getNonce();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void delete(byte[] addr) {
|
||||
worldState.remove(wrap(addr));
|
||||
detailsDB.remove(wrap(addr));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractDetails getContractDetails(byte[] addr) {
|
||||
|
||||
return detailsDB.get(wrap(addr));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public AccountState getAccountState(byte[] addr) {
|
||||
return worldState.get(wrap(addr));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountState createAccount(byte[] addr) {
|
||||
AccountState accountState = new AccountState();
|
||||
worldState.put(wrap(addr), accountState);
|
||||
|
||||
ContractDetails contractDetails = new ContractDetails();
|
||||
detailsDB.put(wrap(addr), contractDetails);
|
||||
|
||||
return accountState;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isExist(byte[] addr) {
|
||||
return getAccountState(addr) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getRoot() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadAccount(byte[] addr, HashMap<ByteArrayWrapper, AccountState> cacheAccounts, HashMap<ByteArrayWrapper, ContractDetails> cacheDetails) {
|
||||
|
||||
AccountState account = getAccountState(addr);
|
||||
ContractDetails details = getContractDetails(addr);
|
||||
|
||||
if (account == null)
|
||||
account = new AccountState();
|
||||
else
|
||||
account = account.clone();
|
||||
|
||||
if (details == null)
|
||||
details = new ContractDetails();
|
||||
else
|
||||
details = details.clone();
|
||||
|
||||
cacheAccounts.put(wrap(addr), account);
|
||||
cacheDetails.put(wrap(addr), details);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package org.ethereum.jsontestsuite;
|
|||
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import org.spongycastle.util.BigIntegers;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
@ -39,8 +40,8 @@ public class Env {
|
|||
String prevHash = env.get("previousHash").toString();
|
||||
|
||||
this.currentCoinbase = Hex.decode(coinbase);
|
||||
this.currentDifficulty = new BigInteger(difficulty).toByteArray();
|
||||
this.currentGasLimit = new BigInteger(gasLimit).toByteArray();
|
||||
this.currentDifficulty = BigIntegers.asUnsignedByteArray( new BigInteger(difficulty) );
|
||||
this.currentGasLimit = BigIntegers.asUnsignedByteArray(new BigInteger(gasLimit));
|
||||
this.currentNumber = new BigInteger(number).toByteArray();
|
||||
this.currentTimestamp = new BigInteger(timestamp).toByteArray();
|
||||
this.previousHash = Hex.decode(prevHash);
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package org.ethereum.jsontestsuite;
|
||||
|
||||
import org.ethereum.config.SystemProperties;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
|
@ -12,6 +16,9 @@ import java.net.HttpURLConnection;
|
|||
import java.net.URL;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class JSONReader {
|
||||
|
||||
|
@ -63,4 +70,26 @@ public class JSONReader {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<String> getFileNamesForTreeSha(String sha){
|
||||
|
||||
String result = getFromUrl("https://api.github.com/repos/ethereum/tests/git/trees/" + sha);
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject testSuiteObj = null;
|
||||
|
||||
List<String> fileNames = new ArrayList<String>();
|
||||
try {
|
||||
testSuiteObj = (JSONObject) parser.parse(result);
|
||||
JSONArray tree = (JSONArray)testSuiteObj.get("tree");
|
||||
|
||||
for (Object oEntry : tree) {
|
||||
JSONObject entry = (JSONObject) oEntry;
|
||||
String testName = (String) entry.get("path");
|
||||
fileNames.add(testName);
|
||||
}
|
||||
} catch (ParseException e) {e.printStackTrace();}
|
||||
|
||||
return fileNames;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import org.json.simple.JSONArray;
|
|||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import org.spongycastle.util.BigIntegers;
|
||||
import org.spongycastle.util.encoders.Hex;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
@ -77,7 +78,7 @@ public class TestCase {
|
|||
String gasString = "0";
|
||||
if (testCaseJSONObj.containsKey("gas"))
|
||||
gasString = testCaseJSONObj.get("gas").toString();
|
||||
this.gas = ByteUtil.bigIntegerToBytes(new BigInteger(gasString));
|
||||
this.gas = BigIntegers.asUnsignedByteArray(new BigInteger(gasString));
|
||||
|
||||
String outString = null;
|
||||
if (testCaseJSONObj.containsKey("out"))
|
||||
|
|
|
@ -3,10 +3,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;
|
||||
import org.ethereum.db.ContractDetails;
|
||||
import org.ethereum.db.RepositoryDummy;
|
||||
import org.ethereum.db.*;
|
||||
import org.ethereum.facade.Repository;
|
||||
import org.ethereum.util.ByteUtil;
|
||||
import org.ethereum.vm.DataWord;
|
||||
|
@ -68,7 +65,8 @@ public class TestRunner {
|
|||
logger.info("***\n");
|
||||
|
||||
logger.info("--------- PRE ---------");
|
||||
RepositoryDummy repository = loadRepository(testCase.getPre());
|
||||
RepositoryImpl repository = loadRepository(new RepositoryDummy(), testCase.getPre());
|
||||
|
||||
|
||||
logger.info("loaded repository");
|
||||
|
||||
|
@ -166,7 +164,7 @@ public class TestRunner {
|
|||
|
||||
|
||||
logger.info("--------- PRE ---------");
|
||||
RepositoryDummy repository = loadRepository(testCase.getPre());
|
||||
RepositoryImpl repository = loadRepository(new RepositoryVMTestDummy(), testCase.getPre());
|
||||
|
||||
try {
|
||||
|
||||
|
@ -186,7 +184,7 @@ public class TestRunner {
|
|||
byte[] msgData = exec.getData();
|
||||
byte[] lastHash = env.getPreviousHash();
|
||||
byte[] coinbase = env.getCurrentCoinbase();
|
||||
long timestamp = new BigInteger(env.getCurrentTimestamp()).longValue();
|
||||
long timestamp = ByteUtil.byteArrayToLong(env.getCurrentTimestamp());
|
||||
long number = ByteUtil.byteArrayToLong(env.getCurrentNumber());
|
||||
byte[] difficulty = env.getCurrentDifficulty();
|
||||
long gaslimit = new BigInteger(env.getCurrentGasLimit()).longValue();
|
||||
|
@ -199,7 +197,7 @@ public class TestRunner {
|
|||
|
||||
ProgramInvoke programInvoke = new ProgramInvokeImpl(address, origin, caller, balance,
|
||||
gasPrice, gas, callValue, msgData, lastHash, coinbase,
|
||||
timestamp, number, difficulty, gaslimit, repository, null, true);
|
||||
timestamp, number, difficulty, gaslimit, repository, new BlockStoreDummy(), true);
|
||||
|
||||
/* 3. Create Program - exec.code */
|
||||
/* 4. run VM */
|
||||
|
@ -496,8 +494,8 @@ public class TestRunner {
|
|||
}
|
||||
|
||||
// assert gas
|
||||
BigInteger expectedGas = new BigInteger(testCase.getGas());
|
||||
BigInteger actualGas = new BigInteger(gas).subtract(BigInteger.valueOf(program.getResult().getGasUsed()));
|
||||
BigInteger expectedGas = new BigInteger(1, testCase.getGas());
|
||||
BigInteger actualGas = new BigInteger(1, gas).subtract(BigInteger.valueOf(program.getResult().getGasUsed()));
|
||||
|
||||
if (!expectedGas.equals(actualGas)) {
|
||||
|
||||
|
@ -535,11 +533,9 @@ public class TestRunner {
|
|||
return transaction;
|
||||
}
|
||||
|
||||
public RepositoryDummy loadRepository(Map<ByteArrayWrapper, AccountState> pre) {
|
||||
public RepositoryImpl loadRepository(RepositoryImpl track, Map<ByteArrayWrapper, AccountState> pre) {
|
||||
|
||||
|
||||
RepositoryDummy track = new RepositoryDummy();
|
||||
|
||||
/* 1. Store pre-exist accounts - Pre */
|
||||
for (ByteArrayWrapper key : pre.keySet()) {
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public class AdminInfo {
|
|||
|
||||
public Long getExecAvg(){
|
||||
|
||||
if (blockExecTime.size() == 0) return 0L;
|
||||
|
||||
long sum = 0;
|
||||
for (int i = 0; i < blockExecTime.size(); ++i){
|
||||
sum += blockExecTime.get(i);
|
||||
|
|
|
@ -247,17 +247,25 @@ public class DataWord implements Comparable<DataWord> {
|
|||
return;
|
||||
}
|
||||
|
||||
BigInteger result = sValue().remainder(word.sValue());
|
||||
BigInteger result = sValue().abs().mod(word.sValue().abs());
|
||||
result = (sValue().signum() == -1) ? result.negate() : result;
|
||||
|
||||
this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));
|
||||
}
|
||||
|
||||
public void addmod(DataWord word1, DataWord word2) {
|
||||
|
||||
this.add(word1);
|
||||
BigInteger result = this.sValue().mod(word2.sValue());
|
||||
this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));
|
||||
this.mod(word2);
|
||||
}
|
||||
|
||||
public void mulmod(DataWord word1, DataWord word2) {
|
||||
|
||||
if (word2.isZero()) {
|
||||
this.data = new byte[32];
|
||||
return;
|
||||
}
|
||||
|
||||
BigInteger result = value().multiply(word1.value()).mod(word2.value());
|
||||
this.data = ByteUtil.copyToArray(result.and(MAX_VALUE));
|
||||
}
|
||||
|
|
|
@ -350,18 +350,23 @@ public class Program {
|
|||
|
||||
if (invokeData.byTestingSuite()) {
|
||||
// This keeps track of the contracts created for a test
|
||||
this.getResult().addCallCreate(programCode, newAddress,
|
||||
this.getResult().addCallCreate(programCode, EMPTY_BYTE_ARRAY,
|
||||
gasLimit.getNoLeadZeroesData(),
|
||||
value.getNoLeadZeroesData());
|
||||
}
|
||||
|
||||
// [4] TRANSFER THE BALANCE
|
||||
result.getRepository().addBalance(senderAddress, endowment.negate());
|
||||
BigInteger newBalance = result.getRepository().addBalance(newAddress, endowment);
|
||||
BigInteger newBalance = BigInteger.ZERO;
|
||||
if (!invokeData.byTestingSuite()) {
|
||||
newBalance = result.getRepository().addBalance(newAddress, endowment);
|
||||
}
|
||||
|
||||
// [3] UPDATE THE NONCE
|
||||
// (THIS STAGE IS NOT REVERTED BY ANY EXCEPTION)
|
||||
result.getRepository().increaseNonce(senderAddress);
|
||||
if (!invokeData.byTestingSuite()) {
|
||||
result.getRepository().increaseNonce(senderAddress);
|
||||
}
|
||||
|
||||
Repository track = result.getRepository().startTracking();
|
||||
|
||||
|
|
|
@ -19,10 +19,7 @@ import org.junit.runners.Suite.SuiteClasses;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Test file specific for tests maintained in the GitHub repository
|
||||
|
@ -68,6 +65,10 @@ public class GitHubJSONTestSuite {
|
|||
}
|
||||
}
|
||||
|
||||
protected static void runGitHubJsonVMTest(String json) throws ParseException {
|
||||
Set<String> excluded = new HashSet<>();
|
||||
runGitHubJsonVMTest(json, excluded);
|
||||
}
|
||||
|
||||
|
||||
protected static void runGitHubJsonVMTest(String json, Set<String> excluded) throws ParseException {
|
||||
|
|
|
@ -1,45 +1,34 @@
|
|||
package test.ethereum.jsontestsuite;
|
||||
|
||||
import org.ethereum.jsontestsuite.JSONReader;
|
||||
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import org.junit.FixMethodOrder;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runners.MethodSorters;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.ethereum.jsontestsuite.JSONReader.getFileNamesForTreeSha;
|
||||
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
public class GitHubVMTest {
|
||||
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void runSingle() throws ParseException {
|
||||
|
||||
String json = JSONReader.loadJSON("VMTests/vmSystemOperationsTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, "CallToPrecompiledContract");
|
||||
String json = JSONReader.loadJSON("VMTests/vmEnvironmentalInfoTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, "extcodecopy0AddressTooBigRight");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testArithmeticFromGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
excluded.add("addmod2");
|
||||
excluded.add("addmod3"); // implement mod by negative for BigInt
|
||||
excluded.add("addmod2_1"); // [?]
|
||||
excluded.add("mulmoddivByZero2"); // [?]
|
||||
excluded.add("addmodDivByZero"); // [?]
|
||||
excluded.add("addmodDivByZero1"); // [?]
|
||||
excluded.add("mulmoddivByZero1"); // [?]
|
||||
excluded.add("mulmoddivByZero"); // [?]
|
||||
excluded.add("addmod3_0"); // [?]
|
||||
|
||||
String json = JSONReader.loadJSON("VMTests/vmArithmeticTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
}
|
||||
|
@ -47,7 +36,6 @@ public class GitHubVMTest {
|
|||
|
||||
@Test // testing full suite
|
||||
public void testBitwiseLogicOperationFromGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
String json = JSONReader.loadJSON("VMTests/vmBitwiseLogicOperationTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
|
@ -56,11 +44,7 @@ public class GitHubVMTest {
|
|||
|
||||
@Test // testing full suite
|
||||
public void testBlockInfoFromGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
excluded.add("blockhash258Block");
|
||||
excluded.add("blockhashInRange");
|
||||
|
||||
String json = JSONReader.loadJSON("VMTests/vmBlockInfoTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
}
|
||||
|
@ -68,13 +52,7 @@ public class GitHubVMTest {
|
|||
|
||||
@Test // testing full suite
|
||||
public void testEnvironmentalInfoFromGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
excluded.add("ExtCodeSizeAddressInputTooBigRightMyAddress");
|
||||
excluded.add("balanceAddressInputTooBigRightMyAddress");
|
||||
excluded.add("balanceAddressInputTooBig");
|
||||
excluded.add("extcodecopy0AddressTooBigRight");
|
||||
|
||||
String json = JSONReader.loadJSON("VMTests/vmEnvironmentalInfoTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
}
|
||||
|
@ -82,7 +60,6 @@ public class GitHubVMTest {
|
|||
|
||||
@Test // testing full suite
|
||||
public void testIOandFlowOperationsFromGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
String json = JSONReader.loadJSON("VMTests/vmIOandFlowOperationsTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
|
@ -91,7 +68,6 @@ public class GitHubVMTest {
|
|||
@Ignore
|
||||
@Test // testing random
|
||||
public void testvmInputLimitsTest1FromGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
String json = JSONReader.loadJSON("VMTests/vmInputLimitsTest1.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
|
@ -99,7 +75,6 @@ public class GitHubVMTest {
|
|||
|
||||
@Test // testing full suite
|
||||
public void testVMLogGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
String json = JSONReader.loadJSON("VMTests/vmLogTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
|
@ -107,7 +82,6 @@ public class GitHubVMTest {
|
|||
|
||||
@Test // testing full suite
|
||||
public void testPushDupSwapFromGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
String json = JSONReader.loadJSON("VMTests/vmPushDupSwapTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
|
@ -115,39 +89,14 @@ public class GitHubVMTest {
|
|||
|
||||
@Test // testing full suite
|
||||
public void testShaFromGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
excluded.add("sha3_bigOffset2");
|
||||
|
||||
String json = JSONReader.loadJSON("VMTests/vmSha3Test.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
}
|
||||
|
||||
@Test // testing full suite
|
||||
public void testvmSystemOperationsTestGitHub() throws ParseException {
|
||||
|
||||
Set<String> excluded = new HashSet<>();
|
||||
// excluded.add("CallToNameRegistratorNotMuchMemory0");
|
||||
// excluded.add("ABAcallsSuicide0");
|
||||
// excluded.add("CallToNameRegistratorNotMuchMemory1");
|
||||
// excluded.add("CallToNameRegistratorOutOfGas");
|
||||
// excluded.add("callcodeToReturn1");
|
||||
excluded.add("createNameRegistrator");
|
||||
// excluded.add("ABAcallsSuicide1");
|
||||
excluded.add("CallToPrecompiledContract");
|
||||
// excluded.add("ABAcalls1");
|
||||
// excluded.add("ABAcalls2");
|
||||
// excluded.add("ABAcalls3");
|
||||
// excluded.add("CallToNameRegistrator0");
|
||||
// excluded.add("ABAcalls0");
|
||||
// excluded.add("CallRecursiveBomb3");
|
||||
// excluded.add("CallRecursiveBomb2");
|
||||
// excluded.add("CallRecursiveBomb1");
|
||||
// excluded.add("CallRecursiveBomb0");
|
||||
// excluded.add("CallToReturn1");
|
||||
// excluded.add("callcodeToNameRegistrator0");
|
||||
|
||||
|
||||
String json = JSONReader.loadJSON("VMTests/vmSystemOperationsTest.json");
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
}
|
||||
|
@ -161,4 +110,25 @@ public class GitHubVMTest {
|
|||
GitHubJSONTestSuite.runGitHubJsonVMTest(json, excluded);
|
||||
}
|
||||
|
||||
@Test // testing full suite
|
||||
public void testRandomVMGitHub() throws ParseException {
|
||||
|
||||
String sha = "60b921af8bf7bbe38565f8543e52a54e5f465ae8";
|
||||
List<String> fileNames = getFileNamesForTreeSha(sha);
|
||||
List<String> excludedFiles =
|
||||
Arrays.asList(
|
||||
""
|
||||
);
|
||||
|
||||
for (String fileName : fileNames) {
|
||||
|
||||
if (excludedFiles.contains(fileName)) continue;
|
||||
System.out.println("Running: " + fileName);
|
||||
String json = JSONReader.loadJSON("VMTests//RandomTests/" + fileName);
|
||||
GitHubJSONTestSuite.runGitHubJsonVMTest(json);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue