3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 06:44:16 +00:00

TestWithPeerGroup: don't stopAsync if the peergroup isn't running and update the class description.

This commit is contained in:
Mike Hearn 2014-11-17 14:38:56 +01:00
parent 5a8ed59029
commit 34017e16f8

View File

@ -34,7 +34,9 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
/** /**
* Utility class that makes it easy to work with mock NetworkConnections in PeerGroups. * You can derive from this class and call peerGroup.start() in your tests to get a functional PeerGroup that can be
* used with loopback peers created using connectPeer. This involves real TCP connections so is a pretty accurate
* mock, but means unit tests cannot be run simultaneously.
*/ */
public class TestWithPeerGroup extends TestWithNetworkConnections { public class TestWithPeerGroup extends TestWithNetworkConnections {
protected static final NetworkParameters params = UnitTestParams.get(); protected static final NetworkParameters params = UnitTestParams.get();
@ -72,7 +74,8 @@ public class TestWithPeerGroup extends TestWithNetworkConnections {
super.tearDown(); super.tearDown();
blockJobs = false; blockJobs = false;
Utils.finishMockSleep(); Utils.finishMockSleep();
peerGroup.stopAsync(); if (peerGroup.isRunning())
peerGroup.stopAsync();
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }