diff --git a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java index bc11e477..fad124a2 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/BlockchainImpl.java @@ -5,7 +5,6 @@ import org.ethereum.facade.Repository; import org.ethereum.listener.EthereumListener; import org.ethereum.manager.WorldManager; import org.ethereum.net.BlockQueue; -import org.ethereum.net.eth.EthHandler; import org.ethereum.util.AdvancedDeviceUtils; import org.ethereum.vm.*; import org.slf4j.Logger; diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java b/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java index e771ef15..12c3fb41 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Genesis.java @@ -3,8 +3,6 @@ package org.ethereum.core; import org.ethereum.crypto.HashUtil; import org.ethereum.trie.Trie; import org.ethereum.trie.TrieImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.spongycastle.util.encoders.Hex; import java.math.BigInteger; @@ -41,8 +39,6 @@ public class Genesis extends Block { "1a26338f0d905e295fccb71fa9ea849ffa12aaf4", // # (A) }; - Logger logger = LoggerFactory.getLogger("main"); - private static byte[] zeroHash256 = new byte[32]; private static byte[] zeroHash160 = new byte[20]; @@ -74,9 +70,6 @@ public class Genesis extends Block { state.update(Hex.decode(address), acctState.getEncoded()); } setStateRoot(state.getRootHash()); - - logger.info("Genesis-hash: {}", Hex.toHexString(this.getHash())); - logger.info("Genesis-stateRoot: {}", Hex.toHexString(this.getStateRoot())); } public static Block getInstance() { diff --git a/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java b/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java index 15718e2d..7eb89c73 100644 --- a/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java +++ b/ethereumj-core/src/main/java/org/ethereum/core/Transaction.java @@ -12,7 +12,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongycastle.util.BigIntegers; -import java.math.BigInteger; import java.security.SignatureException; /** @@ -25,7 +24,7 @@ import java.security.SignatureException; */ public class Transaction { - private static Logger logger = LoggerFactory.getLogger(Transaction.class); + private static final Logger logger = LoggerFactory.getLogger(Transaction.class); /* SHA3 hash of the RLP encoded transaction */ private byte[] hash; diff --git a/ethereumj-core/src/main/java/org/ethereum/db/DatabaseImpl.java b/ethereumj-core/src/main/java/org/ethereum/db/DatabaseImpl.java index e7c594c8..684d2d74 100644 --- a/ethereumj-core/src/main/java/org/ethereum/db/DatabaseImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/db/DatabaseImpl.java @@ -27,7 +27,7 @@ import org.spongycastle.util.encoders.Hex; */ public class DatabaseImpl implements Database { - private static Logger logger = LoggerFactory.getLogger("db"); + private static final Logger logger = LoggerFactory.getLogger("db"); private DB db; private String name; diff --git a/ethereumj-core/src/main/java/org/ethereum/db/RepositoryImpl.java b/ethereumj-core/src/main/java/org/ethereum/db/RepositoryImpl.java index c3e7373c..d96c9a9c 100644 --- a/ethereumj-core/src/main/java/org/ethereum/db/RepositoryImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/db/RepositoryImpl.java @@ -56,7 +56,7 @@ import static org.ethereum.config.SystemProperties.CONFIG; */ public class RepositoryImpl implements Repository { - private Logger logger = LoggerFactory.getLogger("repository"); + private static final Logger logger = LoggerFactory.getLogger("repository"); private Trie worldState; private TrackTrie accountStateDB; @@ -473,18 +473,17 @@ public class RepositoryImpl implements Repository { } public void close() { - - if (this.chainDB != null){ - chainDB.close(); - chainDB = null; + if (this.detailsDB != null){ + detailsDB.close(); + detailsDB = null; } if (this.stateDB != null){ stateDB.close(); stateDB = null; } - if (this.detailsDB != null){ - detailsDB.close(); - detailsDB = null; + if (this.chainDB != null){ + chainDB.close(); + chainDB = null; } } diff --git a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java index 940f1928..47f719e2 100644 --- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java +++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java @@ -44,273 +44,275 @@ public class TestRunner { public List runTestCase(TestCase testCase) { - System.out.println("\nRunning test case: " + testCase.getName()); - List results = new ArrayList<>(); - - Repository repository = new RepositoryImpl(); - - System.out.println("--------- PRE ---------"); - /* 1. Store pre-exist accounts - Pre */ - for (ByteArrayWrapper key : testCase.getPre().keySet()) { - - AccountState accountState = testCase.getPre().get(key); - - repository.createAccount(key.getData()); - repository.saveCode(key.getData(), accountState.getCode()); - repository.addBalance(key.getData(), new BigInteger(accountState.getBalance())); - - for (long i = 0; i < accountState.getNonceLong(); ++i) - repository.increaseNonce(key.getData()); - } - - /* 2. Create ProgramInvoke - Env/Exec */ - Env env = testCase.getEnv(); - Exec exec = testCase.getExec(); - - byte[] address = exec.getAddress(); - byte[] origin = exec.getOrigin(); - byte[] caller = exec.getCaller(); - byte[] balance = ByteUtil.bigIntegerToBytes(repository.getBalance(exec.getAddress())); - byte[] gasPrice = exec.getGasPrice(); - byte[] gas = exec.getGas(); - byte[] callValue = exec.getValue(); - byte[] msgData = exec.getData(); - byte[] lastHash = env.getPreviousHash(); - byte[] coinbase = env.getCurrentCoinbase(); - long timestamp = new BigInteger(env.getCurrentTimestamp()).longValue(); - long number = new BigInteger(env.getCurrentNumber()).longValue(); - byte[] difficulty = env.getCurrentDifficlty(); - long gaslimit = new BigInteger(env.getCurrentGasLimit()).longValue(); - - // Origin and caller need to exist in order to be able to execute - if(repository.getAccountState(origin) == null) - repository.createAccount(origin); - if(repository.getAccountState(caller) == null) - repository.createAccount(caller); - - ProgramInvoke programInvoke = new ProgramInvokeImpl(address, origin, caller, balance, - gasPrice, gas, callValue, msgData, lastHash, coinbase, - timestamp, number, difficulty, gaslimit, repository, true); - - /* 3. Create Program - exec.code */ - /* 4. run VM */ - VM vm = new VM(); - Program program = new Program(exec.getCode(), programInvoke); - - try { - System.out.println("-------- EXEC --------"); - while(!program.isStopped()) - vm.step(program); - } catch (RuntimeException e) { - program.setRuntimeFailure(e); - } - - System.out.println("--------- POST --------"); - /* 5. Assert Post values */ - for (ByteArrayWrapper key : testCase.getPost().keySet()) { - - AccountState accountState = testCase.getPost().get(key); - - long expectedNonce = accountState.getNonceLong(); - BigInteger expectedBalance = accountState.getBigIntegerBalance(); - byte[] expectedCode = accountState.getCode(); - - boolean accountExist = (null != repository.getAccountState(key.getData())); - if (!accountExist) { - - String output = - String.format("The expected account does not exist. key: [ %s ]", - Hex.toHexString(key.getData())); - logger.info(output); - results.add(output); - continue; - } - - long actualNonce = repository.getNonce(key.getData()).longValue(); - BigInteger actualBalance = repository.getBalance(key.getData()); - byte[] actualCode = repository.getCode(key.getData()); - if (actualCode == null) actualCode = "".getBytes(); - - if (expectedNonce != actualNonce) { - - String output = - String.format("The nonce result is different. key: [ %s ], expectedNonce: [ %d ] is actualNonce: [ %d ] ", - Hex.toHexString(key.getData()), expectedNonce, actualNonce); - logger.info(output); - results.add(output); - } - - if (!expectedBalance.equals(actualBalance)) { - - String output = - String.format("The balance result is different. key: [ %s ], expectedBalance: [ %s ] is actualBalance: [ %s ] ", - Hex.toHexString(key.getData()), expectedBalance.toString(), actualBalance.toString()); - logger.info(output); - results.add(output); - } - - if (!Arrays.equals(expectedCode, actualCode)) { - - String output = - String.format("The code result is different. account: [ %s ], expectedCode: [ %s ] is actualCode: [ %s ] ", - Hex.toHexString(key.getData()), - Hex.toHexString(expectedCode), - Hex.toHexString(actualCode)); - logger.info(output); - results.add(output); - } - - // assert storage - Map storage = accountState.getStorage(); - for (ByteArrayWrapper storageKey : storage.keySet()) { - - byte[] expectedStValue = storage.get(storageKey).getData(); - - ContractDetails contractDetails = - program.getResult().getRepository().getContractDetails(accountState.getAddress()); - - if (contractDetails == null) { - - String output = - String.format("Storage raw doesn't exist: key [ %s ], expectedValue: [ %s ]", - Hex.toHexString(storageKey.getData()), - Hex.toHexString(expectedStValue) - ); - logger.info(output); - results.add(output); - continue; - } - - Map testStorage = contractDetails.getStorage(); - DataWord actualValue = testStorage.get(new DataWord(storageKey.getData())); - - if (!Arrays.equals(expectedStValue, actualValue.getNoLeadZeroesData())) { - - String output = - String.format("Storage value different: key [ %s ], expectedValue: [ %s ], actualValue: [ %s ]", - Hex.toHexString(storageKey.getData()), - Hex.toHexString(expectedStValue), - Hex.toHexString(actualValue.getNoLeadZeroesData())); - logger.info(output); - results.add(output); - } - } - } - - // TODO: assert that you have no extra accounts in the repository - // TODO: -> basically the deleted by suicide should be deleted - // TODO: -> and no unexpected created - - List resultCallCreates = - program.getResult().getCallCreateList(); - - // assert call creates - for (int i = 0; i < testCase.getCallCreateList().size(); ++i) { - - org.ethereum.vm.CallCreate resultCallCreate = null; - if (resultCallCreates != null && resultCallCreates.size() > i) { - resultCallCreate = resultCallCreates.get(i); - } - - CallCreate expectedCallCreate = testCase.getCallCreateList().get(i); - - if (resultCallCreate == null && expectedCallCreate != null) { - - String output = - String.format("Missing call/create invoke: to: [ %s ], data: [ %s ], gas: [ %s ], value: [ %s ]", - Hex.toHexString(expectedCallCreate.getDestination()), - Hex.toHexString(expectedCallCreate.getData()), - Hex.toHexString(expectedCallCreate.getGasLimit()), - Hex.toHexString(expectedCallCreate.getValue())); - logger.info(output); - results.add(output); - - continue; - } - - boolean assertDestination = Arrays.equals( - expectedCallCreate.getDestination(), - resultCallCreate.getDestination()); - if (!assertDestination) { - - String output = - String.format("Call/Create destination is different. Expected: [ %s ], result: [ %s ]", - Hex.toHexString(expectedCallCreate.getDestination()), - Hex.toHexString(resultCallCreate.getDestination())); - logger.info(output); - results.add(output); - } - - boolean assertData = Arrays.equals( - expectedCallCreate.getData(), - resultCallCreate.getData()); - if (!assertData) { - - String output = - String.format("Call/Create data is different. Expected: [ %s ], result: [ %s ]", - Hex.toHexString(expectedCallCreate.getData()), - Hex.toHexString(resultCallCreate.getData())); - logger.info(output); - results.add(output); - } - - boolean assertGasLimit = Arrays.equals( - expectedCallCreate.getGasLimit(), - resultCallCreate.getGasLimit()); - if (!assertGasLimit) { - String output = - String.format("Call/Create gasLimit is different. Expected: [ %s ], result: [ %s ]", - Hex.toHexString(expectedCallCreate.getGasLimit()), - Hex.toHexString(resultCallCreate.getGasLimit())); - logger.info(output); - results.add(output); - } - - boolean assertValue = Arrays.equals( - expectedCallCreate.getValue(), - resultCallCreate.getValue()); - if (!assertValue) { - String output = - String.format("Call/Create value is different. Expected: [ %s ], result: [ %s ]", - Hex.toHexString(expectedCallCreate.getValue()), - Hex.toHexString(resultCallCreate.getValue())); - logger.info(output); - results.add(output); - } - } - - // assert out - byte[] expectedHReturn = testCase.getOut(); - byte[] actualHReturn = ByteUtil.EMPTY_BYTE_ARRAY; - if (program.getResult().getHReturn() != null) { - actualHReturn = program.getResult().getHReturn().array(); - } - - if (!Arrays.equals(expectedHReturn, actualHReturn)) { - - String output = - String.format("HReturn is different. Expected hReturn: [ %s ], actual hReturn: [ %s ]", - Hex.toHexString(expectedHReturn), - Hex.toHexString(actualHReturn)); - logger.info(output); - results.add(output); - } - - // assert gas - BigInteger expectedGas = new BigInteger(testCase.getGas()); - BigInteger actualGas = new BigInteger(gas).subtract(BigInteger.valueOf(program.getResult().getGasUsed())); - - if (!expectedGas.equals(actualGas)) { - - String output = - String.format("Gas remaining is different. Expected gas remaining: [ %s ], actual gas remaining: [ %s ]", - expectedGas.toString() , - actualGas.toString()); - logger.info(output); - results.add(output); - } - program.getResult().getRepository().close(); - - return results; + Repository repository = new RepositoryImpl(); + + try { + System.out.println("\nRunning test case: " + testCase.getName()); + List results = new ArrayList<>(); + + System.out.println("--------- PRE ---------"); + /* 1. Store pre-exist accounts - Pre */ + for (ByteArrayWrapper key : testCase.getPre().keySet()) { + + AccountState accountState = testCase.getPre().get(key); + + repository.createAccount(key.getData()); + repository.saveCode(key.getData(), accountState.getCode()); + repository.addBalance(key.getData(), new BigInteger(accountState.getBalance())); + + for (long i = 0; i < accountState.getNonceLong(); ++i) + repository.increaseNonce(key.getData()); + } + + /* 2. Create ProgramInvoke - Env/Exec */ + Env env = testCase.getEnv(); + Exec exec = testCase.getExec(); + + byte[] address = exec.getAddress(); + byte[] origin = exec.getOrigin(); + byte[] caller = exec.getCaller(); + byte[] balance = ByteUtil.bigIntegerToBytes(repository.getBalance(exec.getAddress())); + byte[] gasPrice = exec.getGasPrice(); + byte[] gas = exec.getGas(); + byte[] callValue = exec.getValue(); + byte[] msgData = exec.getData(); + byte[] lastHash = env.getPreviousHash(); + byte[] coinbase = env.getCurrentCoinbase(); + long timestamp = new BigInteger(env.getCurrentTimestamp()).longValue(); + long number = new BigInteger(env.getCurrentNumber()).longValue(); + byte[] difficulty = env.getCurrentDifficlty(); + long gaslimit = new BigInteger(env.getCurrentGasLimit()).longValue(); + + // Origin and caller need to exist in order to be able to execute + if(repository.getAccountState(origin) == null) + repository.createAccount(origin); + if(repository.getAccountState(caller) == null) + repository.createAccount(caller); + + ProgramInvoke programInvoke = new ProgramInvokeImpl(address, origin, caller, balance, + gasPrice, gas, callValue, msgData, lastHash, coinbase, + timestamp, number, difficulty, gaslimit, repository, true); + + /* 3. Create Program - exec.code */ + /* 4. run VM */ + VM vm = new VM(); + Program program = new Program(exec.getCode(), programInvoke); + + try { + System.out.println("-------- EXEC --------"); + while(!program.isStopped()) + vm.step(program); + } catch (RuntimeException e) { + program.setRuntimeFailure(e); + } + + System.out.println("--------- POST --------"); + /* 5. Assert Post values */ + for (ByteArrayWrapper key : testCase.getPost().keySet()) { + + AccountState accountState = testCase.getPost().get(key); + + long expectedNonce = accountState.getNonceLong(); + BigInteger expectedBalance = accountState.getBigIntegerBalance(); + byte[] expectedCode = accountState.getCode(); + + boolean accountExist = (null != repository.getAccountState(key.getData())); + if (!accountExist) { + + String output = + String.format("The expected account does not exist. key: [ %s ]", + Hex.toHexString(key.getData())); + logger.info(output); + results.add(output); + continue; + } + + long actualNonce = repository.getNonce(key.getData()).longValue(); + BigInteger actualBalance = repository.getBalance(key.getData()); + byte[] actualCode = repository.getCode(key.getData()); + if (actualCode == null) actualCode = "".getBytes(); + + if (expectedNonce != actualNonce) { + + String output = + String.format("The nonce result is different. key: [ %s ], expectedNonce: [ %d ] is actualNonce: [ %d ] ", + Hex.toHexString(key.getData()), expectedNonce, actualNonce); + logger.info(output); + results.add(output); + } + + if (!expectedBalance.equals(actualBalance)) { + + String output = + String.format("The balance result is different. key: [ %s ], expectedBalance: [ %s ] is actualBalance: [ %s ] ", + Hex.toHexString(key.getData()), expectedBalance.toString(), actualBalance.toString()); + logger.info(output); + results.add(output); + } + + if (!Arrays.equals(expectedCode, actualCode)) { + + String output = + String.format("The code result is different. account: [ %s ], expectedCode: [ %s ] is actualCode: [ %s ] ", + Hex.toHexString(key.getData()), + Hex.toHexString(expectedCode), + Hex.toHexString(actualCode)); + logger.info(output); + results.add(output); + } + + // assert storage + Map storage = accountState.getStorage(); + for (ByteArrayWrapper storageKey : storage.keySet()) { + + byte[] expectedStValue = storage.get(storageKey).getData(); + + ContractDetails contractDetails = + program.getResult().getRepository().getContractDetails(accountState.getAddress()); + + if (contractDetails == null) { + + String output = + String.format("Storage raw doesn't exist: key [ %s ], expectedValue: [ %s ]", + Hex.toHexString(storageKey.getData()), + Hex.toHexString(expectedStValue) + ); + logger.info(output); + results.add(output); + continue; + } + + Map testStorage = contractDetails.getStorage(); + DataWord actualValue = testStorage.get(new DataWord(storageKey.getData())); + + if (!Arrays.equals(expectedStValue, actualValue.getNoLeadZeroesData())) { + + String output = + String.format("Storage value different: key [ %s ], expectedValue: [ %s ], actualValue: [ %s ]", + Hex.toHexString(storageKey.getData()), + Hex.toHexString(expectedStValue), + Hex.toHexString(actualValue.getNoLeadZeroesData())); + logger.info(output); + results.add(output); + } + } + } + + // TODO: assert that you have no extra accounts in the repository + // TODO: -> basically the deleted by suicide should be deleted + // TODO: -> and no unexpected created + + List resultCallCreates = + program.getResult().getCallCreateList(); + + // assert call creates + for (int i = 0; i < testCase.getCallCreateList().size(); ++i) { + + org.ethereum.vm.CallCreate resultCallCreate = null; + if (resultCallCreates != null && resultCallCreates.size() > i) { + resultCallCreate = resultCallCreates.get(i); + } + + CallCreate expectedCallCreate = testCase.getCallCreateList().get(i); + + if (resultCallCreate == null && expectedCallCreate != null) { + + String output = + String.format("Missing call/create invoke: to: [ %s ], data: [ %s ], gas: [ %s ], value: [ %s ]", + Hex.toHexString(expectedCallCreate.getDestination()), + Hex.toHexString(expectedCallCreate.getData()), + Hex.toHexString(expectedCallCreate.getGasLimit()), + Hex.toHexString(expectedCallCreate.getValue())); + logger.info(output); + results.add(output); + + continue; + } + + boolean assertDestination = Arrays.equals( + expectedCallCreate.getDestination(), + resultCallCreate.getDestination()); + if (!assertDestination) { + + String output = + String.format("Call/Create destination is different. Expected: [ %s ], result: [ %s ]", + Hex.toHexString(expectedCallCreate.getDestination()), + Hex.toHexString(resultCallCreate.getDestination())); + logger.info(output); + results.add(output); + } + + boolean assertData = Arrays.equals( + expectedCallCreate.getData(), + resultCallCreate.getData()); + if (!assertData) { + + String output = + String.format("Call/Create data is different. Expected: [ %s ], result: [ %s ]", + Hex.toHexString(expectedCallCreate.getData()), + Hex.toHexString(resultCallCreate.getData())); + logger.info(output); + results.add(output); + } + + boolean assertGasLimit = Arrays.equals( + expectedCallCreate.getGasLimit(), + resultCallCreate.getGasLimit()); + if (!assertGasLimit) { + String output = + String.format("Call/Create gasLimit is different. Expected: [ %s ], result: [ %s ]", + Hex.toHexString(expectedCallCreate.getGasLimit()), + Hex.toHexString(resultCallCreate.getGasLimit())); + logger.info(output); + results.add(output); + } + + boolean assertValue = Arrays.equals( + expectedCallCreate.getValue(), + resultCallCreate.getValue()); + if (!assertValue) { + String output = + String.format("Call/Create value is different. Expected: [ %s ], result: [ %s ]", + Hex.toHexString(expectedCallCreate.getValue()), + Hex.toHexString(resultCallCreate.getValue())); + logger.info(output); + results.add(output); + } + } + + // assert out + byte[] expectedHReturn = testCase.getOut(); + byte[] actualHReturn = ByteUtil.EMPTY_BYTE_ARRAY; + if (program.getResult().getHReturn() != null) { + actualHReturn = program.getResult().getHReturn().array(); + } + + if (!Arrays.equals(expectedHReturn, actualHReturn)) { + + String output = + String.format("HReturn is different. Expected hReturn: [ %s ], actual hReturn: [ %s ]", + Hex.toHexString(expectedHReturn), + Hex.toHexString(actualHReturn)); + logger.info(output); + results.add(output); + } + + // assert gas + BigInteger expectedGas = new BigInteger(testCase.getGas()); + BigInteger actualGas = new BigInteger(gas).subtract(BigInteger.valueOf(program.getResult().getGasUsed())); + + if (!expectedGas.equals(actualGas)) { + + String output = + String.format("Gas remaining is different. Expected gas remaining: [ %s ], actual gas remaining: [ %s ]", + expectedGas.toString() , + actualGas.toString()); + logger.info(output); + results.add(output); + } + return results; + } finally { + repository.close(); + } } } diff --git a/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java b/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java index 4c572f98..2262d843 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/BlockQueue.java @@ -2,7 +2,6 @@ package org.ethereum.net; import static org.ethereum.config.SystemProperties.CONFIG; -import org.ethereum.config.SystemProperties; import org.ethereum.core.Block; import org.ethereum.manager.WorldManager; import org.slf4j.Logger; @@ -22,7 +21,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; */ public class BlockQueue { - private static Logger logger = LoggerFactory.getLogger("blockqueue"); + private static final Logger logger = LoggerFactory.getLogger("blockqueue"); /** The list of hashes of the heaviest chain on the network, * for which this client doesn't have the blocks yet */ diff --git a/ethereumj-core/src/main/java/org/ethereum/net/MessageQueue.java b/ethereumj-core/src/main/java/org/ethereum/net/MessageQueue.java index ae09969f..8e9bcc16 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/MessageQueue.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/MessageQueue.java @@ -26,7 +26,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; */ public class MessageQueue { - private Logger logger = LoggerFactory.getLogger("net"); + private static final Logger logger = LoggerFactory.getLogger("net"); private Queue messageQueue = new ConcurrentLinkedQueue<>(); private PeerListener listener; diff --git a/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java b/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java index a1d14671..b9447845 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java @@ -29,7 +29,7 @@ import static org.ethereum.config.SystemProperties.CONFIG; */ public class PeerClient { - private Logger logger = LoggerFactory.getLogger("wire"); + private static final Logger logger = LoggerFactory.getLogger("wire"); private PeerListener peerListener; private P2pHandler p2pHandler; diff --git a/ethereumj-core/src/main/java/org/ethereum/net/submit/TransactionTask.java b/ethereumj-core/src/main/java/org/ethereum/net/submit/TransactionTask.java index d414c388..47b4d12d 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/submit/TransactionTask.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/submit/TransactionTask.java @@ -16,7 +16,7 @@ import static java.lang.Thread.sleep; */ public class TransactionTask implements Callable { - private Logger logger = LoggerFactory.getLogger(TransactionTask.class); + private static final Logger logger = LoggerFactory.getLogger(TransactionTask.class); private Transaction tx; diff --git a/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageDecoder.java b/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageDecoder.java index 78c4aad1..b4532735 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageDecoder.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageDecoder.java @@ -17,8 +17,8 @@ import java.util.List; */ public class MessageDecoder extends ByteToMessageDecoder { - private Logger loggerWire = LoggerFactory.getLogger("wire"); - private Logger loggerNet = LoggerFactory.getLogger("net"); + private static final Logger loggerWire = LoggerFactory.getLogger("wire"); + private static final Logger loggerNet = LoggerFactory.getLogger("net"); @Override protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) throws Exception { diff --git a/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageEncoder.java b/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageEncoder.java index 41683419..b66bb1d6 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageEncoder.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/wire/MessageEncoder.java @@ -16,8 +16,8 @@ import org.spongycastle.util.encoders.Hex; */ public class MessageEncoder extends MessageToByteEncoder { - private Logger loggerWire = LoggerFactory.getLogger("wire"); - private Logger loggerNet = LoggerFactory.getLogger("net"); + private static final Logger loggerWire = LoggerFactory.getLogger("wire"); + private static final Logger loggerNet = LoggerFactory.getLogger("net"); @Override diff --git a/ethereumj-core/src/main/java/org/ethereum/trie/TrieImpl.java b/ethereumj-core/src/main/java/org/ethereum/trie/TrieImpl.java index e98b861e..6907e622 100644 --- a/ethereumj-core/src/main/java/org/ethereum/trie/TrieImpl.java +++ b/ethereumj-core/src/main/java/org/ethereum/trie/TrieImpl.java @@ -41,7 +41,7 @@ import org.spongycastle.util.encoders.Hex; */ public class TrieImpl implements Trie { - private Logger logger = LoggerFactory.getLogger("trie"); + private static final Logger logger = LoggerFactory.getLogger("trie"); private static byte PAIR_SIZE = 2; private static byte LIST_SIZE = 17; diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/OpCode.java b/ethereumj-core/src/main/java/org/ethereum/vm/OpCode.java index ea936814..e4aae830 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/OpCode.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/OpCode.java @@ -9,304 +9,305 @@ import java.util.Map; * - Appendix G. Virtual Machine Specification */ public enum OpCode { - + /** Halts execution (0x00) */ - STOP(0x00), + STOP(0x00, 0), /* Arithmetic Operations */ /** (0x01) Addition operation */ - ADD(0x01), + ADD(0x01, 2), /** (0x02) Multiplication operation */ - MUL(0x02), + MUL(0x02, 2), /** (0x03) Subtraction operations */ - SUB(0x03), + SUB(0x03, 2), /** (0x04) Integer division operation */ - DIV(0x04), + DIV(0x04, 2), /** (0x05) Signed integer division operation*/ - SDIV(0x05), + SDIV(0x05, 2), /** (0x06) Modulo remainder operation */ - MOD(0x06), + MOD(0x06, 2), /** (0x07) Signed modulo remainder operation*/ - SMOD(0x07), + SMOD(0x07, 2), /** (0x08) Exponential operation */ - EXP(0x08), + EXP(0x08, 2), /** (0x09) Negation operation */ - NEG(0x09), + NEG(0x09, 1), /** (0x0a) Less-than comparison */ - LT(0X0a), + LT(0X0a, 2), /** (0x0b) Greater-than comparison */ - GT(0X0b), + GT(0X0b, 2), /** (0x0c) Signed less-than comparison */ - SLT(0X0c), + SLT(0X0c, 2), /** (0x0d) Signed greater-than comparison */ - SGT(0X0d), + SGT(0X0d, 2), /** (0x0e) Equality comparison */ - EQ(0X0e), + EQ(0X0e, 2), /** (0x0f) Simple not operator */ - NOT(0X0f), + NOT(0X0f, 1), /* Bitwise Logic Operations */ /** (0x10) Bitwise AND operation */ - AND(0x10), + AND(0x10, 2), /** (0x11) Bitwise OR operation */ - OR(0x11), + OR(0x11, 2), /** (0x12) Bitwise XOR operation */ - XOR(0x12), + XOR(0x12, 2), /** (0x13) Retrieve single byte from word */ - BYTE(0x13), + BYTE(0x13, 2), /** (0x14) Addition combined with modulo * remainder operation */ - ADDMOD(0x14), + ADDMOD(0x14, 3), /** (0x15) Multiplication combined with modulo * remainder operation */ - MULMOD(0x15), + MULMOD(0x15, 3), /* Cryptographic Operations */ /** (0x20) Compute SHA3-256 hash */ - SHA3(0x20), + SHA3(0x20, 2), /* Environmental Information */ - + /** (0x30) Get address of currently * executing account */ - ADDRESS(0x30), + ADDRESS(0x30, 0), /** (0x31) Get balance of the given account */ - BALANCE(0x31), + BALANCE(0x31, 1), /** (0x32) Get execution origination address*/ - ORIGIN(0x32), + ORIGIN(0x32, 0), /** (0x33) Get caller address */ - CALLER(0x33), + CALLER(0x33, 0), /** (0x34) Get deposited value by the * instruction/transaction responsible * for this execution */ - CALLVALUE(0x34), + CALLVALUE(0x34, 0), /** (0x35) Get input data of current * environment */ - CALLDATALOAD(0x35), + CALLDATALOAD(0x35, 1), /** (0x36) Get size of input data in current * environment */ - CALLDATASIZE(0x36), + CALLDATASIZE(0x36, 0), /** (0x37) Copy input data in current * environment to memory */ - CALLDATACOPY(0x37), + CALLDATACOPY(0x37, 3), /** (0x38) Get size of code running in * current environment */ - CODESIZE(0x38), + CODESIZE(0x38, 0), /** (0x39) Copy code running in current * environment to memory */ - CODECOPY(0x39), // [len code_start mem_start CODECOPY] + CODECOPY(0x39, 3), // [len code_start mem_start CODECOPY] /** (0x3a) Get price of gas in current * environment */ - GASPRICE(0x3a), + GASPRICE(0x3a, 0), /** (0x3b) Get size of code running in * current environment with given offset */ - EXTCODESIZE(0x3b), + EXTCODESIZE(0x3b, 1), /** (0x3c) Copy code running in current * environment to memory with given offset */ - EXTCODECOPY(0x3c), + EXTCODECOPY(0x3c, 4), + - /* Block Information */ /** (0x40) Get hash of most recent * complete block */ - PREVHASH(0x40), + PREVHASH(0x40, 0), /** (0x41) Get the block’s coinbase address */ - COINBASE(0x41), + COINBASE(0x41, 0), /** (x042) Get the block’s timestamp */ - TIMESTAMP(0x42), + TIMESTAMP(0x42, 0), /** (0x43) Get the block’s number */ - NUMBER(0x43), + NUMBER(0x43, 0), /** (0x44) Get the block’s difficulty */ - DIFFICULTY(0x44), + DIFFICULTY(0x44, 0), /** (0x45) Get the block’s gas limit */ - GASLIMIT(0x45), + GASLIMIT(0x45, 0), /* Memory, Storage and Flow Operations */ - + /** (0x50) Remove item from stack */ - POP(0x50), + POP(0x50, 1), /** (0x53) Load word from memory */ - MLOAD(0x53), + MLOAD(0x53, 1), /** (0x54) Save word to memory */ - MSTORE(0x54), + MSTORE(0x54, 2), /** (0x55) Save byte to memory */ - MSTORE8(0x55), + MSTORE8(0x55, 2), /** (0x56) Load word from storage */ - SLOAD(0x56), + SLOAD(0x56, 1), /** (0x57) Save word to storage */ - SSTORE(0x57), + SSTORE(0x57, 2), /** (0x58) Alter the program counter */ - JUMP(0x58), + JUMP(0x58, 1), /** (0x59) Conditionally alter the program * counter */ - JUMPI(0x59), + JUMPI(0x59, 2), /** (0x5a) Get the program counter */ - PC(0x5a), + PC(0x5a, 0), /** (0x5b) Get the size of active memory */ - MSIZE(0x5b), + MSIZE(0x5b, 0), /** (0x5c) Get the amount of available gas */ - GAS(0x5c), + GAS(0x5c, 0), /** (0x5d) */ - JUMPDEST(0x5d), + JUMPDEST(0x5d, 0), /* Push Operations */ /** (0x60) Place 1-byte item on stack */ - PUSH1(0x60), + PUSH1(0x60, 0), /** (0x61) Place 2-byte item on stack */ - PUSH2(0x61), + PUSH2(0x61, 0), /** (0x62) Place 3-byte item on stack */ - PUSH3(0x62), + PUSH3(0x62, 0), /** (0x63) Place 4-byte item on stack */ - PUSH4(0x63), + PUSH4(0x63, 0), /** (0x64) Place 5-byte item on stack */ - PUSH5(0x64), + PUSH5(0x64, 0), /** (0x65) Place 6-byte item on stack */ - PUSH6(0x65), + PUSH6(0x65, 0), /** (0x66) Place 7-byte item on stack */ - PUSH7(0x66), + PUSH7(0x66, 0), /** (0x67) Place 8-byte item on stack */ - PUSH8(0x67), + PUSH8(0x67, 0), /** (0x68) Place 9-byte item on stack */ - PUSH9(0x68), + PUSH9(0x68, 0), /** (0x69) Place 10-byte item on stack */ - PUSH10(0x69), + PUSH10(0x69, 0), /** (0x6a) Place 11-byte item on stack */ - PUSH11(0x6a), + PUSH11(0x6a, 0), /** (0x6b) Place 12-byte item on stack */ - PUSH12(0x6b), + PUSH12(0x6b, 0), /** (0x6c) Place 13-byte item on stack */ - PUSH13(0x6c), + PUSH13(0x6c, 0), /** (0x6d) Place 14-byte item on stack */ - PUSH14(0x6d), + PUSH14(0x6d, 0), /** (0x6e) Place 15-byte item on stack */ - PUSH15(0x6e), + PUSH15(0x6e, 0), /** (0x6f) Place 16-byte item on stack */ - PUSH16(0x6f), + PUSH16(0x6f, 0), /** (0x70) Place 17-byte item on stack */ - PUSH17(0x70), + PUSH17(0x70, 0), /** (0x71) Place 18-byte item on stack */ - PUSH18(0x71), + PUSH18(0x71, 0), /** (0x72) Place 19-byte item on stack */ - PUSH19(0x72), + PUSH19(0x72, 0), /** (0x73) Place 20-byte item on stack */ - PUSH20(0x73), + PUSH20(0x73, 0), /** (0x74) Place 21-byte item on stack */ - PUSH21(0x74), + PUSH21(0x74, 0), /** (0x75) Place 22-byte item on stack */ - PUSH22(0x75), + PUSH22(0x75, 0), /** (0x76) Place 23-byte item on stack */ - PUSH23(0x76), + PUSH23(0x76, 0), /** (0x77) Place 24-byte item on stack */ - PUSH24(0x77), + PUSH24(0x77, 0), /** (0x78) Place 25-byte item on stack */ - PUSH25(0x78), + PUSH25(0x78, 0), /** (0x79) Place 26-byte item on stack */ - PUSH26(0x79), + PUSH26(0x79, 0), /** (0x7a) Place 27-byte item on stack */ - PUSH27(0x7a), + PUSH27(0x7a, 0), /** (0x7b) Place 28-byte item on stack */ - PUSH28(0x7b), + PUSH28(0x7b, 0), /** (0x7c) Place 29-byte item on stack */ - PUSH29(0x7c), + PUSH29(0x7c, 0), /** (0x7d) Place 30-byte item on stack */ - PUSH30(0x7d), + PUSH30(0x7d, 0), /** (0x7e) Place 31-byte item on stack */ - PUSH31(0x7e), + PUSH31(0x7e, 0), /** (0x7f) Place 32-byte (full word) * item on stack */ - PUSH32(0x7f), + PUSH32(0x7f, 0), /* Duplicate Nth item from the stack */ /** (0x80) Duplicate 1st item on stack */ - DUP1(0x80), + DUP1(0x80, 1), /** (0x81) Duplicate 2nd item on stack */ - DUP2(0x81), + DUP2(0x81, 2), /** (0x82) Duplicate 3rd item on stack */ - DUP3(0x82), + DUP3(0x82, 3), /** (0x83) Duplicate 4th item on stack */ - DUP4(0x83), + DUP4(0x83, 4), /** (0x84) Duplicate 5th item on stack */ - DUP5(0x84), + DUP5(0x84, 5), /** (0x85) Duplicate 6th item on stack */ - DUP6(0x85), + DUP6(0x85, 6), /** (0x86) Duplicate 7th item on stack */ - DUP7(0x86), + DUP7(0x86, 7), /** (0x87) Duplicate 8th item on stack */ - DUP8(0x87), + DUP8(0x87, 8), /** (0x88) Duplicate 9th item on stack */ - DUP9(0x88), + DUP9(0x88, 9), /** (0x89) Duplicate 10th item on stack */ - DUP10(0x89), + DUP10(0x89, 10), /** (0x8a) Duplicate 11th item on stack */ - DUP11(0x8a), + DUP11(0x8a, 11), /** (0x8b) Duplicate 12th item on stack */ - DUP12(0x8b), + DUP12(0x8b, 12), /** (0x8c) Duplicate 13th item on stack */ - DUP13(0x8c), + DUP13(0x8c, 13), /** (0x8d) Duplicate 14th item on stack */ - DUP14(0x8d), + DUP14(0x8d, 14), /** (0x8e) Duplicate 15th item on stack */ - DUP15(0x8e), + DUP15(0x8e, 15), /** (0x8f) Duplicate 16th item on stack */ - DUP16(0x8f), + DUP16(0x8f, 16), /* Swap the Nth item from the stack with the top */ /** (0x90) Exchange 2nd item from stack with the top */ - SWAP1(0x90), + SWAP1(0x90, 2), /** (0x91) Exchange 3rd item from stack with the top */ - SWAP2(0x91), + SWAP2(0x91, 3), /** (0x92) Exchange 4th item from stack with the top */ - SWAP3(0x92), + SWAP3(0x92, 4), /** (0x93) Exchange 5th item from stack with the top */ - SWAP4(0x93), + SWAP4(0x93, 5), /** (0x94) Exchange 6th item from stack with the top */ - SWAP5(0x94), + SWAP5(0x94, 6), /** (0x95) Exchange 7th item from stack with the top */ - SWAP6(0x95), + SWAP6(0x95, 7), /** (0x96) Exchange 8th item from stack with the top */ - SWAP7(0x96), + SWAP7(0x96, 8), /** (0x97) Exchange 9th item from stack with the top */ - SWAP8(0x97), + SWAP8(0x97, 9), /** (0x98) Exchange 10th item from stack with the top */ - SWAP9(0x98), + SWAP9(0x98, 10), /** (0x99) Exchange 11th item from stack with the top */ - SWAP10(0x99), + SWAP10(0x99, 11), /** (0x9a) Exchange 12th item from stack with the top */ - SWAP11(0x9a), + SWAP11(0x9a, 12), /** (0x9b) Exchange 13th item from stack with the top */ - SWAP12(0x9b), + SWAP12(0x9b, 13), /** (0x9c) Exchange 14th item from stack with the top */ - SWAP13(0x9c), + SWAP13(0x9c, 14), /** (0x9d) Exchange 15th item from stack with the top */ - SWAP14(0x9d), + SWAP14(0x9d, 15), /** (0x9e) Exchange 16th item from stack with the top */ - SWAP15(0x9e), + SWAP15(0x9e, 16), /** (0x9f) Exchange 17th item from stack with the top */ - SWAP16(0x9f), + SWAP16(0x9f, 17), /* System operations */ /** (0xf0) Create a new account with associated code */ - CREATE(0xf0), // [in_size] [in_offs] [gas_val] CREATE + CREATE(0xf0, 3), // [in_size] [in_offs] [gas_val] CREATE /** (cxf1) Message-call into an account */ - CALL(0xf1), // [out_data_size] [out_data_start] [in_data_size] [in_data_start] [value] [to_addr] [gas] CALL + CALL(0xf1, 7), // [out_data_size] [out_data_start] [in_data_size] [in_data_start] [value] [to_addr] [gas] CALL /** (0xf2) Halt execution returning output data */ - RETURN(0xf2), + RETURN(0xf2, 2), /** (0xf3) Calls self, but grabbing the code from the * TO argument instead of from one's own address */ - CALLCODE(0xf3), + CALLCODE(0xf3, 7), /** (0xff) Halt execution and register account for * later deletion */ - SUICIDE(0xff); + SUICIDE(0xff, 1); private byte opcode; + private int require; private static final Map intToTypeMap = new HashMap<>(); private static final Map stringToByteMap = new HashMap<>(); @@ -318,13 +319,23 @@ public enum OpCode { } } - private OpCode(int op) { + private OpCode(int op, int require) { this.opcode = (byte) op; + this.require = require; } public byte val() { return opcode; } + + /** + * Returns the mininum amount of items required on the stack for this operation + * + * @return minimum amount of expected items on the stack + */ + public int require() { + return require; + } public int asInt() { return opcode; diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/Program.java b/ethereumj-core/src/main/java/org/ethereum/vm/Program.java index e4080cfa..f52364ab 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/Program.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/Program.java @@ -24,8 +24,9 @@ import java.util.Stack; */ public class Program { - private Logger logger = LoggerFactory.getLogger("VM"); - private Logger gasLogger = LoggerFactory.getLogger("gas"); + private static final Logger logger = LoggerFactory.getLogger("VM"); + private static final Logger gasLogger = LoggerFactory.getLogger("gas"); + private int invokeHash; private ProgramListener listener; @@ -55,6 +56,12 @@ public class Program { } } + public byte getOp(int pc) { + if (ops.length <= pc) + return 0; + return ops[pc]; + } + public byte getCurrentOp() { if(ops.length == 0) return 0; @@ -93,9 +100,12 @@ public class Program { } public void setPC(DataWord pc) { + this.setPC(pc.intValue()); + } - this.pc = pc.intValue(); - + public void setPC(int pc) { + this.pc = pc; + if (this.pc == ops.length) stop(); @@ -105,10 +115,6 @@ public class Program { } } - public void setPC(int pc) { - this.pc = pc; - } - public boolean isStopped() { return stopped; } @@ -130,7 +136,7 @@ public class Program { if (pc + n > ops.length) { stop(); - throw new RuntimeException("pc overflow sweep n: " + n + " pc: " + pc); + throw new PcOverflowException("pc overflow sweep n: " + n + " pc: " + pc); } byte[] data = Arrays.copyOfRange(ops, pc, pc + n); @@ -257,12 +263,12 @@ public class Program { public void createContract(DataWord value, DataWord memStart, DataWord memSize) { // [1] FETCH THE CODE FROM THE MEMORY - ByteBuffer programCode = memoryChunk(memStart, memSize); + byte[] programCode = memoryChunk(memStart, memSize).array(); byte[] senderAddress = this.getOwnerAddress().getLast20Bytes(); if (logger.isInfoEnabled()) logger.info("creating a new contract inside contract run: [{}]", Hex.toHexString(senderAddress)); - + // actual gas subtract DataWord gasLimit = this.getGas(); this.spendGas(gasLimit.longValue(), "internal call"); @@ -272,16 +278,12 @@ public class Program { byte[] newAddress = HashUtil.calcNewAddr(this.getOwnerAddress().getLast20Bytes(), nonce); result.getRepository().createAccount(newAddress); - // [3] UPDATE THE NONCE - // (THIS STAGE IS NOT REVERTED BY ANY EXCEPTION) - result.getRepository().increaseNonce(senderAddress); - - if (invokeData.byTestingSuite()) { - // This keeps track of the contracts created for a test - this.getResult().addCallCreate(programCode.array(), newAddress, - gasLimit.getNoLeadZeroesData(), - value.getNoLeadZeroesData()); - } + if (invokeData.byTestingSuite()) { + // This keeps track of the contracts created for a test + this.getResult().addCallCreate(programCode, newAddress, + gasLimit.getNoLeadZeroesData(), + value.getNoLeadZeroesData()); + } // [4] TRANSFER THE BALANCE BigInteger endowment = value.value(); @@ -291,23 +293,32 @@ public class Program { return; } result.getRepository().addBalance(senderAddress, endowment.negate()); - result.getRepository().addBalance(newAddress, endowment); + BigInteger newBalance = result.getRepository().addBalance(newAddress, endowment); Repository trackRepository = result.getRepository().getTrack(); trackRepository.startTracking(); + + // [3] UPDATE THE NONCE + // (THIS STAGE IS NOT REVERTED BY ANY EXCEPTION) + trackRepository.increaseNonce(senderAddress); // [5] COOK THE INVOKE AND EXECUTE - ProgramInvoke programInvoke = - ProgramInvokeFactory.createProgramInvoke(this, new DataWord(newAddress), DataWord.ZERO, - gasLimit, BigInteger.ZERO, null, trackRepository, this.invokeData.getCallDeep() + 1); - - VM vm = new VM(); - Program program = new Program(programCode.array(), programInvoke); - vm.play(program); - ProgramResult result = program.getResult(); - this.result.addDeleteAccounts(result.getDeleteAccounts()); - - if (result.getException() != null && + ProgramInvoke programInvoke = ProgramInvokeFactory.createProgramInvoke( + this, new DataWord(newAddress), DataWord.ZERO, gasLimit, + newBalance, null, trackRepository); + + ProgramResult result = null; + + if (programCode != null && programCode.length != 0) { + VM vm = new VM(); + Program program = new Program(programCode, programInvoke); + vm.play(program); + result = program.getResult(); + this.result.addDeleteAccounts(result.getDeleteAccounts()); + } + + if (result != null && + result.getException() != null && result.getException() instanceof Program.OutOfGasException) { logger.info("contract run halted by OutOfGas: new contract init ={}" , Hex.toHexString(newAddress)); @@ -319,17 +330,18 @@ public class Program { // 4. CREATE THE CONTRACT OUT OF RETURN byte[] code = result.getHReturn().array(); trackRepository.saveCode(newAddress, code); - + trackRepository.commit(); + // IN SUCCESS PUSH THE ADDRESS INTO THE STACK stackPush(new DataWord(newAddress)); - trackRepository.commit(); - + // 5. REFUND THE REMAIN GAS + long refundGas = gasLimit.longValue() - result.getGasUsed(); if (refundGas > 0) { this.refundGas(refundGas, "remain gas from the internal call"); - if (logger.isInfoEnabled()) { - logger.info("The remaining gas is refunded, account: [{}], gas: [{}] ", + if (gasLogger.isInfoEnabled()) { + gasLogger.info("The remaining gas is refunded, account: [{}], gas: [{}] ", Hex.toHexString(this.getOwnerAddress().getLast20Bytes()), refundGas); } @@ -346,7 +358,7 @@ public class Program { */ public void callToAddress(MessageCall msg) { - ByteBuffer data = memoryChunk(msg.getInDataOffs(), msg.getInDataSize()); + byte[] data = memoryChunk(msg.getInDataOffs(), msg.getInDataSize()).array(); // FETCH THE SAVED STORAGE byte[] codeAddress = msg.getCodeAddress().getLast20Bytes(); @@ -363,12 +375,12 @@ public class Program { // 2.1 PERFORM THE GAS VALUE TX // (THIS STAGE IS NOT REVERTED BY ANY EXCEPTION) if (this.getGas().longValue() - msg.getGas().longValue() < 0 ) { - logger.info("No gas for the internal call, \n" + + gasLogger.info("No gas for the internal call, \n" + "fromAddress={}, codeAddress={}", Hex.toHexString(senderAddress), Hex.toHexString(codeAddress)); throw new OutOfGasException(); } - + BigInteger endowment = msg.getEndowment().value(); BigInteger senderBalance = result.getRepository().getBalance(senderAddress); if (senderBalance.compareTo(endowment) < 0) { @@ -377,11 +389,10 @@ public class Program { } result.getRepository().addBalance(senderAddress, endowment.negate()); BigInteger contextBalance = result.getRepository().addBalance(contextAddress, endowment); - + if (invokeData.byTestingSuite()) { // This keeps track of the calls created for a test - this.getResult().addCallCreate(data.array(), - contextAddress, + this.getResult().addCallCreate(data, contextAddress, msg.getGas().getNoLeadZeroesData(), msg.getEndowment().getNoLeadZeroesData()); } @@ -393,9 +404,8 @@ public class Program { trackRepository.startTracking(); ProgramInvoke programInvoke = ProgramInvokeFactory.createProgramInvoke( - this, new DataWord(contextAddress), msg.getEndowment(), msg.getGas(), - contextBalance, data.array(), trackRepository, - this.invokeData.getCallDeep() + 1); + this, new DataWord(contextAddress), msg.getEndowment(), + msg.getGas(), contextBalance, data, trackRepository); ProgramResult result = null; @@ -410,7 +420,7 @@ public class Program { if (result != null && result.getException() != null && result.getException() instanceof Program.OutOfGasException) { - logger.info("contract run halted by OutOfGas: contract={}" , Hex.toHexString(contextAddress)); + gasLogger.info("contract run halted by OutOfGas: contract={}" , Hex.toHexString(contextAddress)); trackRepository.rollback(); stackPushZero(); @@ -438,10 +448,12 @@ public class Program { // 5. REFUND THE REMAIN GAS if (result != null) { BigInteger refundGas = msg.getGas().value().subtract(BigInteger.valueOf(result.getGasUsed())); - if (refundGas.compareTo(BigInteger.ZERO) == 1) { + if (refundGas.signum() == 1) { this.refundGas(refundGas.longValue(), "remaining gas from the internal call"); - logger.info("The remaining gas refunded, account: [{}], gas: [{}] ", - Hex.toHexString(senderAddress), refundGas.toString()); + if(gasLogger.isInfoEnabled()) + gasLogger.info("The remaining gas refunded, account: [{}], gas: [{}] ", + Hex.toHexString(senderAddress), + refundGas.toString()); } } else { this.refundGas(msg.getGas().longValue(), "remaining gas from the internal call"); diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/ProgramInvokeFactory.java b/ethereumj-core/src/main/java/org/ethereum/vm/ProgramInvokeFactory.java index 002794cd..60999a0c 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/ProgramInvokeFactory.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/ProgramInvokeFactory.java @@ -4,6 +4,7 @@ import org.ethereum.core.Block; import org.ethereum.core.Transaction; import org.ethereum.facade.Repository; import org.ethereum.manager.WorldManager; +import org.ethereum.util.ByteUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongycastle.util.encoders.Hex; @@ -18,8 +19,16 @@ import java.math.BigInteger; */ public class ProgramInvokeFactory { - private static Logger logger = LoggerFactory.getLogger("VM"); + private static final Logger logger = LoggerFactory.getLogger("VM"); + /** + * This attribute defines the number of resursive calls allowed in the EVM + * Note: For the JVM to reach this level without a StackOverflow exception, + * ethereumj may need to be started with a JVM argument to increase + * the stack size. For example: -Xss10m + */ + private static final int MAX_CREATE_CALL_DEPTH = 1024; + // Invocation by the wire tx public static ProgramInvoke createProgramInvoke(Transaction tx, Block block, Repository repository) { @@ -28,7 +37,7 @@ public class ProgramInvokeFactory { /*** ADDRESS op ***/ // YP: Get address of currently executing account. - byte[] address = (tx.isContractCreation())? tx.getContractAddress(): tx.getReceiveAddress(); + byte[] address = tx.isContractCreation() ? tx.getContractAddress(): tx.getReceiveAddress(); /*** ORIGIN op ***/ // YP: This is the sender of original transaction; it is never a contract. @@ -53,8 +62,7 @@ public class ProgramInvokeFactory { /*** CALLDATALOAD op ***/ /*** CALLDATACOPY op ***/ /*** CALLDATASIZE op ***/ - byte[] data = tx.getData(); - if (data == null) data = new byte[]{}; + byte[] data = tx.getData() == null ? ByteUtil.EMPTY_BYTE_ARRAY : tx.getData(); /*** PREVHASH op ***/ byte[] lastHash = lastBlock.getHash(); @@ -122,7 +130,7 @@ public class ProgramInvokeFactory { public static ProgramInvoke createProgramInvoke(Program program, DataWord toAddress, DataWord inValue, DataWord inGas, BigInteger balanceInt, byte[] dataIn, - Repository repository, int callDeep) { + Repository repository) { DataWord address = toAddress; DataWord origin = program.getOriginAddress(); @@ -174,9 +182,14 @@ public class ProgramInvokeFactory { Hex.toHexString(difficulty.getNoLeadZeroesData()), gasLimit.longValue()); } + + int newCallDepth = program.invokeData.getCallDeep() + 1; + if (newCallDepth >= MAX_CREATE_CALL_DEPTH) { + throw program.new OutOfGasException(); + } return new ProgramInvokeImpl(address, origin, caller, balance, gasPrice, gas, callValue, data, lastHash, coinbase, timestamp, number, difficulty, gasLimit, - repository, callDeep); + repository, newCallDepth); } } diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/ProgramResult.java b/ethereumj-core/src/main/java/org/ethereum/vm/ProgramResult.java index becc0d75..a74068e1 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/ProgramResult.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/ProgramResult.java @@ -63,23 +63,16 @@ public class ProgramResult { this.repository = repository; } - public void addDeleteAccount(DataWord address){ - - if (deleteAccounts == null){ + public void addDeleteAccount(DataWord address) { + if (deleteAccounts == null) deleteAccounts = new ArrayList<>(); - } - deleteAccounts.add(address); } - public void addDeleteAccounts(List accounts){ - + public void addDeleteAccounts(List accounts) { if (accounts == null) return; - - if (deleteAccounts == null){ + if (deleteAccounts == null) deleteAccounts = new ArrayList<>(); - } - deleteAccounts.addAll(accounts); } diff --git a/ethereumj-core/src/main/java/org/ethereum/vm/VM.java b/ethereumj-core/src/main/java/org/ethereum/vm/VM.java index 7da3d63c..66a39fd6 100644 --- a/ethereumj-core/src/main/java/org/ethereum/vm/VM.java +++ b/ethereumj-core/src/main/java/org/ethereum/vm/VM.java @@ -62,8 +62,8 @@ import static org.ethereum.vm.OpCode.PUSH1; */ public class VM { - private Logger logger = LoggerFactory.getLogger("VM"); - private Logger dumpLogger = LoggerFactory.getLogger("dump"); + private static final Logger logger = LoggerFactory.getLogger("VM"); + private static final Logger dumpLogger = LoggerFactory.getLogger("dump"); private static BigInteger _32_ = BigInteger.valueOf(32); private static String logString = "[{}]\t Op: [{}] Gas: [{}] Deep: [{}] Hint: [{}]"; @@ -94,6 +94,8 @@ public class VM { long gasBefore = program.getGas().longValue(); int stepBefore = program.getPC(); + program.stackRequire(op.require()); + // Calculate fees and spend gas switch (op) { case STOP: case SUICIDE: @@ -101,7 +103,6 @@ public class VM { gasCost = GasCost.STOP; break; case SSTORE: - program.stackRequire(2); DataWord newValue = stack.get(stack.size()-2); DataWord oldValue = program.storageLoad(stack.peek()); if (oldValue == null && !newValue.isZero()) @@ -120,40 +121,31 @@ public class VM { // These all operate on memory and therefore potentially expand it: case MSTORE: - program.stackRequire(2); newMemSize = memNeeded(stack.peek(), new DataWord(32)); break; case MSTORE8: - program.stackRequire(2); newMemSize = memNeeded(stack.peek(), new DataWord(1)); break; case MLOAD: - program.stackRequire(1); newMemSize = memNeeded(stack.peek(), new DataWord(32)); break; case RETURN: - program.stackRequire(2); newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-2)); break; case SHA3: - program.stackRequire(2); gasCost = GasCost.SHA3; newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-2)); break; case CALLDATACOPY: - program.stackRequire(3); newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-3)); break; case CODECOPY: - program.stackRequire(3); newMemSize = memNeeded(stack.peek(), stack.get(stack.size()-3)); break; case EXTCODECOPY: - program.stackRequire(4); newMemSize = memNeeded(stack.get(stack.size()-2), stack.get(stack.size()-4)); break; case CALL: case CALLCODE: - program.stackRequire(7); gasCost = GasCost.CALL; DataWord callGasWord = stack.get(stack.size()-1); if(callGasWord.compareTo(program.getGas()) == 1) { @@ -165,7 +157,6 @@ public class VM { newMemSize = in.max(out); break; case CREATE: - program.stackRequire(3); gasCost = GasCost.CREATE; newMemSize = memNeeded(stack.get(stack.size()-2), stack.get(stack.size()-3)); break; @@ -202,7 +193,6 @@ public class VM { program.stop(); } break; case ADD:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -215,7 +205,6 @@ public class VM { } break; case MUL:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -227,7 +216,6 @@ public class VM { program.step(); } break; case SUB:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -239,7 +227,6 @@ public class VM { program.step(); } break; case DIV:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -251,7 +238,6 @@ public class VM { program.step(); } break; case SDIV:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -263,7 +249,6 @@ public class VM { program.step(); } break; case MOD:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -275,7 +260,6 @@ public class VM { program.step(); } break; case SMOD:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -287,7 +271,6 @@ public class VM { program.step(); } break; case EXP:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -299,7 +282,6 @@ public class VM { program.step(); } break; case NEG:{ - program.stackRequire(1); DataWord word1 = program.stackPop(); word1.negate(); @@ -310,7 +292,6 @@ public class VM { program.step(); } break; case LT:{ - program.stackRequire(2); // TODO: can be improved by not using BigInteger DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -328,7 +309,6 @@ public class VM { program.step(); } break; case SLT:{ - program.stackRequire(2); // TODO: can be improved by not using BigInteger DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -346,7 +326,6 @@ public class VM { program.step(); } break; case SGT:{ - program.stackRequire(2); // TODO: can be improved by not using BigInteger DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -364,7 +343,6 @@ public class VM { program.step(); } break; case GT:{ - program.stackRequire(2); // TODO: can be improved by not using BigInteger DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -382,7 +360,6 @@ public class VM { program.step(); } break; case EQ:{ - program.stackRequire(2); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -399,7 +376,6 @@ public class VM { program.step(); } break; case NOT: { - program.stackRequire(1); DataWord word1 = program.stackPop(); if (word1.isZero()) { word1.getData()[31] = 1; @@ -417,8 +393,7 @@ public class VM { /** * Bitwise Logic Operations */ - case AND:{ - program.stackRequire(2); + case AND:{ DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -429,8 +404,7 @@ public class VM { program.stackPush(word1); program.step(); } break; - case OR: { - program.stackRequire(2); + case OR: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -441,8 +415,7 @@ public class VM { program.stackPush(word1); program.step(); } break; - case XOR: { - program.stackRequire(2); + case XOR: { DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); @@ -453,8 +426,7 @@ public class VM { program.stackPush(word1); program.step(); } break; - case BYTE:{ - program.stackRequire(2); + case BYTE:{ DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); DataWord result = null; @@ -474,7 +446,6 @@ public class VM { program.step(); } break; case ADDMOD:{ - program.stackRequire(3); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); DataWord word3 = program.stackPop(); @@ -483,7 +454,6 @@ public class VM { program.step(); } break; case MULMOD:{ - program.stackRequire(3); DataWord word1 = program.stackPop(); DataWord word2 = program.stackPop(); DataWord word3 = program.stackPop(); @@ -495,8 +465,7 @@ public class VM { /** * SHA3 */ - case SHA3:{ - program.stackRequire(2); + case SHA3:{ DataWord memOffsetData = program.stackPop(); DataWord lengthData = program.stackPop(); ByteBuffer buffer = program.memoryChunk(memOffsetData, lengthData); @@ -524,7 +493,6 @@ public class VM { program.step(); } break; case BALANCE:{ - program.stackRequire(1); DataWord address = program.stackPop(); DataWord balance = program.getBalance(address); @@ -563,8 +531,7 @@ public class VM { program.stackPush(callValue); program.step(); } break; - case CALLDATALOAD:{ - program.stackRequire(1); + case CALLDATALOAD:{ DataWord dataOffs = program.stackPop(); DataWord value = program.getDataValue(dataOffs); @@ -583,8 +550,7 @@ public class VM { program.stackPush(dataSize); program.step(); } break; - case CALLDATACOPY:{ - program.stackRequire(3); + case CALLDATACOPY:{ DataWord memOffsetData = program.stackPop(); DataWord dataOffsetData = program.stackPop(); DataWord lengthData = program.stackPop(); @@ -603,7 +569,6 @@ public class VM { if (op == OpCode.CODESIZE) length = program.getCode().length; else { - program.stackRequire(1); DataWord address = program.stackPop(); length = program.getCodeAt(address).length; } @@ -624,18 +589,20 @@ public class VM { fullCode = program.getCodeAt(address); } - DataWord memOffsetData = program.stackPop(); - DataWord codeOffsetData = program.stackPop(); - DataWord lengthData = program.stackPop(); + DataWord memOffsetData = program.stackPop(); + BigInteger codeOffsetData = program.stackPop().value(); + BigInteger lengthData = program.stackPop().value(); - int length = lengthData.intValue(); - int codeOffset = codeOffsetData.intValue(); - - if (fullCode == null || fullCode.length < length + codeOffset) { + if (fullCode == null + || BigInteger.valueOf(fullCode.length).compareTo( + codeOffsetData.add(lengthData)) < 0) { program.stop(); break; } + int length = lengthData.intValue(); + int codeOffset = codeOffsetData.intValue(); + byte[] codeCopy = new byte[length]; System.arraycopy(fullCode, codeOffset, codeCopy, 0, length); @@ -713,7 +680,6 @@ public class VM { program.step(); } break; case POP:{ - program.stackRequire(1); program.stackPop(); program.step(); } break; @@ -723,7 +689,6 @@ public class VM { case DUP13: case DUP14: case DUP15: case DUP16:{ int n = op.val() - OpCode.DUP1.val() + 1; - program.stackRequire(n); DataWord word_1 = stack.get(stack.size() - n); program.stackPush(word_1.clone()); program.step(); @@ -735,7 +700,6 @@ public class VM { case SWAP13: case SWAP14: case SWAP15: case SWAP16:{ int n = op.val() - OpCode.SWAP1.val() + 2; - program.stackRequire(n); DataWord word_1 = stack.peek(); stack.set(stack.size() - 1, stack.get(stack.size() - n)); stack.set(stack.size() - n, word_1); @@ -743,7 +707,6 @@ public class VM { } break; case MLOAD:{ - program.stackRequire(1); DataWord addr = program.stackPop(); DataWord data = program.memoryLoad(addr); @@ -754,7 +717,6 @@ public class VM { program.step(); } break; case MSTORE:{ - program.stackRequire(2); DataWord addr = program.stackPop(); DataWord value = program.stackPop(); @@ -765,7 +727,6 @@ public class VM { program.step(); } break; case MSTORE8:{ - program.stackRequire(2); DataWord addr = program.stackPop(); DataWord value = program.stackPop(); byte[] byteVal = {value.getData()[31]}; @@ -773,7 +734,6 @@ public class VM { program.step(); } break; case SLOAD:{ - program.stackRequire(1); DataWord key = program.stackPop(); DataWord val = program.storageLoad(key); @@ -787,7 +747,6 @@ public class VM { program.step(); } break; case SSTORE:{ - program.stackRequire(2); DataWord addr = program.stackPop(); DataWord value = program.stackPop(); @@ -798,32 +757,34 @@ public class VM { program.step(); } break; case JUMP:{ - program.stackRequire(1); DataWord pos = program.stackPop(); -// if (!pos.equals(DataWord.ZERO) && OpCode.code(program.getCurrentOp()) != OpCode.JUMPDEST) -// throw new BadJumpDestinationException(); + int nextPC = pos.intValue(); // possible overflow + if (nextPC != 0 && program.getOp(nextPC-1) != OpCode.JUMPDEST.val()) + throw new BadJumpDestinationException(); if (logger.isInfoEnabled()) - hint = "~> " + pos.value(); + hint = "~> " + nextPC; + + program.setPC(nextPC); - program.setPC(pos); } break; case JUMPI:{ - program.stackRequire(2); DataWord pos = program.stackPop(); DataWord cond = program.stackPop(); -// if (!pos.isZero() && OpCode.code(program.getCurrentOp()) != OpCode.JUMPDEST) -// throw new BadJumpDestinationException(); - + if (!cond.isZero()) { - program.setPC(pos); + int nextPC = pos.intValue(); // possible overflow + if (nextPC != 0 && program.getOp(nextPC-1) != OpCode.JUMPDEST.val()) + throw new BadJumpDestinationException(); + + if (logger.isInfoEnabled()) + hint = "~> " + nextPC; + + program.setPC(nextPC); } else { program.step(); } - - if (logger.isInfoEnabled()) - hint = "~> " + program.getPC(); - + } break; case PC:{ int pc = program.getPC(); @@ -868,9 +829,9 @@ public class VM { program.stackPush(data); } break; case JUMPDEST:{ + program.step(); } break; case CREATE:{ - program.stackRequire(3); DataWord value = program.stackPop(); DataWord inOffset = program.stackPop(); DataWord inSize = program.stackPop(); @@ -887,7 +848,7 @@ public class VM { } break; case CALL: case CALLCODE: { DataWord gas = program.stackPop(); - DataWord codeAddress = program.stackPop(); + DataWord codeAddress = program.stackPop(); DataWord value = program.stackPop(); DataWord inDataOffs = program.stackPop(); @@ -916,7 +877,6 @@ public class VM { program.step(); } break; case RETURN:{ - program.stackRequire(2); DataWord offset = program.stackPop(); DataWord size = program.stackPop(); @@ -932,7 +892,6 @@ public class VM { program.stop(); } break; case SUICIDE:{ - program.stackRequire(1); DataWord address = program.stackPop(); program.suicide(address); @@ -953,12 +912,9 @@ public class VM { vmCounter++; } catch (RuntimeException e) { - if(e instanceof OutOfGasException) { - logger.warn("OutOfGasException occurred", e); + if(e instanceof OutOfGasException) program.spendAllGas(); - } - else - logger.error("VM halted", e); + logger.warn("VM halted", e.getMessage()); program.stop(); throw e; } @@ -981,8 +937,8 @@ public class VM { program.setRuntimeFailure(e); } } - - /** + + /** * Utility to calculate new total memory size needed for an operation. *
Basically just offset + size, unless size is 0, in which case the result is also 0. * diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java new file mode 100644 index 00000000..9de2035e --- /dev/null +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuite.java @@ -0,0 +1,46 @@ +package org.ethereum.jsontestsuite; + +import java.util.Iterator; +import java.util.List; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Test file specific for tests maintained in the GitHub repository + * by the Ethereum DEV team.
+ * + * @see https://github.com/ethereum/tests/ + */ +@RunWith(Suite.class) +@SuiteClasses({ + GitHubVMTest.class, + GitHubRandomTest.class +}) +public class GitHubJSONTestSuite { + + protected static void runGitHubJsonTest(String json) throws ParseException { + Assume.assumeFalse("Online test is not available", json.equals("")); + + JSONParser parser = new JSONParser(); + JSONObject testSuiteObj = (JSONObject)parser.parse(json); + + TestSuite testSuite = new TestSuite(testSuiteObj); + Iterator testIterator = testSuite.iterator(); + + while (testIterator.hasNext()){ + + TestCase testCase = testIterator.next(); + + TestRunner runner = new TestRunner(); + List result = runner.runTestCase(testCase); + Assert.assertTrue(result.isEmpty()); + } + } +} diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuiteTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuiteTest.java deleted file mode 100644 index aebceb21..00000000 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubJSONTestSuiteTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.ethereum.jsontestsuite; - -import java.util.Iterator; -import java.util.List; - -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Test; - -/** - * Test file specific for tests maintained in the GitHub repository - * by the Ethereum DEV team.
- * - * @see https://github.com/ethereum/tests/ - */ -public class GitHubJSONTestSuiteTest { - - @Test // testing full suite - public void testArithmeticFromGitHub() throws ParseException { - - String json = JSONReader.loadJSON("vmArithmeticTest.json"); - runGitHubJsonTest(json); - } - - @Test // testing full suite - public void testBitwiseLogicOperationFromGitHub() throws ParseException { - - String json = JSONReader.loadJSON("vmBitwiseLogicOperationTest.json"); - runGitHubJsonTest(json); - } - - @Test // testing full suite - public void testBlockInfoFromGitHub() throws ParseException { - - String json = JSONReader.loadJSON("vmBlockInfoTest.json"); - runGitHubJsonTest(json); - } - - @Test // testing full suite - public void testEnvironmentalInfoFromGitHub() throws ParseException { - - String json = JSONReader.loadJSON("vmEnvironmentalInfoTest.json"); - runGitHubJsonTest(json); - } - - @Test // testing full suite - public void testIOandFlowOperationsFromGitHub() throws ParseException { - - String json = JSONReader.loadJSON("vmIOandFlowOperationsTest.json"); - runGitHubJsonTest(json); - } - - @Test // testing full suite - public void testPushDupSwapFromGitHub() throws ParseException { - - String json = JSONReader.loadJSON("vmPushDupSwapTest.json"); - runGitHubJsonTest(json); - } - - @Test // testing full suite - public void testShaFromGitHub() throws ParseException { - - String json = JSONReader.loadJSON("vmSha3Test.json"); - runGitHubJsonTest(json); - } - - @Test // testing full suite - public void testSystemOperationsFromGitHub() throws ParseException { - - String json = JSONReader.loadJSON("vmSystemOperationsTest.json"); - runGitHubJsonTest(json); - } - - private void runGitHubJsonTest(String json) throws ParseException { - Assume.assumeFalse("Online test is not available", json.equals("")); - - JSONParser parser = new JSONParser(); - JSONObject testSuiteObj = (JSONObject)parser.parse(json); - - TestSuite testSuite = new TestSuite(testSuiteObj); - Iterator testIterator = testSuite.iterator(); - - while (testIterator.hasNext()){ - - TestCase testCase = testIterator.next(); - - TestRunner runner = new TestRunner(); - List result = runner.runTestCase(testCase); - Assert.assertTrue(result.isEmpty()); - } - } -} diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubRandomTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubRandomTest.java new file mode 100644 index 00000000..7d5541fe --- /dev/null +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubRandomTest.java @@ -0,0 +1,23 @@ +package org.ethereum.jsontestsuite; + +import org.json.simple.parser.ParseException; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class GitHubRandomTest { + + @Test // testing full suite + public void testRandom04FromGitHub() throws ParseException { + String json = JSONReader.loadJSON("randomTests/201410211705.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + + @Test // testing full suite + public void testRandom06FromGitHub() throws ParseException { + String json = JSONReader.loadJSON("randomTests/201410211708.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + +} diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubVMTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubVMTest.java new file mode 100644 index 00000000..c02711e7 --- /dev/null +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/GitHubVMTest.java @@ -0,0 +1,66 @@ +package org.ethereum.jsontestsuite; + +import org.json.simple.parser.ParseException; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class GitHubVMTest { + + @Test // testing full suite + public void testArithmeticFromGitHub() throws ParseException { + + String json = JSONReader.loadJSON("vmtests/vmArithmeticTest.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + + @Test // testing full suite + public void testBitwiseLogicOperationFromGitHub() throws ParseException { + + String json = JSONReader.loadJSON("vmtests/vmBitwiseLogicOperationTest.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + + @Test // testing full suite + public void testBlockInfoFromGitHub() throws ParseException { + + String json = JSONReader.loadJSON("vmtests/vmBlockInfoTest.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + + @Test // testing full suite + public void testEnvironmentalInfoFromGitHub() throws ParseException { + + String json = JSONReader.loadJSON("vmtests/vmEnvironmentalInfoTest.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + + @Test // testing full suite + public void testIOandFlowOperationsFromGitHub() throws ParseException { + + String json = JSONReader.loadJSON("vmtests/vmIOandFlowOperationsTest.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + + @Test // testing full suite + public void testPushDupSwapFromGitHub() throws ParseException { + + String json = JSONReader.loadJSON("vmtests/vmPushDupSwapTest.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + + @Test // testing full suite + public void testShaFromGitHub() throws ParseException { + + String json = JSONReader.loadJSON("vmtests/vmSha3Test.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } + + @Test // testing full suite + public void testSystemOperationsFromGitHub() throws ParseException { + + String json = JSONReader.loadJSON("vmtests/vmSystemOperationsTest.json"); + GitHubJSONTestSuite.runGitHubJsonTest(json); + } +} diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/JSONReader.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/JSONReader.java index 0ec8db9b..9d142ec6 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/JSONReader.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/JSONReader.java @@ -12,7 +12,8 @@ import java.nio.file.Files; public class JSONReader { public static String loadJSON(String filename) { - String json = getFromUrl("https://raw.githubusercontent.com/ethereum/tests/master/vmtests/" + filename); +// return getFromLocal(filename); + String json = getFromUrl("https://raw.githubusercontent.com/ethereum/tests/develop/" + filename); return json == "" ? json = getFromLocal(filename) : json; } diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/LocalJSONTestSuiteTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/LocalJSONTestSuiteTest.java index fd6d1572..8ef84097 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/LocalJSONTestSuiteTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/LocalJSONTestSuiteTest.java @@ -1,11 +1,6 @@ package org.ethereum.jsontestsuite; -import java.io.File; -import java.io.IOException; import java.math.BigInteger; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; import java.util.List; import org.ethereum.db.ByteArrayWrapper; @@ -173,110 +168,52 @@ public class LocalJSONTestSuiteTest { TestRunner runner = new TestRunner(); List result = runner.runTestCase(testCase); - Assert.assertTrue(result.size() == 0); - } @Test // TestCase file: vmtest-1.json // - public void test6() throws ParseException, IOException, URISyntaxException { - - String testSrc = JSONReader.getFromLocal("vmtest-1.json"); - - JSONParser parser = new JSONParser(); - JSONObject testCaseJSONObj = (JSONObject)parser.parse(testSrc); - - TestSuite testSuite = new TestSuite(testCaseJSONObj); - - TestRunner runner = new TestRunner(); - List result = runner.runTestSuite(testSuite); - - Assert.assertTrue(result.size() == 0); + public void test6() { + String vmtest = JSONReader.getFromLocal("vmtest-1.json"); + runTest(vmtest); } - @Test // TestCase file: vmtest-2.json // - public void test7() throws ParseException, IOException, URISyntaxException { - - URL vmtest = ClassLoader - .getSystemResource("jsontestsuite/vmtest-2.json"); - - File vmTestFile = new File(vmtest.toURI()); - byte[] testData = Files.readAllBytes(vmTestFile.toPath()); - String testSrc = new String(testData); - - JSONParser parser = new JSONParser(); - JSONObject testCaseJSONObj = (JSONObject)parser.parse(testSrc); - - TestSuite testSuite = new TestSuite(testCaseJSONObj); - - TestRunner runner = new TestRunner(); - List result = runner.runTestSuite(testSuite); - - Assert.assertTrue(result.size() == 0); + public void test7() { + String vmtest = JSONReader.getFromLocal("vmtest-2.json"); + runTest(vmtest); } @Test // TestCase file: vmtest-3.json // - public void test8() throws ParseException, IOException, URISyntaxException { - - URL vmtest = ClassLoader - .getSystemResource("jsontestsuite/vmtest-3.json"); - - File vmTestFile = new File(vmtest.toURI()); - byte[] testData = Files.readAllBytes(vmTestFile.toPath()); - String testSrc = new String(testData); - - JSONParser parser = new JSONParser(); - JSONObject testCaseJSONObj = (JSONObject)parser.parse(testSrc); - - TestSuite testSuite = new TestSuite(testCaseJSONObj); - - TestRunner runner = new TestRunner(); - List result = runner.runTestSuite(testSuite); - - Assert.assertTrue(result.size() == 0); - } - - - @Test // TestCase file: vmtest-4.json // - public void test9() throws ParseException, IOException, URISyntaxException { - - URL vmtest = ClassLoader - .getSystemResource("jsontestsuite/vmtest-4.json"); - - File vmTestFile = new File(vmtest.toURI()); - byte[] testData = Files.readAllBytes(vmTestFile.toPath()); - String testSrc = new String(testData); - - JSONParser parser = new JSONParser(); - JSONObject testCaseJSONObj = (JSONObject)parser.parse(testSrc); - - TestSuite testSuite = new TestSuite(testCaseJSONObj); - - TestRunner runner = new TestRunner(); - List result = runner.runTestSuite(testSuite); - - Assert.assertTrue(result.size() == 0); + public void test8() { + String vmtest = JSONReader.getFromLocal("vmtest-3.json"); + runTest(vmtest); } @Test // TestCase file: vmtest-4.json // - public void test10() throws ParseException, IOException, URISyntaxException { + public void test9() { + String vmtest = JSONReader.getFromLocal("vmtest-4.json"); + runTest(vmtest); + } - URL vmtest = ClassLoader - .getSystemResource("jsontestsuite/vmtest-5.json"); - - File vmTestFile = new File(vmtest.toURI()); - byte[] testData = Files.readAllBytes(vmTestFile.toPath()); - String testSrc = new String(testData); - - JSONParser parser = new JSONParser(); - JSONObject testCaseJSONObj = (JSONObject)parser.parse(testSrc); - - TestSuite testSuite = new TestSuite(testCaseJSONObj); - - TestRunner runner = new TestRunner(); - List result = runner.runTestSuite(testSuite); - - Assert.assertTrue(result.size() == 0); + @Test // TestCase file: vmtest-5.json // + public void test10() { + String vmtest = JSONReader.getFromLocal("vmtest-5.json"); + runTest(vmtest); + } + + private void runTest(String vmtest) { + try { + JSONParser parser = new JSONParser(); + JSONObject testCaseJSONObj = (JSONObject)parser.parse(vmtest); + + TestSuite testSuite = new TestSuite(testCaseJSONObj); + + TestRunner runner = new TestRunner(); + List result = runner.runTestSuite(testSuite); + + Assert.assertTrue(result.size() == 0); + } catch (ParseException e) { + Assert.fail(e.getMessage()); + } } } diff --git a/ethereumj-core/src/test/java/org/ethereum/vm/VMComplexTest.java b/ethereumj-core/src/test/java/org/ethereum/vm/VMComplexTest.java index d294405a..1a82d881 100644 --- a/ethereumj-core/src/test/java/org/ethereum/vm/VMComplexTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/vm/VMComplexTest.java @@ -47,7 +47,7 @@ public class VMComplexTest { // Set contract into Database String callerAddr = "cd2a3d9f938e13cd947ec05abc7fe734df8dd826"; String contractAddr = "77045e71a7a2c50903d88e564cd72fab11e82051"; - String code = "6103e75660005460006000530b0f630000004b596001600053036103e757600060006000600060007377045e71a7a2c50903d88e564cd72fab11e820516008600a5c0402f1630000004c5800"; + String code = "6103e75660005460006000530b0f630000004c596001600053036103e757600060006000600060007377045e71a7a2c50903d88e564cd72fab11e820516008600a5c0402f1630000004c585d00"; byte[] contractAddrB = Hex.decode(contractAddr); byte[] callerAddrB = Hex.decode(callerAddr); diff --git a/ethereumj-core/src/test/java/org/ethereum/vm/VMCustomTest.java b/ethereumj-core/src/test/java/org/ethereum/vm/VMCustomTest.java new file mode 100644 index 00000000..d2f4853e --- /dev/null +++ b/ethereumj-core/src/test/java/org/ethereum/vm/VMCustomTest.java @@ -0,0 +1,561 @@ +package org.ethereum.vm; + +import org.ethereum.vm.Program.OutOfGasException; +import org.ethereum.vm.Program.StackTooSmallException; +import org.junit.After; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; +import org.spongycastle.util.encoders.Hex; + +import java.math.BigInteger; + +import static org.junit.Assert.*; + +/** + * www.ethereumJ.com + * @author: Roman Mandeleil + * Created on: 01/06/2014 11:05 + */ + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class VMCustomTest { + + private ProgramInvokeMockImpl invoke; + private Program program; + + @Before + public void setup() { + byte[] ownerAddress = Hex.decode("77045E71A7A2C50903D88E564CD72FAB11E82051"); + byte[] msgData = Hex.decode("00000000000000000000000000000000000000000000000000000000000000A1" + + "00000000000000000000000000000000000000000000000000000000000000B1"); + + invoke = new ProgramInvokeMockImpl(msgData); + invoke.setOwnerAddress(ownerAddress); + + invoke.getRepository().createAccount(ownerAddress); + invoke.getRepository().addBalance(ownerAddress, BigInteger.valueOf(1000L)); + } + + @After + public void tearDown() { + invoke.getRepository().close(); + } + + @Test // CALLDATASIZE OP + public void testCALLDATASIZE_1() { + + VM vm = new VM(); + program = new Program(Hex.decode("36"), invoke); + String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000040"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + + @Test // CALLDATALOAD OP + public void testCALLDATALOAD_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("600035"), invoke); + String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000A1"; + + vm.step(program); + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // CALLDATALOAD OP + public void testCALLDATALOAD_2() { + + VM vm = new VM(); + program = + new Program(Hex.decode("600235"), invoke); + String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000A10000"; + + vm.step(program); + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + + @Test // CALLDATALOAD OP + public void testCALLDATALOAD_3() { + + VM vm = new VM(); + program = + new Program(Hex.decode("602035"), invoke); + String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000B1"; + + vm.step(program); + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + + @Test // CALLDATALOAD OP + public void testCALLDATALOAD_4() { + + VM vm = new VM(); + program = + new Program(Hex.decode("602335"), invoke); + String s_expected_1 = "00000000000000000000000000000000000000000000000000000000B1000000"; + + vm.step(program); + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // CALLDATALOAD OP + public void testCALLDATALOAD_5() { + + VM vm = new VM(); + program = + new Program(Hex.decode("603F35"), invoke); + String s_expected_1 = "B100000000000000000000000000000000000000000000000000000000000000"; + + vm.step(program); + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test(expected=RuntimeException.class) // CALLDATALOAD OP mal + public void testCALLDATALOAD_6() { + + VM vm = new VM(); + program = + new Program(Hex.decode("35"), invoke); + try { + vm.step(program); + } finally { + assertTrue(program.isStopped()); + } + } + + @Test // CALLDATACOPY OP + public void testCALLDATACOPY_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("60206000600037"), invoke); + String m_expected = "00000000000000000000000000000000000000000000000000000000000000A1"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); + } + + @Test // CALLDATACOPY OP + public void testCALLDATACOPY_2() { + + VM vm = new VM(); + program = + new Program(Hex.decode("60406000600037"), invoke); + String m_expected = "00000000000000000000000000000000000000000000000000000000000000A1" + + "00000000000000000000000000000000000000000000000000000000000000B1"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); + } + + + @Test // CALLDATACOPY OP + public void testCALLDATACOPY_3() { + + VM vm = new VM(); + program = + new Program(Hex.decode("60406004600037"), invoke); + String m_expected = "000000000000000000000000000000000000000000000000000000A100000000" + + "000000000000000000000000000000000000000000000000000000B100000000"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); + } + + + @Test // CALLDATACOPY OP + public void testCALLDATACOPY_4() { + + VM vm = new VM(); + program = + new Program(Hex.decode("60406000600437"), invoke); + String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + + "000000A100000000000000000000000000000000000000000000000000000000" + + "000000B100000000000000000000000000000000000000000000000000000000"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); + } + + @Test // CALLDATACOPY OP + public void testCALLDATACOPY_5() { + + VM vm = new VM(); + program = + new Program(Hex.decode("60406000600437"), invoke); + String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + + "000000A100000000000000000000000000000000000000000000000000000000" + + "000000B100000000000000000000000000000000000000000000000000000000"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); + } + + + @Test(expected=StackTooSmallException.class) // CALLDATACOPY OP mal + public void testCALLDATACOPY_6() { + + VM vm = new VM(); + program = + new Program(Hex.decode("6040600037"), invoke); + + try { + vm.step(program); + vm.step(program); + vm.step(program); + } finally { + assertTrue(program.isStopped()); + } + } + + @Test(expected=OutOfGasException.class) // CALLDATACOPY OP mal + public void testCALLDATACOPY_7() { + + VM vm = new VM(); + program = + new Program(Hex.decode("6020600073CC0929EB16730E7C14FEFC63006AC2D794C5795637"), invoke); + + try { + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + } finally { + assertTrue(program.isStopped()); + } + } + + @Test // ADDRESS OP + public void testADDRESS_1() { + + VM vm = new VM(); + program = new Program(Hex.decode("30"), invoke); + String s_expected_1 = "00000000000000000000000077045E71A7A2C50903D88E564CD72FAB11E82051"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + program.getResult().getRepository().close(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // BALANCE OP + public void testBALANCE_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("3031"), invoke); + String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000003E8"; + + vm.step(program); + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // ORIGIN OP + public void testORIGIN_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("32"), invoke); + String s_expected_1 = "00000000000000000000000013978AEE95F38490E9769C39B2773ED763D9CD5F"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // CALLER OP + public void testCALLER_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("33"), invoke); + String s_expected_1 = "000000000000000000000000885F93EED577F2FC341EBB9A5C9B2CE4465D96C4"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // CALLVALUE OP + public void testCALLVALUE_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("34"), invoke); + String s_expected_1 = "0000000000000000000000000000000000000000000000000DE0B6B3A7640000"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // SHA3 OP + public void testSHA3_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("60016000556001600020"), invoke); + String s_expected_1 = "5FE7F977E71DBA2EA1A68E21057BEEBB9BE2AC30C6410AA38D4F3FBE41DCFFD2"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // SHA3 OP + public void testSHA3_2() { + + VM vm = new VM(); + program = + new Program(Hex.decode("6102016000546002601E20"), invoke); + String s_expected_1 = "114A3FE82A0219FCC31ABD15617966A125F12B0FD3409105FC83B487A9D82DE4"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test(expected=StackTooSmallException.class) // SHA3 OP mal + public void testSHA3_3() { + + VM vm = new VM(); + program = + new Program(Hex.decode("610201600054600220"), invoke); + try { + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + } finally { + assertTrue(program.isStopped()); + } + } + + @Test // PREVHASH OP + public void testPREVHASH_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("40"), invoke); + String s_expected_1 = "961CB117ABA86D1E596854015A1483323F18883C2D745B0BC03E87F146D2BB1C"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // COINBASE OP + public void testCOINBASE_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("41"), invoke); + String s_expected_1 = "000000000000000000000000E559DE5527492BCB42EC68D07DF0742A98EC3F1E"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // TIMESTAMP OP + public void testTIMESTAMP_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("42"), invoke); + String s_expected_1 = "000000000000000000000000000000000000000000000000000000005387FE24"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // NUMBER OP + public void testNUMBER_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("43"), invoke); + String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000021"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // DIFFICULTY OP + public void testDIFFICULTY_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("44"), invoke); + String s_expected_1 = "00000000000000000000000000000000000000000000000000000000003ED290"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // GASPRICE OP + public void testGASPRICE_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("3A"), invoke); + String s_expected_1 = "000000000000000000000000000000000000000000000000000009184E72A000"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // GAS OP + public void testGAS_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("5C"), invoke); + String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000F423F"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test // GASLIMIT OP + public void testGASLIMIT_1() { + + VM vm = new VM(); + program = + new Program(Hex.decode("45"), invoke); + String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000F4240"; + + vm.step(program); + + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + + @Test(expected=Program.IllegalOperationException.class) // INVALID OP + public void testINVALID_1() { + + VM vm = new VM(); + program = new Program(Hex.decode("6001516002"), invoke); + String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; + + try { + vm.step(program); + vm.step(program); + } finally { + assertTrue(program.isStopped()); + DataWord item1 = program.stackPop(); + assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); + } + } + + /* TEST CASE LIST END */ + +} + +// TODO: add gas expeted and calculated to all test cases +// TODO: considering: G_TXDATA + G_TRANSACTION + +/** + * TODO: + * + * 22) CREATE: + * 23) CALL: + * + * + **/ + +/** + + contract creation (gas usage) + ----------------------------- + G_TRANSACTION = (500) + 60016000546006601160003960066000f261778e600054 (115) + PUSH1 6001 (1) + PUSH1 6000 (1) + MSTORE 54 (1 + 1) + PUSH1 6006 (1) + PUSH1 6011 (1) + PUSH1 6000 (1) + CODECOPY 39 (1) + PUSH1 6006 (1) + PUSH1 6000 (1) + RETURN f2 (1) + 61778e600054 + +*/ diff --git a/ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java b/ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java index a5a70fa1..57441538 100644 --- a/ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/vm/VMTest.java @@ -2,16 +2,15 @@ package org.ethereum.vm; import org.ethereum.facade.Repository; import org.ethereum.util.ByteUtil; -import org.ethereum.vm.Program.OutOfGasException; -import org.ethereum.vm.Program.PcOverflowException; import org.ethereum.vm.Program.StackTooSmallException; +import org.ethereum.vm.VM.BadJumpDestinationException; +import org.junit.After; +import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; import org.spongycastle.util.encoders.Hex; -import java.math.BigInteger; - import static org.junit.Assert.*; /** @@ -22,18 +21,30 @@ import static org.junit.Assert.*; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class VMTest { - + + private ProgramInvoke invoke; + private Program program; + + @Before + public void setup() { + invoke = new ProgramInvokeMockImpl(); + } + + @After + public void tearDown() { + invoke.getRepository().close(); + } + @Test // PUSH1 OP public void testPUSH1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60A0"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60A0"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000A0"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -41,13 +52,12 @@ public class VMTest { public void testPUSH2() { VM vm = new VM(); - Program program = new Program(Hex.decode("61A0B0"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61A0B0"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000A0B0"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -55,13 +65,12 @@ public class VMTest { public void testPUSH3() { VM vm = new VM(); - Program program = new Program(Hex.decode("62A0B0C0"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("62A0B0C0"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000A0B0C0"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -69,13 +78,12 @@ public class VMTest { public void testPUSH4() { VM vm = new VM(); - Program program = new Program(Hex.decode("63A0B0C0D0"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("63A0B0C0D0"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000A0B0C0D0"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -83,13 +91,12 @@ public class VMTest { public void testPUSH5() { VM vm = new VM(); - Program program = new Program(Hex.decode("64A0B0C0D0E0"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("64A0B0C0D0E0"), invoke); String expected = "000000000000000000000000000000000000000000000000000000A0B0C0D0E0"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -97,13 +104,12 @@ public class VMTest { public void testPUSH6() { VM vm = new VM(); - Program program = new Program(Hex.decode("65A0B0C0D0E0F0"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("65A0B0C0D0E0F0"), invoke); String expected = "0000000000000000000000000000000000000000000000000000A0B0C0D0E0F0"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -111,13 +117,12 @@ public class VMTest { public void testPUSH7() { VM vm = new VM(); - Program program = new Program(Hex.decode("66A0B0C0D0E0F0A1"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("66A0B0C0D0E0F0A1"), invoke); String expected = "00000000000000000000000000000000000000000000000000A0B0C0D0E0F0A1"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -125,13 +130,12 @@ public class VMTest { public void testPUSH8() { VM vm = new VM(); - Program program = new Program(Hex.decode("67A0B0C0D0E0F0A1B1"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("67A0B0C0D0E0F0A1B1"), invoke); String expected = "000000000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -139,13 +143,12 @@ public class VMTest { public void testPUSH9() { VM vm = new VM(); - Program program = new Program(Hex.decode("68A0B0C0D0E0F0A1B1C1"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("68A0B0C0D0E0F0A1B1C1"), invoke); String expected = "0000000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -154,13 +157,12 @@ public class VMTest { public void testPUSH10() { VM vm = new VM(); - Program program = new Program(Hex.decode("69A0B0C0D0E0F0A1B1C1D1"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("69A0B0C0D0E0F0A1B1C1D1"), invoke); String expected = "00000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -168,13 +170,12 @@ public class VMTest { public void testPUSH11() { VM vm = new VM(); - Program program = new Program(Hex.decode("6AA0B0C0D0E0F0A1B1C1D1E1"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6AA0B0C0D0E0F0A1B1C1D1E1"), invoke); String expected = "000000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -182,13 +183,12 @@ public class VMTest { public void testPUSH12() { VM vm = new VM(); - Program program = new Program(Hex.decode("6BA0B0C0D0E0F0A1B1C1D1E1F1"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6BA0B0C0D0E0F0A1B1C1D1E1F1"), invoke); String expected = "0000000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -196,13 +196,12 @@ public class VMTest { public void testPUSH13() { VM vm = new VM(); - Program program = new Program(Hex.decode("6CA0B0C0D0E0F0A1B1C1D1E1F1A2"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6CA0B0C0D0E0F0A1B1C1D1E1F1A2"), invoke); String expected = "00000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -210,13 +209,12 @@ public class VMTest { public void testPUSH14() { VM vm = new VM(); - Program program = new Program(Hex.decode("6DA0B0C0D0E0F0A1B1C1D1E1F1A2B2"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6DA0B0C0D0E0F0A1B1C1D1E1F1A2B2"), invoke); String expected = "000000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -224,13 +222,12 @@ public class VMTest { public void testPUSH15() { VM vm = new VM(); - Program program = new Program(Hex.decode("6EA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6EA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2"), invoke); String expected = "0000000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -238,13 +235,12 @@ public class VMTest { public void testPUSH16() { VM vm = new VM(); - Program program = new Program(Hex.decode("6FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2"), invoke); String expected = "00000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -252,13 +248,12 @@ public class VMTest { public void testPUSH17() { VM vm = new VM(); - Program program = new Program(Hex.decode("70A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("70A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2"), invoke); String expected = "000000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -266,13 +261,12 @@ public class VMTest { public void testPUSH18() { VM vm = new VM(); - Program program = new Program(Hex.decode("71A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("71A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2"), invoke); String expected = "0000000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -280,13 +274,12 @@ public class VMTest { public void testPUSH19() { VM vm = new VM(); - Program program = new Program(Hex.decode("72A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("72A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3"), invoke); String expected = "00000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -294,13 +287,12 @@ public class VMTest { public void testPUSH20() { VM vm = new VM(); - Program program = new Program(Hex.decode("73A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("73A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3"), invoke); String expected = "000000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -308,13 +300,12 @@ public class VMTest { public void testPUSH21() { VM vm = new VM(); - Program program = new Program(Hex.decode("74A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("74A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3"), invoke); String expected = "0000000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -322,13 +313,12 @@ public class VMTest { public void testPUSH22() { VM vm = new VM(); - Program program = new Program(Hex.decode("75A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("75A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3"), invoke); String expected = "00000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -336,13 +326,12 @@ public class VMTest { public void testPUSH23() { VM vm = new VM(); - Program program = new Program(Hex.decode("76A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("76A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3"), invoke); String expected = "000000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -350,13 +339,12 @@ public class VMTest { public void testPUSH24() { VM vm = new VM(); - Program program = new Program(Hex.decode("77A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("77A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3"), invoke); String expected = "0000000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -364,13 +352,12 @@ public class VMTest { public void testPUSH25() { VM vm = new VM(); - Program program = new Program(Hex.decode("78A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("78A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4"), invoke); String expected = "00000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -378,13 +365,12 @@ public class VMTest { public void testPUSH26() { VM vm = new VM(); - Program program = new Program(Hex.decode("79A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("79A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4"), invoke); String expected = "000000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -392,13 +378,12 @@ public class VMTest { public void testPUSH27() { VM vm = new VM(); - Program program = new Program(Hex.decode("7AA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7AA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4"), invoke); String expected = "0000000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -406,13 +391,12 @@ public class VMTest { public void testPUSH28() { VM vm = new VM(); - Program program = new Program(Hex.decode("7BA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7BA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4"), invoke); String expected = "00000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -420,13 +404,12 @@ public class VMTest { public void testPUSH29() { VM vm = new VM(); - Program program = new Program(Hex.decode("7CA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7CA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4"), invoke); String expected = "000000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -434,13 +417,12 @@ public class VMTest { public void testPUSH30() { VM vm = new VM(); - Program program = new Program(Hex.decode("7DA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7DA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4"), invoke); String expected = "0000A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -448,13 +430,12 @@ public class VMTest { public void testPUSH31() { VM vm = new VM(); - Program program = new Program(Hex.decode("7EA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7EA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1"), invoke); String expected = "00A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -462,13 +443,12 @@ public class VMTest { public void testPUSH32() { VM vm = new VM(); - Program program = new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1"), invoke); String expected = "A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1"; program.fullTrace(); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -476,13 +456,12 @@ public class VMTest { public void testPUSHN_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("61AA"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61AA"), invoke); try { program.fullTrace(); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -491,13 +470,12 @@ public class VMTest { public void testPUSHN_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("7fAABB"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7fAABB"), invoke); try { program.fullTrace(); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -506,14 +484,13 @@ public class VMTest { public void testAND_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("600A600A10"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600A600A10"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000000A"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -521,14 +498,13 @@ public class VMTest { public void testAND_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("60C0600A10"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60C0600A10"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -536,13 +512,12 @@ public class VMTest { public void testAND_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("60C010"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60C010"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -551,14 +526,13 @@ public class VMTest { public void testOR_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60F0600F11"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60F0600F11"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -566,14 +540,13 @@ public class VMTest { public void testOR_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("60C3603C11"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60C3603C11"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -581,13 +554,12 @@ public class VMTest { public void testOR_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("60C011"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60C011"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -596,14 +568,13 @@ public class VMTest { public void testXOR_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60FF60FF12"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60FF60FF12"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -611,14 +582,13 @@ public class VMTest { public void testXOR_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("600F60F012"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600F60F012"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -627,13 +597,12 @@ public class VMTest { public void testXOR_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("60C012"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60C012"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -642,14 +611,13 @@ public class VMTest { public void testBYTE_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("65AABBCCDDEEFF601E13"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("65AABBCCDDEEFF601E13"), invoke); String expected = "00000000000000000000000000000000000000000000000000000000000000EE"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -657,14 +625,13 @@ public class VMTest { public void testBYTE_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("65AABBCCDDEEFF602013"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("65AABBCCDDEEFF602013"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -672,14 +639,13 @@ public class VMTest { public void testBYTE_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("65AABBCCDDEE3A601F13"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("65AABBCCDDEE3A601F13"), invoke); String expected = "000000000000000000000000000000000000000000000000000000000000003A"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -688,13 +654,12 @@ public class VMTest { public void testBYTE_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("65AABBCCDDEE3A13"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("65AABBCCDDEE3A13"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -703,13 +668,12 @@ public class VMTest { public void testNOT_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60000F"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60000F"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -717,13 +681,12 @@ public class VMTest { public void testNOT_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("602A0F"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602A0F"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -731,13 +694,12 @@ public class VMTest { public void testNOT_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("0F"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("0F"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -746,14 +708,13 @@ public class VMTest { public void testEQ_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("602A602A0E"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602A602A0E"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -761,14 +722,13 @@ public class VMTest { public void testEQ_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("622A3B4C622A3B4C0E"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("622A3B4C622A3B4C0E"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase() ); } @@ -776,14 +736,13 @@ public class VMTest { public void testEQ_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("622A3B5C622A3B4C0E"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("622A3B5C622A3B4C0E"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -791,13 +750,12 @@ public class VMTest { public void testEQ_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("622A3B4C0E"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("622A3B4C0E"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -806,14 +764,13 @@ public class VMTest { public void testGT_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("600160020B"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600160020B"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -821,14 +778,13 @@ public class VMTest { public void testGT_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("6001610F000B"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6001610F000B"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -836,14 +792,13 @@ public class VMTest { public void testGT_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("6301020304610F000B"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6301020304610F000B"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -851,13 +806,12 @@ public class VMTest { public void testGT_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("622A3B4C0B"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("622A3B4C0B"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -866,14 +820,13 @@ public class VMTest { public void testSGT_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("600160020D"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600160020D"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -881,9 +834,9 @@ public class VMTest { public void testSGT_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + // 30 + program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + // 30 "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 - "0D"), new ProgramInvokeMockImpl()); + "0D"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; @@ -891,7 +844,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -899,9 +851,9 @@ public class VMTest { public void testSGT_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 + program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" + // -169 - "0D"), new ProgramInvokeMockImpl()); + "0D"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; @@ -909,7 +861,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -917,14 +868,13 @@ public class VMTest { public void testSGT_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 - "0D"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 + "0D"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -933,14 +883,13 @@ public class VMTest { public void testLT_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("600160020A"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600160020A"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -948,14 +897,13 @@ public class VMTest { public void testLT_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("6001610F000A"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6001610F000A"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -963,14 +911,13 @@ public class VMTest { public void testLT_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("6301020304610F000A"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6301020304610F000A"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -978,13 +925,12 @@ public class VMTest { public void testLT_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("622A3B4C0A"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("622A3B4C0A"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -993,14 +939,13 @@ public class VMTest { public void testSLT_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("600160020C"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600160020C"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1008,9 +953,9 @@ public class VMTest { public void testSLT_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + // 30 + program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + // 30 "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 - "0C"), new ProgramInvokeMockImpl()); + "0C"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; @@ -1018,7 +963,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1026,9 +970,9 @@ public class VMTest { public void testSLT_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 + program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF57" + // -169 - "0C"), new ProgramInvokeMockImpl()); + "0C"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; @@ -1036,7 +980,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1044,14 +987,13 @@ public class VMTest { public void testSLT_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 - "0D"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 + "0D"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1060,13 +1002,12 @@ public class VMTest { public void testNEG_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("600109"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600109"), invoke); String expected = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1074,13 +1015,12 @@ public class VMTest { public void testNEG_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("61A00309"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61A00309"), invoke); String expected = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5FFD"; vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1088,13 +1028,12 @@ public class VMTest { public void testNEG_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("61000009"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61000009"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1102,12 +1041,11 @@ public class VMTest { public void testNEG_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("09"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("09"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1116,7 +1054,7 @@ public class VMTest { public void testPOP_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("61000060016200000250"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61000060016200000250"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); @@ -1124,7 +1062,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1132,7 +1069,7 @@ public class VMTest { public void testPOP_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("6100006001620000025050"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6100006001620000025050"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); @@ -1141,7 +1078,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1149,7 +1085,7 @@ public class VMTest { public void testPOP_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("61000060016200000250505050"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61000060016200000250505050"), invoke); try { vm.step(program); vm.step(program); @@ -1159,7 +1095,6 @@ public class VMTest { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1184,7 +1119,7 @@ public class VMTest { for (int i = 0; i < n; i++) { programCode += "60" + (12 + i); } - Program program = new Program(ByteUtil.appendByte(Hex.decode(programCode.getBytes()), operation), new ProgramInvokeMockImpl()); + program = new Program(ByteUtil.appendByte(Hex.decode(programCode.getBytes()), operation), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000000012"; int expectedLen = n + 1; @@ -1192,7 +1127,6 @@ public class VMTest { vm.step(program); } - program.getResult().getRepository().close(); assertEquals(expectedLen, program.stack.toArray().length); assertEquals(expected, Hex.toHexString(program.stackPop().getData()).toUpperCase()); for (int i = 0; i < expectedLen-2; i++) { @@ -1205,11 +1139,10 @@ public class VMTest { public void testDUPN_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("80"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("80"), invoke); try { vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1236,13 +1169,12 @@ public class VMTest { programCode += "60" + (11+i); expected[i] = "00000000000000000000000000000000000000000000000000000000000000" + (11+i); } - Program program = new Program(ByteUtil.appendByte(Hex.decode(programCode), operation), new ProgramInvokeMockImpl()); + program = new Program(ByteUtil.appendByte(Hex.decode(programCode), operation), invoke); for (int i = 0; i <= expected.length; i++) { vm.step(program); } - program.getResult().getRepository().close(); assertEquals(expected.length, program.stack.toArray().length); assertEquals(expected[0], Hex.toHexString(program.stackPop().getData()).toUpperCase()); for (int i = expected.length-2; i > 0; i--) { @@ -1255,12 +1187,11 @@ public class VMTest { public void testSWAPN_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("90"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("90"), invoke); try { vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1269,14 +1200,13 @@ public class VMTest { public void testMSTORE_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("611234600054"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("611234600054"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000001234"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.memory.array())); } @@ -1284,7 +1214,7 @@ public class VMTest { public void testMSTORE_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("611234600054615566602054"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("611234600054615566602054"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000001234" + "0000000000000000000000000000000000000000000000000000000000005566"; @@ -1295,7 +1225,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.memory.array())); } @@ -1303,7 +1232,7 @@ public class VMTest { public void testMSTORE_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("611234600054615566602054618888600054"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("611234600054615566602054618888600054"), invoke); String expected = "0000000000000000000000000000000000000000000000000000000000008888" + "0000000000000000000000000000000000000000000000000000000000005566"; @@ -1317,7 +1246,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.memory.array())); } @@ -1325,7 +1253,7 @@ public class VMTest { public void testMSTORE_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("61123460A054"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61123460A054"), invoke); String expected = "" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + @@ -1338,7 +1266,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(expected, Hex.toHexString(program.memory.array())); } @@ -1346,12 +1273,11 @@ public class VMTest { public void testMSTORE_5() { VM vm = new VM(); - Program program = new Program(Hex.decode("61123454"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61123454"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1360,14 +1286,13 @@ public class VMTest { public void testMLOAD_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("600053"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600053"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected, Hex.toHexString(program.memory.array())); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1376,7 +1301,7 @@ public class VMTest { public void testMLOAD_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("602253"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602253"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000"; @@ -1385,7 +1310,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1395,7 +1319,7 @@ public class VMTest { public void testMLOAD_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("602053"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602053"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; @@ -1403,7 +1327,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected, Hex.toHexString(program.memory.array())); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1412,7 +1335,7 @@ public class VMTest { public void testMLOAD_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("611234602054602053"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("611234602054602053"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000001234"; String s_expected = "0000000000000000000000000000000000000000000000000000000000001234"; @@ -1423,7 +1346,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected, Hex.toHexString(program.memory.array())); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1432,7 +1354,7 @@ public class VMTest { public void testMLOAD_5() { VM vm = new VM(); - Program program = new Program(Hex.decode("611234602054601F53"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("611234602054601F53"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000001234"; String s_expected = "0000000000000000000000000000000000000000000000000000000000000012"; @@ -1443,7 +1365,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected, Hex.toHexString(program.memory.array())); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1452,11 +1373,10 @@ public class VMTest { public void testMLOAD_6() { VM vm = new VM(); - Program program = new Program(Hex.decode("53"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("53"), invoke); try { vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1465,14 +1385,13 @@ public class VMTest { public void testMSTORE8_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6011600055"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6011600055"), invoke); String m_expected = "1100000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected, Hex.toHexString(program.memory.array())); } @@ -1481,14 +1400,13 @@ public class VMTest { public void testMSTORE8_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("6022600155"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6022600155"), invoke); String m_expected = "0022000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected, Hex.toHexString(program.memory.array())); } @@ -1496,7 +1414,7 @@ public class VMTest { public void testMSTORE8_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("6022602155"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6022602155"), invoke); String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + "0022000000000000000000000000000000000000000000000000000000000000"; @@ -1504,7 +1422,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected, Hex.toHexString(program.memory.array())); } @@ -1512,12 +1429,11 @@ public class VMTest { public void testMSTORE8_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("602255"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602255"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1526,9 +1442,8 @@ public class VMTest { public void testSSTORE_1() { VM vm = new VM(); - ProgramInvokeMockImpl invoke = new ProgramInvokeMockImpl(); - Program program = new Program(Hex.decode("602260AA57"), invoke); + program = new Program(Hex.decode("602260AA57"), invoke); String s_expected_key = "00000000000000000000000000000000000000000000000000000000000000AA"; String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000022"; @@ -1539,7 +1454,6 @@ public class VMTest { DataWord key = new DataWord(Hex.decode(s_expected_key)); DataWord val = program.result.getRepository().getStorageValue(invoke.getOwnerAddress().getNoLeadZeroesData(), key); - program.getResult().getRepository().close(); assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase()); } @@ -1547,9 +1461,8 @@ public class VMTest { public void testSSTORE_2() { VM vm = new VM(); - ProgramInvokeMockImpl invoke = new ProgramInvokeMockImpl(); - Program program = new Program(Hex.decode("602260AA57602260BB57"), invoke); + program = new Program(Hex.decode("602260AA57602260BB57"), invoke); String s_expected_key = "00000000000000000000000000000000000000000000000000000000000000BB"; String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000022"; @@ -1564,7 +1477,6 @@ public class VMTest { DataWord key = new DataWord(Hex.decode(s_expected_key)); DataWord val = repository.getStorageValue(invoke.getOwnerAddress().getNoLeadZeroesData(), key); - program.getResult().getRepository().close(); assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase()); } @@ -1572,12 +1484,11 @@ public class VMTest { public void testSSTORE_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("602257"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602257"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1586,13 +1497,12 @@ public class VMTest { public void testSLOAD_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60AA56"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60AA56"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1600,7 +1510,7 @@ public class VMTest { public void testSLOAD_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("602260AA5760AA56"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602260AA5760AA56"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000022"; vm.step(program); @@ -1609,7 +1519,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1617,7 +1526,7 @@ public class VMTest { public void testSLOAD_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("602260AA57603360CC5760CC56"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602260AA57603360CC5760CC56"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000033"; vm.step(program); @@ -1629,7 +1538,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1637,11 +1545,10 @@ public class VMTest { public void testSLOAD_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("56"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("56"), invoke); try { vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1650,12 +1557,11 @@ public class VMTest { public void testPC_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("5A"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("5A"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1664,7 +1570,7 @@ public class VMTest { public void testPC_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("602260AA5760AA565A"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("602260AA5760AA565A"), invoke); String s_expected = "0000000000000000000000000000000000000000000000000000000000000008"; vm.step(program); @@ -1674,7 +1580,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1682,7 +1587,7 @@ public class VMTest { public void testJUMP_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60AA60BB600D5860CC60DD60EE60FF"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60AA60BB600E5860CC60DD60EE5D60FF"), invoke); String s_expected = "00000000000000000000000000000000000000000000000000000000000000FF"; vm.step(program); @@ -1691,20 +1596,18 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } - @Test(expected=PcOverflowException.class) // JUMP OP mal data + @Test(expected=BadJumpDestinationException.class) // JUMP OP mal data public void testJUMP_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("600C5860CC60DD60EE60FF"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600C5860CC60DD60EE60FF"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1713,7 +1616,7 @@ public class VMTest { public void testJUMPI_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("600160055960CC"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60016006595D60CC"), invoke); String s_expected = "00000000000000000000000000000000000000000000000000000000000000CC"; vm.step(program); @@ -1721,7 +1624,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected, Hex.toHexString(program.stack.peek().getData()).toUpperCase()); } @@ -1730,7 +1632,7 @@ public class VMTest { public void testJUMPI_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("630000000060445960CC60DD"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("630000000060445960CC60DD"), invoke); String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000DD"; String s_expected_2 = "00000000000000000000000000000000000000000000000000000000000000CC"; @@ -1743,7 +1645,6 @@ public class VMTest { DataWord item1 = program.stackPop(); DataWord item2 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); assertEquals(s_expected_2, Hex.toHexString(item2.getData()).toUpperCase()); } @@ -1752,36 +1653,79 @@ public class VMTest { public void testJUMPI_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("600159"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600159"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } - @Test(expected=PcOverflowException.class) // JUMPI OP mal + @Test(expected=BadJumpDestinationException.class) // JUMPI OP mal public void testJUMPI_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("6001602259"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6001602259"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } + + @Test // JUMPDEST OP for JUMP + public void testJUMPDEST_1() { + + VM vm = new VM(); + program = new Program(Hex.decode("602360085860015d600257"), invoke); + + String s_expected_key = "0000000000000000000000000000000000000000000000000000000000000002"; + String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000023"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + DataWord key = new DataWord(Hex.decode(s_expected_key)); + DataWord val = program.result.getRepository().getStorageValue(invoke.getOwnerAddress().getNoLeadZeroesData(), key); + + assertTrue(program.isStopped()); + assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase()); + } + + @Test // JUMPDEST OP for JUMPI + public void testJUMPDEST_2() { + + VM vm = new VM(); + program = new Program(Hex.decode("60236001600a5960015d600257"), invoke); + + String s_expected_key = "0000000000000000000000000000000000000000000000000000000000000002"; + String s_expected_val = "0000000000000000000000000000000000000000000000000000000000000023"; + + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + vm.step(program); + + DataWord key = new DataWord(Hex.decode(s_expected_key)); + DataWord val = program.result.getRepository().getStorageValue(invoke.getOwnerAddress().getNoLeadZeroesData(), key); + + assertTrue(program.isStopped()); + assertEquals(s_expected_val, Hex.toHexString(val.getData()).toUpperCase()); + } @Test // ADD OP mal public void testADD_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6002600201"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6002600201"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000004"; vm.step(program); @@ -1789,7 +1733,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1797,7 +1740,7 @@ public class VMTest { public void testADD_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("611002600201"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("611002600201"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000001004"; vm.step(program); @@ -1805,7 +1748,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1813,7 +1755,7 @@ public class VMTest { public void testADD_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("6110026512345678900901"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6110026512345678900901"), invoke); String s_expected_1 = "000000000000000000000000000000000000000000000000000012345678A00B"; vm.step(program); @@ -1821,7 +1763,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1829,12 +1770,11 @@ public class VMTest { public void testADD_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("61123401"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61123401"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1842,7 +1782,7 @@ public class VMTest { @Test // ADDMOD OP mal public void testADDMOD_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60026002600314"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60026002600314"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); @@ -1851,7 +1791,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertTrue(program.isStopped()); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1859,7 +1798,7 @@ public class VMTest { @Test // ADDMOD OP public void testADDMOD_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("6110006002611002146000"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6110006002611002146000"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000004"; vm.step(program); @@ -1868,7 +1807,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertFalse(program.isStopped()); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1876,7 +1814,7 @@ public class VMTest { @Test // ADDMOD OP public void testADDMOD_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("61100265123456789009600214"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61100265123456789009600214"), invoke); String s_expected_1 = "000000000000000000000000000000000000000000000000000000000000093B"; vm.step(program); @@ -1885,7 +1823,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertTrue(program.isStopped()); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1893,12 +1830,11 @@ public class VMTest { @Test(expected=StackTooSmallException.class) // ADDMOD OP mal public void testADDMOD_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("61123414"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61123414"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1907,7 +1843,7 @@ public class VMTest { public void testMUL_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6003600202"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6003600202"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000006"; vm.step(program); @@ -1915,7 +1851,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1923,7 +1858,7 @@ public class VMTest { public void testMUL_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("62222222600302"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("62222222600302"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000666666"; vm.step(program); @@ -1931,7 +1866,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1939,7 +1873,7 @@ public class VMTest { public void testMUL_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("622222226233333302"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("622222226233333302"), invoke); String s_expected_1 = "000000000000000000000000000000000000000000000000000006D3A05F92C6"; vm.step(program); @@ -1947,7 +1881,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -1955,12 +1888,11 @@ public class VMTest { public void testMUL_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("600102"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600102"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -1968,7 +1900,7 @@ public class VMTest { @Test // MULMOD OP public void testMULMOD_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60036002600415"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60036002600415"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002"; vm.step(program); @@ -1977,14 +1909,13 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test // MULMOD OP public void testMULMOD_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("622222226003600415"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("622222226003600415"), invoke); String s_expected_1 = "000000000000000000000000000000000000000000000000000000000000000C"; vm.step(program); @@ -1993,14 +1924,13 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test // MULMOD OP public void testMULMOD_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("62222222623333336244444415"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("62222222623333336244444415"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); @@ -2009,19 +1939,17 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test(expected=StackTooSmallException.class) // MULMOD OP mal public void testMULMOD_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("600115"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600115"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -2030,7 +1958,7 @@ public class VMTest { public void testDIV_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6002600404"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6002600404"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002"; vm.step(program); @@ -2038,7 +1966,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2046,7 +1973,7 @@ public class VMTest { public void testDIV_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("6033609904"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6033609904"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000003"; vm.step(program); @@ -2054,7 +1981,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2063,7 +1989,7 @@ public class VMTest { public void testDIV_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("6022609904"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6022609904"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000004"; vm.step(program); @@ -2071,7 +1997,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2079,7 +2004,7 @@ public class VMTest { public void testDIV_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("6015609904"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6015609904"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000007"; vm.step(program); @@ -2087,7 +2012,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2096,7 +2020,7 @@ public class VMTest { public void testDIV_5() { VM vm = new VM(); - Program program = new Program(Hex.decode("6004600704"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6004600704"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); @@ -2104,7 +2028,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2112,12 +2035,11 @@ public class VMTest { public void testDIV_6() { VM vm = new VM(); - Program program = new Program(Hex.decode("600704"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600704"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -2126,7 +2048,7 @@ public class VMTest { public void testSDIV_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6103E87FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC1805"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6103E87FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC1805"), invoke); String s_expected_1 = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; vm.step(program); @@ -2134,7 +2056,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2142,7 +2063,7 @@ public class VMTest { public void testSDIV_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("60FF60FF05"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60FF60FF05"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); @@ -2150,7 +2071,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2158,7 +2078,7 @@ public class VMTest { public void testSDIV_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("600060FF05"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600060FF05"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); @@ -2166,7 +2086,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2174,13 +2093,12 @@ public class VMTest { public void testSDIV_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("60FF05"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60FF05"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -2189,7 +2107,7 @@ public class VMTest { public void testSUB_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6004600603"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6004600603"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002"; vm.step(program); @@ -2198,14 +2116,13 @@ public class VMTest { DataWord item1 = program.stackPop(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - program.getResult().getRepository().close(); } @Test // SUB OP public void testSUB_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("61444461666603"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61444461666603"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000002222"; vm.step(program); @@ -2213,7 +2130,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2221,7 +2137,7 @@ public class VMTest { public void testSUB_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("614444639999666603"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("614444639999666603"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000099992222"; vm.step(program); @@ -2229,7 +2145,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2237,12 +2152,11 @@ public class VMTest { public void testSUB_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("639999666603"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("639999666603"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -2251,13 +2165,12 @@ public class VMTest { public void testMSIZE_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("5B"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("5B"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000000"; vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2265,7 +2178,7 @@ public class VMTest { public void testMSIZE_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("60206030545B"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60206030545B"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000060"; vm.step(program); @@ -2274,7 +2187,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2283,7 +2195,7 @@ public class VMTest { public void testSTOP_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("60206030601060306011602300"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60206030601060306011602300"), invoke); int expectedSteps = 7; int i = 0; @@ -2292,7 +2204,6 @@ public class VMTest { vm.step(program); ++i; } - program.getResult().getRepository().close(); assertEquals(expectedSteps, i); } @@ -2301,7 +2212,7 @@ public class VMTest { public void testEXP_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6003600208"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6003600208"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000008"; vm.step(program); @@ -2309,7 +2220,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2317,7 +2227,7 @@ public class VMTest { public void testEXP_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("60006212345608"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("60006212345608"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); @@ -2325,7 +2235,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -2333,12 +2242,11 @@ public class VMTest { public void testEXP_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("6212345608"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6212345608"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -2347,7 +2255,7 @@ public class VMTest { public void testRETURN_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("61123460005460206000F2"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61123460005460206000F2"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000001234"; vm.step(program); @@ -2357,7 +2265,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(program.getResult().getHReturn().array()).toUpperCase()); assertTrue(program.isStopped()); } @@ -2367,7 +2274,7 @@ public class VMTest { public void testRETURN_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("6112346000546020601FF2"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6112346000546020601FF2"), invoke); String s_expected_1 = "3400000000000000000000000000000000000000000000000000000000000000"; vm.step(program); @@ -2377,7 +2284,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(program.getResult().getHReturn().array()).toUpperCase()); assertTrue(program.isStopped()); } @@ -2386,9 +2292,9 @@ public class VMTest { public void testRETURN_3() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005460206000F2"), - new ProgramInvokeMockImpl()); + invoke); String s_expected_1 = "A0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B1"; vm.step(program); @@ -2398,7 +2304,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(program.getResult().getHReturn().array()).toUpperCase()); assertTrue(program.isStopped()); } @@ -2408,9 +2313,9 @@ public class VMTest { public void testRETURN_4() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("7FA0B0C0D0E0F0A1B1C1D1E1F1A2B2C2D2E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B160005460206010F2"), - new ProgramInvokeMockImpl()); + invoke); String s_expected_1 = "E2F2A3B3C3D3E3F3A4B4C4D4E4F4A1B100000000000000000000000000000000"; vm.step(program); @@ -2420,7 +2325,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(program.getResult().getHReturn().array()).toUpperCase()); assertTrue(program.isStopped()); } @@ -2430,8 +2334,8 @@ public class VMTest { public void testCODECOPY_1() { VM vm = new VM(); - Program program = - new Program(Hex.decode("60036007600039123456"), new ProgramInvokeMockImpl()); + program = + new Program(Hex.decode("60036007600039123456"), invoke); String m_expected_1 = "1234560000000000000000000000000000000000000000000000000000000000"; vm.step(program); @@ -2439,7 +2343,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected_1, Hex.toHexString(program.memory.array()).toUpperCase()); } @@ -2447,9 +2350,9 @@ public class VMTest { public void testCODECOPY_2() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("605E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235602054"), - new ProgramInvokeMockImpl()); + invoke); String m_expected_1 = "6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254516040016014525451606001601E5254516080016028525460A052546016604860003960166000F26000603F556103E756600054600053602002356020540000"; vm.step(program); @@ -2457,7 +2360,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected_1, Hex.toHexString(program.memory.array()).toUpperCase()); } @@ -2465,16 +2367,15 @@ public class VMTest { public void testCODECOPY_3() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("605E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), - new ProgramInvokeMockImpl()); + invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } @@ -2482,16 +2383,15 @@ public class VMTest { public void testCODECOPY_4() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("605E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), - new ProgramInvokeMockImpl()); + invoke); vm.step(program); vm.step(program); vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } @@ -2504,9 +2404,9 @@ public class VMTest { public void testCODECOPY_5() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("611234600054615566602054607060006020396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), - new ProgramInvokeMockImpl()); + invoke); vm.step(program); vm.step(program); @@ -2519,7 +2419,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertFalse(program.isStopped()); } @@ -2528,15 +2427,14 @@ public class VMTest { public void testCODECOPY_6() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("605E6007396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), - new ProgramInvokeMockImpl()); + invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -2545,8 +2443,8 @@ public class VMTest { public void testEXTCODECOPY_1() { VM vm = new VM(); - Program program = - new Program(Hex.decode("60036007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C123456"), new ProgramInvokeMockImpl()); + program = + new Program(Hex.decode("60036007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C123456"), invoke); String m_expected_1 = "6000600000000000000000000000000000000000000000000000000000000000"; vm.step(program); @@ -2555,7 +2453,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected_1, Hex.toHexString(program.memory.array()).toUpperCase()); } @@ -2563,9 +2460,9 @@ public class VMTest { public void testEXTCODECOPY_2() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("603E6007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235602054"), - new ProgramInvokeMockImpl()); + invoke); String m_expected_1 = "6000605F556014600054601E60205463ABCDDCBA6040545B51602001600A5254516040016014525451606001601E5254516080016028525460A0525460160000"; vm.step(program); @@ -2574,16 +2471,15 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertEquals(m_expected_1, Hex.toHexString(program.memory.array()).toUpperCase()); } @Test // EXTCODECOPY OP public void testEXTCODECOPY_3() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("605E6007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), - new ProgramInvokeMockImpl()); + invoke); vm.step(program); vm.step(program); @@ -2591,7 +2487,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } @@ -2599,9 +2494,9 @@ public class VMTest { public void testEXTCODECOPY_4() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("605E6007600073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), - new ProgramInvokeMockImpl()); + invoke); vm.step(program); vm.step(program); @@ -2609,16 +2504,15 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } @Test // EXTCODECOPY OP public void testEXTCODECOPY_5() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("611234600054615566602054603E6000602073471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C6000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e756600054600053602002351234"), - new ProgramInvokeMockImpl()); + invoke); vm.step(program); vm.step(program); @@ -2632,7 +2526,6 @@ public class VMTest { vm.step(program); vm.step(program); - program.getResult().getRepository().close(); assertFalse(program.isStopped()); } @@ -2640,16 +2533,15 @@ public class VMTest { @Test(expected=StackTooSmallException.class) // EXTCODECOPY OP mal public void testEXTCODECOPY_6() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("605E600773471FD3AD3E9EEADEEC4608B92D16CE6B500704CC3C"), - new ProgramInvokeMockImpl()); + invoke); try { vm.step(program); vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -2659,434 +2551,35 @@ public class VMTest { public void testCODESIZE_1() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("385E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), - new ProgramInvokeMockImpl()); + invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000062"; vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test // EXTCODESIZE OP public void testEXTCODESIZE_1() { VM vm = new VM(); - Program program = + program = new Program(Hex.decode("73471FD3AD3E9EEADEEC4608B92D16CE6B500704CC395E60076000396000605f556014600054601e60205463abcddcba6040545b51602001600a5254516040016014525451606001601e5254516080016028525460a052546016604860003960166000f26000603f556103e75660005460005360200235"), - new ProgramInvokeMockImpl()); // Push address on the stack and perform EXTCODECOPY + invoke); // Push address on the stack and perform EXTCODECOPY String s_expected_1 = "000000000000000000000000471FD3AD3E9EEADEEC4608B92D16CE6B500704CC"; vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } - - @Test // CALLDATASIZE OP - public void testCALLDATASIZE_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("36"), - createProgramInvoke_1()); - String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000040"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - - @Test // CALLDATALOAD OP - public void testCALLDATALOAD_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("600035"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000A1"; - - vm.step(program); - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // CALLDATALOAD OP - public void testCALLDATALOAD_2() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("600235"), - createProgramInvoke_1()); - String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000A10000"; - - vm.step(program); - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - - @Test // CALLDATALOAD OP - public void testCALLDATALOAD_3() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("602035"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000B1"; - - vm.step(program); - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - - @Test // CALLDATALOAD OP - public void testCALLDATALOAD_4() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("602335"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000000000000000000000000000000000000B1000000"; - - vm.step(program); - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // CALLDATALOAD OP - public void testCALLDATALOAD_5() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("603F35"), - createProgramInvoke_1()); - String s_expected_1 = "B100000000000000000000000000000000000000000000000000000000000000"; - - vm.step(program); - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test(expected=RuntimeException.class) // CALLDATALOAD OP mal - public void testCALLDATALOAD_6() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("35"), - createProgramInvoke_1()); - try { - vm.step(program); - } finally { - program.getResult().getRepository().close(); - assertTrue(program.isStopped()); - } - } - - @Test // CALLDATACOPY OP - public void testCALLDATACOPY_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("60206000600037"), - createProgramInvoke_1()); - String m_expected = "00000000000000000000000000000000000000000000000000000000000000A1"; - - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - - program.getResult().getRepository().close(); - assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); - } - - @Test // CALLDATACOPY OP - public void testCALLDATACOPY_2() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("60406000600037"), - createProgramInvoke_1()); - String m_expected = "00000000000000000000000000000000000000000000000000000000000000A1" + - "00000000000000000000000000000000000000000000000000000000000000B1"; - - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - - program.getResult().getRepository().close(); - assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); - } - - - @Test // CALLDATACOPY OP - public void testCALLDATACOPY_3() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("60406004600037"), - createProgramInvoke_1()); - String m_expected = "000000000000000000000000000000000000000000000000000000A100000000" + - "000000000000000000000000000000000000000000000000000000B100000000"; - - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - - program.getResult().getRepository().close(); - assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); - } - - - @Test // CALLDATACOPY OP - public void testCALLDATACOPY_4() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("60406000600437"), - createProgramInvoke_1()); - String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + - "000000A100000000000000000000000000000000000000000000000000000000" + - "000000B100000000000000000000000000000000000000000000000000000000"; - - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - - program.getResult().getRepository().close(); - assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); - } - - @Test // CALLDATACOPY OP - public void testCALLDATACOPY_5() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("60406000600437"), - createProgramInvoke_1()); - String m_expected = "0000000000000000000000000000000000000000000000000000000000000000" + - "000000A100000000000000000000000000000000000000000000000000000000" + - "000000B100000000000000000000000000000000000000000000000000000000"; - - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - - program.getResult().getRepository().close(); - assertEquals(m_expected, Hex.toHexString(program.memory.array()).toUpperCase()); - } - - - @Test(expected=StackTooSmallException.class) // CALLDATACOPY OP mal - public void testCALLDATACOPY_6() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("6040600037"), - createProgramInvoke_1()); - - try { - vm.step(program); - vm.step(program); - vm.step(program); - } finally { - program.getResult().getRepository().close(); - assertTrue(program.isStopped()); - } - } - - @Test(expected=OutOfGasException.class) // CALLDATACOPY OP mal - public void testCALLDATACOPY_7() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("6020600073CC0929EB16730E7C14FEFC63006AC2D794C5795637"), - createProgramInvoke_1()); - - try { - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - } finally { - program.getResult().getRepository().close(); - assertTrue(program.isStopped()); - } - } - - @Test // ADDRESS OP - public void testADDRESS_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("30"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000077045E71A7A2C50903D88E564CD72FAB11E82051"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // BALANCE OP - public void testBALANCE_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("3031"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000003E8"; - - vm.step(program); - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // ORIGIN OP - public void testORIGIN_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("32"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000013978AEE95F38490E9769C39B2773ED763D9CD5F"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // CALLER OP - public void testCALLER_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("33"), - createProgramInvoke_1()); - String s_expected_1 = "000000000000000000000000885F93EED577F2FC341EBB9A5C9B2CE4465D96C4"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // CALLVALUE OP - public void testCALLVALUE_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("34"), - createProgramInvoke_1()); - String s_expected_1 = "0000000000000000000000000000000000000000000000000DE0B6B3A7640000"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // SHA3 OP - public void testSHA3_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("60016000556001600020"), - createProgramInvoke_1()); - String s_expected_1 = "5FE7F977E71DBA2EA1A68E21057BEEBB9BE2AC30C6410AA38D4F3FBE41DCFFD2"; - - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // SHA3 OP - public void testSHA3_2() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("6102016000546002601E20"), - createProgramInvoke_1()); - String s_expected_1 = "114A3FE82A0219FCC31ABD15617966A125F12B0FD3409105FC83B487A9D82DE4"; - - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test(expected=StackTooSmallException.class) // SHA3 OP mal - public void testSHA3_3() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("610201600054600220"), - createProgramInvoke_1()); - try { - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - vm.step(program); - } finally { - program.getResult().getRepository().close(); - assertTrue(program.isStopped()); - } - } @Test // MOD OP public void testMOD_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6003600406"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6003600406"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); @@ -3094,14 +2587,13 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test // MOD OP public void testMOD_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("61012C6101F406"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("61012C6101F406"), invoke); String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000000C8"; vm.step(program); @@ -3109,14 +2601,13 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test // MOD OP public void testMOD_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("6004600206"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6004600206"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000002"; vm.step(program); @@ -3124,7 +2615,6 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @@ -3132,14 +2622,13 @@ public class VMTest { public void testMOD_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("600406"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("600406"), invoke); try { vm.step(program); vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } @@ -3147,7 +2636,7 @@ public class VMTest { @Test // SMOD OP public void testSMOD_1() { VM vm = new VM(); - Program program = new Program(Hex.decode("6003600407"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("6003600407"), invoke); String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; vm.step(program); @@ -3155,16 +2644,15 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test // SMOD OP public void testSMOD_2() { VM vm = new VM(); - Program program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE2" + // -30 + program = new Program(Hex.decode("7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE2" + // -30 "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 - "07"), new ProgramInvokeMockImpl()); + "07"), invoke); String s_expected_1 = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC"; vm.step(program); @@ -3172,16 +2660,15 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test // SMOD OP public void testSMOD_3() { VM vm = new VM(); - Program program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + // 30 + program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + // 30 "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF56" + // -170 - "07"), new ProgramInvokeMockImpl()); + "07"), invoke); String s_expected_1 = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEC"; vm.step(program); @@ -3189,188 +2676,21 @@ public class VMTest { vm.step(program); DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); } @Test(expected=StackTooSmallException.class) // SMOD OP mal public void testSMOD_4() { VM vm = new VM(); - Program program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + // 30 - "07"), new ProgramInvokeMockImpl()); + program = new Program(Hex.decode("7F000000000000000000000000000000000000000000000000000000000000001E" + // 30 + "07"), invoke); try { vm.step(program); vm.step(program); } finally { - program.getResult().getRepository().close(); assertTrue(program.isStopped()); } } - - @Test // PREVHASH OP - public void testPREVHASH_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("40"), - createProgramInvoke_1()); - String s_expected_1 = "961CB117ABA86D1E596854015A1483323F18883C2D745B0BC03E87F146D2BB1C"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // COINBASE OP - public void testCOINBASE_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("41"), - createProgramInvoke_1()); - String s_expected_1 = "000000000000000000000000E559DE5527492BCB42EC68D07DF0742A98EC3F1E"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // TIMESTAMP OP - public void testTIMESTAMP_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("42"), - createProgramInvoke_1()); - String s_expected_1 = "000000000000000000000000000000000000000000000000000000005387FE24"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // NUMBER OP - public void testNUMBER_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("43"), - createProgramInvoke_1()); - String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000021"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // DIFFICULTY OP - public void testDIFFICULTY_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("44"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000000000000000000000000000000000000003ED290"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // GASPRICE OP - public void testGASPRICE_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("3A"), - createProgramInvoke_1()); - String s_expected_1 = "000000000000000000000000000000000000000000000000000009184E72A000"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // GAS OP - public void testGAS_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("5C"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000F423F"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test // GASLIMIT OP - public void testGASLIMIT_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("45"), - createProgramInvoke_1()); - String s_expected_1 = "00000000000000000000000000000000000000000000000000000000000F4240"; - - vm.step(program); - - DataWord item1 = program.stackPop(); - program.getResult().getRepository().close(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - - @Test(expected=Program.IllegalOperationException.class) // INVALID OP - public void testINVALID_1() { - - VM vm = new VM(); - Program program = - new Program(Hex.decode("6001516002"), - createProgramInvoke_1()); - String s_expected_1 = "0000000000000000000000000000000000000000000000000000000000000001"; - - try { - vm.step(program); - vm.step(program); - } finally { - program.getResult().getRepository().close(); - assertTrue(program.isStopped()); - DataWord item1 = program.stackPop(); - assertEquals(s_expected_1, Hex.toHexString(item1.getData()).toUpperCase()); - } - } - - /* TEST CASE LIST END */ - - public ProgramInvoke createProgramInvoke_1() { - - byte[] ownerAddress = Hex.decode("77045E71A7A2C50903D88E564CD72FAB11E82051"); - byte[] msgData = Hex.decode("00000000000000000000000000000000000000000000000000000000000000A1" + - "00000000000000000000000000000000000000000000000000000000000000B1"); - - ProgramInvokeMockImpl pi = new ProgramInvokeMockImpl(msgData); - pi.setOwnerAddress(ownerAddress); - - pi.getRepository().createAccount(ownerAddress); - pi.getRepository().addBalance(ownerAddress, BigInteger.valueOf(1000L)); - - return pi; - } } // TODO: add gas expeted and calculated to all test cases diff --git a/ethereumj-core/src/test/resources/jsontestsuite/vmArithmeticTest.json b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmArithmeticTest.json similarity index 95% rename from ethereumj-core/src/test/resources/jsontestsuite/vmArithmeticTest.json rename to ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmArithmeticTest.json index 3f431c7c..5df9965b 100644 --- a/ethereumj-core/src/test/resources/jsontestsuite/vmArithmeticTest.json +++ b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmArithmeticTest.json @@ -1617,6 +1617,134 @@ } } }, + "mul4" : { + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f800000000000000000000000000000000000000000000000000000000000000002600057", + "data" : "0x", + "gas" : "10000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000" + }, + "gas" : "9796", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f800000000000000000000000000000000000000000000000000000000000000002600057", + "nonce" : "0", + "storage" : { + "0x" : "0x8000000000000000000000000000000000000000000000000000000000000000" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f800000000000000000000000000000000000000000000000000000000000000002600057", + "nonce" : "0", + "storage" : { + } + } + } + }, + "mul5" : { + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x7f80000000000000000000000000000000000000000000000000000000000000007f800000000000000000000000000000000000000000000000000000000000000002600057", + "data" : "0x", + "gas" : "10000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000" + }, + "gas" : "9896", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7f80000000000000000000000000000000000000000000000000000000000000007f800000000000000000000000000000000000000000000000000000000000000002600057", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7f80000000000000000000000000000000000000000000000000000000000000007f800000000000000000000000000000000000000000000000000000000000000002600057", + "nonce" : "0", + "storage" : { + } + } + } + }, + "mul6" : { + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02600057", + "data" : "0x", + "gas" : "10000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000" + }, + "gas" : "9796", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02600057", + "nonce" : "0", + "storage" : { + "0x" : "0x01" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff02600057", + "nonce" : "0", + "storage" : { + } + } + } + }, "neg0" : { "callcreates" : [ ], diff --git a/ethereumj-core/src/test/resources/jsontestsuite/vmBitwiseLogicOperationTest.json b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmBitwiseLogicOperationTest.json similarity index 100% rename from ethereumj-core/src/test/resources/jsontestsuite/vmBitwiseLogicOperationTest.json rename to ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmBitwiseLogicOperationTest.json diff --git a/ethereumj-core/src/test/resources/jsontestsuite/vmBlockInfoTest.json b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmBlockInfoTest.json similarity index 100% rename from ethereumj-core/src/test/resources/jsontestsuite/vmBlockInfoTest.json rename to ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmBlockInfoTest.json diff --git a/ethereumj-core/src/test/resources/jsontestsuite/vmEnvironmentalInfoTest.json b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmEnvironmentalInfoTest.json similarity index 99% rename from ethereumj-core/src/test/resources/jsontestsuite/vmEnvironmentalInfoTest.json rename to ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmEnvironmentalInfoTest.json index 35ad5f8f..0b24173d 100644 --- a/ethereumj-core/src/test/resources/jsontestsuite/vmEnvironmentalInfoTest.json +++ b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmEnvironmentalInfoTest.json @@ -1128,4 +1128,4 @@ } } } -} \ No newline at end of file +} diff --git a/ethereumj-core/src/test/resources/jsontestsuite/vmIOandFlowOperationsTest.json b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmIOandFlowOperationsTest.json similarity index 90% rename from ethereumj-core/src/test/resources/jsontestsuite/vmIOandFlowOperationsTest.json rename to ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmIOandFlowOperationsTest.json index 3fba6c00..c5034754 100644 --- a/ethereumj-core/src/test/resources/jsontestsuite/vmIOandFlowOperationsTest.json +++ b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmIOandFlowOperationsTest.json @@ -148,7 +148,7 @@ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, - "gas" : "9796", + "gas" : "9997", "out" : "0x", "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { @@ -156,7 +156,6 @@ "code" : "0x60236007586001600257", "nonce" : "0", "storage" : { - "0x02" : "0x23" } } }, @@ -212,6 +211,91 @@ } } }, + "jump0_jumpdest0" : { + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x602360085860015d600257", + "data" : "0x", + "gas" : "10000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000" + }, + "gas" : "9796", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x602360085860015d600257", + "nonce" : "0", + "storage" : { + "0x02" : "0x23" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x602360085860015d600257", + "nonce" : "0", + "storage" : { + } + } + } + }, + "jump0_jumpdest1" : { + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x602360075860015d600257", + "data" : "0x", + "gas" : "10000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000" + }, + "gas" : "9997", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x602360075860015d600257", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x602360075860015d600257", + "nonce" : "0", + "storage" : { + } + } + } + }, "jumpi0" : { "callcreates" : [ ], @@ -233,7 +317,7 @@ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, - "gas" : "9795", + "gas" : "9996", "out" : "0x", "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { @@ -241,7 +325,6 @@ "code" : "0x602360016009596001600257", "nonce" : "0", "storage" : { - "0x02" : "0x23" } } }, @@ -298,6 +381,49 @@ } } }, + "jumpi1_jumpdest" : { + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "1000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x60236001600a5960015d600257", + "data" : "0x", + "gas" : "10000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000" + }, + "gas" : "9795", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x60236001600a5960015d600257", + "nonce" : "0", + "storage" : { + "0x02" : "0x23" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x60236001600a5960015d600257", + "nonce" : "0", + "storage" : { + } + } + } + }, "mloadError0" : { "callcreates" : [ ], @@ -1044,7 +1170,7 @@ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, - "gas" : "9999", + "gas" : "10000", "out" : "0x", "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { diff --git a/ethereumj-core/src/test/resources/jsontestsuite/vmPushDupSwapTest.json b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmPushDupSwapTest.json similarity index 99% rename from ethereumj-core/src/test/resources/jsontestsuite/vmPushDupSwapTest.json rename to ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmPushDupSwapTest.json index 444ccc5d..f7fcb335 100644 --- a/ethereumj-core/src/test/resources/jsontestsuite/vmPushDupSwapTest.json +++ b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmPushDupSwapTest.json @@ -407,7 +407,7 @@ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, - "gas" : "9998", + "gas" : "9999", "out" : "0x", "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { @@ -2555,7 +2555,7 @@ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000" }, - "gas" : "9997", + "gas" : "9998", "out" : "0x", "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { diff --git a/ethereumj-core/src/test/resources/jsontestsuite/vmSha3Test.json b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmSha3Test.json similarity index 100% rename from ethereumj-core/src/test/resources/jsontestsuite/vmSha3Test.json rename to ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmSha3Test.json diff --git a/ethereumj-core/src/test/resources/jsontestsuite/vmSystemOperationsTest.json b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmSystemOperationsTest.json similarity index 74% rename from ethereumj-core/src/test/resources/jsontestsuite/vmSystemOperationsTest.json rename to ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmSystemOperationsTest.json index c3e339f2..a2dd1d1c 100644 --- a/ethereumj-core/src/test/resources/jsontestsuite/vmSystemOperationsTest.json +++ b/ethereumj-core/src/test/resources/jsontestsuite/vmtests/vmSystemOperationsTest.json @@ -1,5 +1,5 @@ { - "ABAcalls" : { + "ABAcalls0" : { "callcreates" : [ { "data" : "0x", @@ -63,6 +63,198 @@ } } }, + "ABAcalls1" : { + "callcreates" : [ + { + "data" : "0x", + "destination" : "945304eb96065b2a98b57a48a06ae28d285a71b5", + "gasLimit" : "9999999998992", + "value" : "24" + } + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "10000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x6000600060006000601873945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f15a57", + "data" : "0x", + "gas" : "10000000000000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "100000" + }, + "gas" : "898727", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "999999999999999488", + "code" : "0x6000600060006000601873945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f15a57", + "nonce" : "0", + "storage" : { + "0x25" : "0x01" + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "535", + "code" : "0x60006000600060006017730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f16001015a57", + "nonce" : "0", + "storage" : { + "0x28" : "0x02" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x6000600060006000601873945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f15a57", + "nonce" : "0", + "storage" : { + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "23", + "code" : "0x60006000600060006017730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f16001015a57", + "nonce" : "0", + "storage" : { + } + } + } + }, + "ABAcalls2" : { + "callcreates" : [ + { + "data" : "0x", + "destination" : "945304eb96065b2a98b57a48a06ae28d285a71b5", + "gasLimit" : "9999999998768", + "value" : "1" + } + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "10000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1", + "data" : "0x", + "gas" : "10000000000000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "100000" + }, + "gas" : "1003475", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "999999999999999488", + "code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1", + "nonce" : "0", + "storage" : { + "0x" : "0x01" + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "512", + "code" : "0x60016000560160005760006000600060006000730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f1", + "nonce" : "0", + "storage" : { + "0x" : "0x0200" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1", + "nonce" : "0", + "storage" : { + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "0", + "code" : "0x60016000560160005760006000600060006000730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f1", + "nonce" : "0", + "storage" : { + } + } + } + }, + "ABAcalls3" : { + "callcreates" : [ + { + "data" : "0x", + "destination" : "945304eb96065b2a98b57a48a06ae28d285a71b5", + "gasLimit" : "998768", + "value" : "1" + } + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "10000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1", + "data" : "0x", + "gas" : "1000000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "100000" + }, + "gas" : "864457", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1024558", + "code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1", + "nonce" : "0", + "storage" : { + "0x" : "0x01" + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "442", + "code" : "0x60016000560160005760006000600060006000730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f1", + "nonce" : "0", + "storage" : { + "0x" : "0x01b9" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1025000", + "code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1", + "nonce" : "0", + "storage" : { + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "0", + "code" : "0x60016000560160005760006000600060006000730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f1", + "nonce" : "0", + "storage" : { + } + } + } + }, "ABAcallsSuicide0" : { "callcreates" : [ { @@ -175,7 +367,7 @@ } } }, - "CallRecursiveBomb" : { + "CallRecursiveBomb0" : { "callcreates" : [ { "data" : "0x", @@ -239,6 +431,156 @@ } } }, + "CallRecursiveBomb1" : { + "callcreates" : [ + { + "data" : "0x", + "destination" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "gasLimit" : "364267", + "value" : "0" + } + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "10000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "data" : "0x", + "gas" : "364723", + "gasPrice" : "1", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "100000" + }, + "gas" : "104246", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "20000000", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "nonce" : "0", + "storage" : { + "0x" : "0x03fe", + "0x01" : "0x01" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "20000000", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "nonce" : "0", + "storage" : { + } + } + } + }, + "CallRecursiveBomb2" : { + "callcreates" : [ + { + "data" : "0x", + "destination" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "gasLimit" : "364268", + "value" : "0" + } + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "10000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "data" : "0x", + "gas" : "364724", + "gasPrice" : "1", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "100000" + }, + "gas" : "104551", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "20000000", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "nonce" : "0", + "storage" : { + "0x" : "0x03ff", + "0x01" : "0x01" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "20000000", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "nonce" : "0", + "storage" : { + } + } + } + }, + "CallRecursiveBomb3" : { + "callcreates" : [ + { + "data" : "0x", + "destination" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "gasLimit" : "999544", + "value" : "0" + } + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "10000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "data" : "0x", + "gas" : "1000000", + "gasPrice" : "1", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "100000" + }, + "gas" : "104551", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "20000000", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "nonce" : "0", + "storage" : { + "0x" : "0x03ff", + "0x01" : "0x01" + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "20000000", + "code" : "0x600160005601600057600060006000600060003060e05c03f1600157", + "nonce" : "0", + "storage" : { + } + } + } + }, "CallToNameRegistrator0" : { "callcreates" : [ { @@ -279,7 +621,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "46", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" : "0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa" @@ -296,7 +638,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -343,7 +685,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "46", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { "0xeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00" : "0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa" @@ -360,7 +702,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -407,7 +749,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "46", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -423,7 +765,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -469,7 +811,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "46", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -485,7 +827,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -525,7 +867,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -541,7 +883,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -581,7 +923,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -597,7 +939,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -637,7 +979,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -653,7 +995,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -726,12 +1068,6 @@ }, "PostToNameRegistrator0" : { "callcreates" : [ - { - "data" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa", - "destination" : "945304eb96065b2a98b57a48a06ae28d285a71b5", - "gasLimit" : "1000000", - "value" : "23" - } ], "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", @@ -744,43 +1080,42 @@ "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa60205460406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080", "data" : "0x", "gas" : "10000000000000", "gasPrice" : "100000000000000", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "100000" }, - "gas" : "9999998999967", + "gas" : "9999999999991", "out" : "0x", "post" : { - "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "999999999999999977", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa60205460406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3", - "nonce" : "0", - "storage" : { - } - }, - "945304eb96065b2a98b57a48a06ae28d285a71b5" : { - "balance" : "46", - "code" : "0x600035560f6009590060203560003557", - "nonce" : "0", - "storage" : { - "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" : "0xaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa" - } - } - }, - "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa60205460406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080", "nonce" : "0", "storage" : { } }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080", + "nonce" : "0", + "storage" : { + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "23", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -789,12 +1124,6 @@ }, "PostToReturn1" : { "callcreates" : [ - { - "data" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa", - "destination" : "945304eb96065b2a98b57a48a06ae28d285a71b5", - "gasLimit" : "1000000", - "value" : "23" - } ], "env" : { "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", @@ -807,25 +1136,25 @@ "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa60205460406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080", "data" : "0x", "gas" : "10000000000000", "gasPrice" : "100000000000000", "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "100000" }, - "gas" : "9999998999967", + "gas" : "9999999999991", "out" : "0x", "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "999999999999999977", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa60205460406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3", + "balance" : "1000000000000000000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080", "nonce" : "0", "storage" : { } }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { - "balance" : "46", + "balance" : "23", "code" : "0x603760005560026000f2", "nonce" : "0", "storage" : { @@ -835,7 +1164,7 @@ "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa60205460406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080", "nonce" : "0", "storage" : { } @@ -863,7 +1192,7 @@ "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "data" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffafffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa", "gas" : "10000", "gasPrice" : "100000000000000", @@ -875,7 +1204,7 @@ "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa" : "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa" @@ -885,14 +1214,14 @@ "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } } } }, - "callstatelessToNameRegistrator0" : { + "callcodeToNameRegistrator0" : { "callcreates" : [ { "data" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa", @@ -912,7 +1241,7 @@ "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546000604060406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f4600057", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546000604060406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3600057", "data" : "0x", "gas" : "10000000000000", "gasPrice" : "100000000000000", @@ -924,7 +1253,7 @@ "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546000604060406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f4600057", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546000604060406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3600057", "nonce" : "0", "storage" : { "0x" : "0x01", @@ -933,7 +1262,7 @@ }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -942,21 +1271,21 @@ "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546000604060406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f4600057", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546000604060406000601773945304eb96065b2a98b57a48a06ae28d285a71b5620f4240f3600057", "nonce" : "0", "storage" : { } }, "945304eb96065b2a98b57a48a06ae28d285a71b5" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } } } }, - "callstatelessToReturn1" : { + "callcodeToReturn1" : { "callcreates" : [ { "data" : "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa", @@ -976,7 +1305,7 @@ "exec" : { "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546002600060406000601773945304eb96065b2a98b57a48a06ae28d285a71b56101f4f4600057", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546002600060406000601773945304eb96065b2a98b57a48a06ae28d285a71b56101f4f3600057", "data" : "0x", "gas" : "10000000000000", "gasPrice" : "100000000000000", @@ -988,7 +1317,7 @@ "post" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546002600060406000601773945304eb96065b2a98b57a48a06ae28d285a71b56101f4f4600057", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546002600060406000601773945304eb96065b2a98b57a48a06ae28d285a71b56101f4f3600057", "nonce" : "0", "storage" : { "0x" : "0x01", @@ -1006,7 +1335,121 @@ "pre" : { "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", - "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546002600060406000601773945304eb96065b2a98b57a48a06ae28d285a71b56101f4f4600057", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546002600060406000601773945304eb96065b2a98b57a48a06ae28d285a71b56101f4f3600057", + "nonce" : "0", + "storage" : { + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "23", + "code" : "0x6001600157603760005560026000f2", + "nonce" : "0", + "storage" : { + } + } + } + }, + "callstatelessToNameRegistrator0" : { + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "10000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080600057", + "data" : "0x", + "gas" : "10000000000000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "100000" + }, + "gas" : "9999999999790", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080600057", + "nonce" : "0", + "storage" : { + "0x" : "0x80" + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "23", + "code" : "0x600035560f600a59005d60203560003557", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080600057", + "nonce" : "0", + "storage" : { + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "23", + "code" : "0x600035560f600a59005d60203560003557", + "nonce" : "0", + "storage" : { + } + } + } + }, + "callstatelessToReturn1" : { + "callcreates" : [ + ], + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "256", + "currentGasLimit" : "10000000", + "currentNumber" : "0", + "currentTimestamp" : "1", + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080600057", + "data" : "0x", + "gas" : "10000000000000", + "gasPrice" : "100000000000000", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "100000" + }, + "gas" : "9999999999790", + "out" : "0x", + "post" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080600057", + "nonce" : "0", + "storage" : { + "0x" : "0x80" + } + }, + "945304eb96065b2a98b57a48a06ae28d285a71b5" : { + "balance" : "23", + "code" : "0x6001600157603760005560026000f2", + "nonce" : "0", + "storage" : { + } + } + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "code" : "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6000547faaffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffaa6020546080600057", "nonce" : "0", "storage" : { } @@ -1354,7 +1797,7 @@ "post" : { "cd1722f3947def4cf144679da39c4c32bdc35681" : { "balance" : "1000000000000000023", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -1370,7 +1813,7 @@ }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -1410,7 +1853,7 @@ }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -1426,7 +1869,7 @@ }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -1459,7 +1902,7 @@ "post" : { "cd1722f3947def4cf144679da39c4c32bdc35681" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } @@ -1475,11 +1918,11 @@ }, "cd1722f3947def4cf144679da39c4c32bdc35681" : { "balance" : "23", - "code" : "0x600035560f6009590060203560003557", + "code" : "0x600035560f600a59005d60203560003557", "nonce" : "0", "storage" : { } } } } -} +} \ No newline at end of file diff --git a/ethereumj-studio/src/main/resources/log4j.properties b/ethereumj-studio/src/main/resources/log4j.properties index 0f15bdee..165e3d7b 100644 --- a/ethereumj-studio/src/main/resources/log4j.properties +++ b/ethereumj-studio/src/main/resources/log4j.properties @@ -23,8 +23,8 @@ log4j.appender.file.RollingPolicy.FileNamePattern=./logs/ethereum_%d{yyyy-MM-dd} # filter noisy classes log4j.logger.block = ERROR log4j.logger.wallet = ERROR -log4j.logger.net = DEBUG -log4j.logger.wire = DEBUG +log4j.logger.net = ERROR +log4j.logger.wire = ERROR log4j.logger.db = ERROR log4j.logger.peerdiscovery = ERROR log4j.logger.peermonitor = ERROR @@ -33,8 +33,8 @@ log4j.logger.io.netty = ERROR log4j.logger.VM = ERROR log4j.logger.main = ERROR log4j.logger.trie = ERROR -log4j.logger.state = INFO -log4j.logger.repository = INFO +log4j.logger.state = ERROR +log4j.logger.repository = ERROR log4j.logger.blockchain = INFO log4j.logger.blockqueue = ERROR log4j.logger.txs = ERROR