From bc24645644dc49e950ea534505d63b1064e70db0 Mon Sep 17 00:00:00 2001 From: nicksavers Date: Sun, 13 Jul 2014 23:05:04 +0200 Subject: [PATCH] Add namecoin.json and fix in TestRunner --- .../java/org/ethereum/db/ContractDetails.java | 1 - .../ethereum/jsontestsuite/AccountState.java | 1 - .../ethereum/jsontestsuite/TestRunner.java | 4 ++-- .../jsontestsuite/JSONTestSuiteTest.java | 23 ++++++++++++++++++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java b/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java index 5f2363d5..57df990e 100644 --- a/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java +++ b/ethereumj-core/src/main/java/org/ethereum/db/ContractDetails.java @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.ethereum.crypto.SHA3Helper; import org.ethereum.trie.Trie; import org.ethereum.util.RLP; import org.ethereum.util.RLPElement; diff --git a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/AccountState.java b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/AccountState.java index a6ffe60a..2e05b003 100644 --- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/AccountState.java +++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/AccountState.java @@ -2,7 +2,6 @@ package org.ethereum.jsontestsuite; import org.ethereum.db.ByteArrayWrapper; import org.ethereum.util.ByteUtil; -import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.spongycastle.util.encoders.Hex; 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 88e47526..86d0ba37 100644 --- a/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java +++ b/ethereumj-core/src/main/java/org/ethereum/jsontestsuite/TestRunner.java @@ -65,7 +65,7 @@ public class TestRunner { Env env = testCase.getEnv(); Exec exec = testCase.getExec(); - byte[] address = exec.getAddress(); + byte[] address = exec.getAddress(); //repository.createAccount(address); byte[] origin = exec.getOrigin(); byte[] caller = exec.getCaller(); byte[] balance = ByteUtil.bigIntegerToBytes(repository.getBalance(exec.getAddress())); @@ -158,7 +158,7 @@ public class TestRunner { byte[] expectedStValue = storage.get(storageKey).getData(); ContractDetails contractDetails = - program.getResult().getRepository().getContractDetails(storageKey.getData()); + program.getResult().getRepository().getContractDetails(accountState.getAddress()); if (contractDetails == null){ diff --git a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/JSONTestSuiteTest.java b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/JSONTestSuiteTest.java index 78c75398..45da05f5 100644 --- a/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/JSONTestSuiteTest.java +++ b/ethereumj-core/src/test/java/org/ethereum/jsontestsuite/JSONTestSuiteTest.java @@ -314,8 +314,29 @@ public class JSONTestSuiteTest { List result = runner.runTestCase(testCase); Assert.assertTrue(result.isEmpty()); } - } + + @Test // testing full suite + public void testNameCoinFromGitHub() throws ParseException { + String json = Utils.getFromUrl("https://raw.githubusercontent.com/ethereum/tests/develop/namecoin.json"); + Assume.assumeFalse("Online test suite is no 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(); + + System.out.println("Running: " + testCase.getName()); + TestRunner runner = new TestRunner(); + List result = runner.runTestCase(testCase); + Assert.assertTrue(result.isEmpty()); + } + } + }