package org.ethereum.jsontestsuite;

import org.ethereum.core.BlockHeader;
import org.json.simple.parser.ParseException;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

import static org.junit.Assert.*;

/**
 * @author Mikhail Kalinin
 * @since 02.09.2015
 */
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubBasicTest {

    private static final Logger logger = LoggerFactory.getLogger("TCK-Test");

    @Test
    public void runDifficultyTest() throws IOException, ParseException {

        String shacommit = "b814f9fb484889bda407f2b9349983f211b77753";
        String json = JSONReader.loadJSONFromCommit("BasicTests/difficulty.json", shacommit);

        DifficultyTestSuite testSuite = new DifficultyTestSuite(json);

        for (DifficultyTestCase testCase : testSuite.getTestCases()) {

            logger.info("Running {}\n", testCase.getName());

            BlockHeader current = testCase.getCurrent();
            BlockHeader parent = testCase.getParent();

            assertEquals(testCase.getExpectedDifficulty(), current.calcDifficulty(parent));
        }
    }
}

@@ -30,16 +30,61 @@
 suite;%0A%0A
+import org.ethereum.config.SystemProperties;%0A
 import o
@@ -109,24 +109,24 @@
 lockHeader;%0A
-
 import org.j
@@ -159,16 +159,41 @@
 eption;%0A
+import org.junit.Before;%0A
 import o
@@ -400,16 +400,75 @@
 ssert.*;
+%0Aimport static org.ethereum.config.SystemProperties.CONFIG;
 %0A%0A/**%0A *
@@ -591,24 +591,24 @@
 asicTest %7B%0A%0A
-
     private 
@@ -670,24 +670,198 @@
 CK-Test%22);%0A%0A
+    @Before%0A    public void setup() %7B%0A%0A        // if not set explicitly%0A        // this test fails being run by Gradle%0A        CONFIG.setGenesisInfo(%22frontier.json%22);%0A    %7D%0A%0A
     @Test%0A  

Fix difficulty test to run correctly via Gradle