Skip to content

Commit

Permalink
AKI-536 Give concurrent suite more control over unity forkpoint
Browse files Browse the repository at this point in the history
Concurrent runner waits for 2 blocks after the fork before starting any tests
  • Loading branch information
geoff-aion committed Nov 15, 2019
1 parent ede8c24 commit 8eee41e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.aion.equihash.EquihashMiner;
import org.aion.harness.main.NodeFactory.NodeType;
import org.aion.harness.main.NodeListener;
import org.aion.harness.main.event.Event;
import org.aion.harness.main.event.IEvent;
import org.aion.harness.main.event.JavaPrepackagedLogEvents;
import org.aion.harness.main.event.RustPrepackagedLogEvents;
import org.aion.harness.result.FutureResult;
import org.aion.harness.result.LogEventResult;
import org.aion.harness.tests.integ.runner.exception.TestRunnerInitializationException;
import org.aion.harness.tests.integ.runner.exception.UnexpectedTestRunnerException;
import org.aion.harness.tests.integ.runner.exception.UnsupportedAnnotation;
Expand Down Expand Up @@ -122,6 +129,8 @@ public void run(RunNotifier runNotifier) {
// StakingBlockSigner currently needs to be started after the node's rpc is up and running
stakingBlockSigner.start();

waitForBlock(7, testNodeManager.newNodeListener(), nt);

// Run every @BeforeClass method in any of the test classes.
List<FailedClass> failedClasses = runAllBeforeClassMethodsAndReturnFailedClasses(nt);

Expand Down Expand Up @@ -169,6 +178,24 @@ public void run(RunNotifier runNotifier) {
System.setErr(originalStderr);
}

private void waitForBlock(int num, NodeListener listener, NodeType nt) throws TimeoutException, InterruptedException {
IEvent blockSealedEvent;
if (nt == NodeType.JAVA_NODE) {
blockSealedEvent = new Event("PendingStateImpl.processBest: #" + num);
} else if (nt == NodeType.RUST_NODE) {
blockSealedEvent = new Event(" block added. #" + num);
} else {
throw new RuntimeException("Unknown Node Type");
}

FutureResult<LogEventResult> resultFuture = listener.listenForEvent(blockSealedEvent, 3, TimeUnit.MINUTES);
LogEventResult res = resultFuture.get(3, TimeUnit.MINUTES);

if (!res.eventWasObserved()) {
throw new RuntimeException("Didn't observe block sealed string");
}
}

/**
* Grabs all of the N test methods from the given test classes and hands them out to the threads.
* The minimum of (N, MAX_NUM_THREADS) threads will be used to run the tests.
Expand Down
2 changes: 1 addition & 1 deletion Tests/test_resources/custom/config/fork.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
fork0.3.2=0
fork0.4.0=0
fork1.0=4
fork1.0=5
2 changes: 1 addition & 1 deletion Tests/test_resources/rust_custom/custom.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"maximumExtraDataSize": "0x20",
"minGasLimit": "0x100590",
"monetaryPolicyUpdate": "0",
"unityUpdate": "4"
"unityUpdate": "5"
},
"genesis": {
"seal": {
Expand Down

0 comments on commit 8eee41e

Please sign in to comment.