mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 10:15:52 +00:00
More PeerTest cleanup
This commit is contained in:
parent
bdfc72913c
commit
e89fe1a4ea
@ -112,12 +112,7 @@ public class PeerTest {
|
|||||||
// Check that it runs through the event loop and shut down correctly
|
// Check that it runs through the event loop and shut down correctly
|
||||||
@Test
|
@Test
|
||||||
public void testRun_normal() throws Exception {
|
public void testRun_normal() throws Exception {
|
||||||
expectPeerDisconnect();
|
runPeerAndVerify();
|
||||||
|
|
||||||
control.replay();
|
|
||||||
|
|
||||||
peer.run();
|
|
||||||
control.verify();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that when we receive a block that does not connect to our chain, we send a
|
// Check that when we receive a block that does not connect to our chain, we send a
|
||||||
@ -140,12 +135,7 @@ public class PeerTest {
|
|||||||
conn.writeMessage(capture(message));
|
conn.writeMessage(capture(message));
|
||||||
expectLastCall();
|
expectLastCall();
|
||||||
|
|
||||||
expectPeerDisconnect();
|
runPeerAndVerify();
|
||||||
|
|
||||||
control.replay();
|
|
||||||
|
|
||||||
peer.run();
|
|
||||||
control.verify();
|
|
||||||
|
|
||||||
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
||||||
expectedLocator.add(b1.getHash());
|
expectedLocator.add(b1.getHash());
|
||||||
@ -182,12 +172,7 @@ public class PeerTest {
|
|||||||
conn.writeMessage(capture(message));
|
conn.writeMessage(capture(message));
|
||||||
expectLastCall();
|
expectLastCall();
|
||||||
|
|
||||||
expectPeerDisconnect();
|
runPeerAndVerify();
|
||||||
|
|
||||||
control.replay();
|
|
||||||
|
|
||||||
peer.run();
|
|
||||||
control.verify();
|
|
||||||
|
|
||||||
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
List<Sha256Hash> expectedLocator = new ArrayList<Sha256Hash>();
|
||||||
expectedLocator.add(b1.getHash());
|
expectedLocator.add(b1.getHash());
|
||||||
@ -225,12 +210,7 @@ public class PeerTest {
|
|||||||
conn.writeMessage(capture(message));
|
conn.writeMessage(capture(message));
|
||||||
expectLastCall();
|
expectLastCall();
|
||||||
|
|
||||||
expectPeerDisconnect();
|
runPeerAndVerify();
|
||||||
|
|
||||||
control.replay();
|
|
||||||
|
|
||||||
peer.run();
|
|
||||||
control.verify();
|
|
||||||
|
|
||||||
List<InventoryItem> items = message.getValue().getItems();
|
List<InventoryItem> items = message.getValue().getItems();
|
||||||
assertEquals(1, items.size());
|
assertEquals(1, items.size());
|
||||||
@ -319,6 +299,12 @@ public class PeerTest {
|
|||||||
expect(conn.getVersionMessage()).andReturn(new VersionMessage(unitTestParams, 100));
|
expect(conn.getVersionMessage()).andReturn(new VersionMessage(unitTestParams, 100));
|
||||||
listener.onBlocksDownloaded(eq(peer), anyObject(Block.class), eq(99));
|
listener.onBlocksDownloaded(eq(peer), anyObject(Block.class), eq(99));
|
||||||
expectLastCall();
|
expectLastCall();
|
||||||
|
runPeerAndVerify();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stage a disconnect, replay the mocks, run and verify
|
||||||
|
private void runPeerAndVerify() throws IOException, ProtocolException,
|
||||||
|
PeerException {
|
||||||
expectPeerDisconnect();
|
expectPeerDisconnect();
|
||||||
|
|
||||||
control.replay();
|
control.replay();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user