Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Update TransitionTests with new test format
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalinin committed Aug 16, 2017
1 parent 1d85930 commit 7a7da0c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.ethereum.config.BlockchainNetConfig;
import org.ethereum.config.blockchain.*;
import org.ethereum.config.net.BaseNetConfig;
import org.ethereum.jsontestsuite.suite.*;
import org.ethereum.jsontestsuite.suite.runners.TransactionTestRunner;
import org.json.simple.JSONObject;
Expand Down Expand Up @@ -263,14 +264,36 @@ public enum Network {
EIP150,
EIP158,
Byzantium,
Constantinople;
Constantinople,

// Transition networks
FrontierToHomesteadAt5,
HomesteadToDaoAt5,
HomesteadToEIP150At5;

public BlockchainNetConfig getConfig() {
switch (this) {

case Frontier: return new FrontierConfig();
case Homestead: return new HomesteadConfig();
case EIP150: return new Eip150HFConfig(new DaoHFConfig());
case EIP158: return new Eip160HFConfig(new DaoHFConfig());

case FrontierToHomesteadAt5: return new BaseNetConfig() {{
add(0, new FrontierConfig());
add(5, new HomesteadConfig());
}};

case HomesteadToDaoAt5: return new BaseNetConfig() {{
add(0, new HomesteadConfig());
add(5, new DaoHFConfig(new HomesteadConfig(), 5));
}};

case HomesteadToEIP150At5: return new BaseNetConfig() {{
add(0, new HomesteadConfig());
add(5, new Eip150HFConfig(new HomesteadConfig()));
}};

default: throw new IllegalArgumentException("Unknown network value: " + this.name());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,47 @@
*/
package org.ethereum.jsontestsuite;

import org.ethereum.config.SystemProperties;
import org.ethereum.config.blockchain.DaoHFConfig;
import org.ethereum.config.blockchain.Eip150HFConfig;
import org.ethereum.config.blockchain.FrontierConfig;
import org.ethereum.config.blockchain.HomesteadConfig;
import org.ethereum.config.net.BaseNetConfig;
import org.ethereum.config.net.MainNetConfig;
import org.ethereum.jsontestsuite.suite.JSONReader;
import org.json.simple.parser.ParseException;
import org.ethereum.jsontestsuite.suite.BlockchainTestSuite;
import org.junit.*;
import org.junit.runners.MethodSorters;

import java.io.IOException;
import java.util.Collections;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubTestNetTest {

//SHACOMMIT of tested commit, ethereum/tests.git
public String shacommit = "9ed33d7440f13c09ce7f038f92abd02d23b26f0d";
static String commitSHA = "85f6d7cc01b6bd04e071f5ba579fc675cfd2043b";
static String treeSHA = "0af522c09e8a264f651f5a4715301381c14784d7"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/TransitionTests

@Before
public void setup() {
SystemProperties.getDefault().setGenesisInfo("frontier.json");
SystemProperties.getDefault().setBlockchainConfig(new BaseNetConfig() {{
add(0, new FrontierConfig());
add(5, new HomesteadConfig());
add(8, new DaoHFConfig(new HomesteadConfig(), 8));
add(10, new Eip150HFConfig(new DaoHFConfig(new HomesteadConfig(), 8)));
static BlockchainTestSuite suite;

}});
@BeforeClass
public static void setup() {
suite = new BlockchainTestSuite(treeSHA, commitSHA);
}

@After
public void clean() {
SystemProperties.getDefault().setBlockchainConfig(MainNetConfig.INSTANCE);
@Test
@Ignore
// this method is mostly for hands-on convenient testing
// using this method turn off initializing of BlockchainTestSuite to avoid unnecessary GitHub API hits
public void bcTransitionSingle() throws IOException {
BlockchainTestSuite.runSingle(
"TransitionTests/bcHomesteadToDao/DaoTransactions.json", commitSHA);
}

@Test
public void bcEIP150Test() throws ParseException, IOException {
String json = JSONReader.loadJSONFromCommit("BlockchainTests/TestNetwork/bcEIP150Test.json", shacommit);
GitHubJSONTestSuite.runGitHubJsonBlockTest(json, Collections.EMPTY_SET);
public void bcFrontierToHomestead() throws IOException {
suite.runAll("TransitionTests/bcFrontierToHomestead", GitHubJSONTestSuite.Network.FrontierToHomesteadAt5);
}

@Test
public void bcSimpleTransitionTest() throws ParseException, IOException {
String json = JSONReader.loadJSONFromCommit("BlockchainTests/TestNetwork/bcSimpleTransitionTest.json", shacommit);
GitHubJSONTestSuite.runGitHubJsonBlockTest(json, Collections.EMPTY_SET);
@Ignore // TODO fix it
public void bcHomesteadToDao() throws IOException {
suite.runAll("TransitionTests/bcHomesteadToDao", GitHubJSONTestSuite.Network.HomesteadToDaoAt5);
}

@Test
public void bcTheDaoTest() throws ParseException, IOException {
String json = JSONReader.loadJSONFromCommit("BlockchainTests/TestNetwork/bcTheDaoTest.json", shacommit);
GitHubJSONTestSuite.runGitHubJsonBlockTest(json, Collections.EMPTY_SET);
public void bcHomesteadToEIP150() throws IOException {
suite.runAll("TransitionTests/bcHomesteadToEIP150", GitHubJSONTestSuite.Network.HomesteadToEIP150At5);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public BlockchainTestSuite(String treeSHA, String commitSHA, GitHubJSONTestSuite
this.networks = networks;
}

public BlockchainTestSuite(String treeSHA, String commitSHA) {
this(treeSHA, commitSHA, GitHubJSONTestSuite.Network.values());
}

private static void run(List<String> checkFiles,
String commitSHA,
GitHubJSONTestSuite.Network[] networks) throws IOException {
Expand Down Expand Up @@ -142,4 +146,9 @@ public static void runSingle(String testFile, String commitSHA,
logger.info(" " + testFile);
run(Collections.singletonList(testFile), commitSHA, new GitHubJSONTestSuite.Network[] { network });
}

public static void runSingle(String testFile, String commitSHA) throws IOException {
logger.info(" " + testFile);
run(Collections.singletonList(testFile), commitSHA, GitHubJSONTestSuite.Network.values());
}
}

0 comments on commit 7a7da0c

Please sign in to comment.