Code cleanup

This commit is contained in:
2016-02-24 22:51:35 +01:00
parent f5215be8c6
commit 4dd639e651
14 changed files with 107 additions and 37 deletions

View File

@ -114,7 +114,7 @@ class Connection {
public static Connection sync(InternalContext ctx, InetAddress address, int port, MessageListener listener,
long timeoutInSeconds) throws IOException {
return new Connection(ctx, Mode.SYNC, listener, new Socket(address, port),
return new Connection(ctx, SYNC, listener, new Socket(address, port),
new HashSet<InventoryVector>(),
new HashSet<InventoryVector>(),
new NetworkAddress.Builder().ip(address).port(port).stream(1).build(),

View File

@ -171,6 +171,8 @@ public class DefaultNetworkHandler implements NetworkHandler, ContextHolder {
case ACTIVE:
active++;
break;
default:
// nothing to do
}
}
}

View File

@ -52,30 +52,30 @@ public class NetworkHandlerTest {
public static void setUp() {
peerInventory = new TestInventory();
peer = new BitmessageContext.Builder()
.addressRepo(Mockito.mock(AddressRepository.class))
.addressRepo(mock(AddressRepository.class))
.inventory(peerInventory)
.messageRepo(Mockito.mock(MessageRepository.class))
.powRepo(Mockito.mock(ProofOfWorkRepository.class))
.messageRepo(mock(MessageRepository.class))
.powRepo(mock(ProofOfWorkRepository.class))
.port(6001)
.nodeRegistry(new TestNodeRegistry())
.networkHandler(new DefaultNetworkHandler())
.cryptography(new BouncyCryptography())
.listener(Mockito.mock(BitmessageContext.Listener.class))
.listener(mock(BitmessageContext.Listener.class))
.build();
peer.startup();
nodeInventory = new TestInventory();
networkHandler = new DefaultNetworkHandler();
node = new BitmessageContext.Builder()
.addressRepo(Mockito.mock(AddressRepository.class))
.addressRepo(mock(AddressRepository.class))
.inventory(nodeInventory)
.messageRepo(Mockito.mock(MessageRepository.class))
.powRepo(Mockito.mock(ProofOfWorkRepository.class))
.messageRepo(mock(MessageRepository.class))
.powRepo(mock(ProofOfWorkRepository.class))
.port(6002)
.nodeRegistry(new TestNodeRegistry(localhost))
.networkHandler(networkHandler)
.cryptography(new BouncyCryptography())
.listener(Mockito.mock(BitmessageContext.Listener.class))
.listener(mock(BitmessageContext.Listener.class))
.build();
}