use of bisq.core.btc.BitcoinNodes.BtcNode in project bisq-core by bisq-network.
the class BtcNodeConverterTest method testConvertWithTor.
@Test
public void testConvertWithTor() throws DnsLookupException {
InetAddress expected = mock(InetAddress.class);
Facade facade = mock(Facade.class);
when(facade.torLookup(any(), anyString())).thenReturn(expected);
BtcNode node = mock(BtcNode.class);
when(node.getHostNameOrAddress()).thenReturn("aaa.onion");
PeerAddress peerAddress = new BtcNodeConverter(facade).convertWithTor(node, mock(Socks5Proxy.class));
// noinspection ConstantConditions
assertEquals(expected, peerAddress.getAddr());
}
use of bisq.core.btc.BitcoinNodes.BtcNode in project bisq-core by bisq-network.
the class BtcNodeConverterTest method testConvertClearNode.
@Ignore
@Test
public void testConvertClearNode() {
final String ip = "192.168.0.1";
BtcNode node = mock(BtcNode.class);
when(node.getHostNameOrAddress()).thenReturn(ip);
PeerAddress peerAddress = new BtcNodeConverter().convertClearNode(node);
// noinspection ConstantConditions
InetAddress inetAddress = peerAddress.getAddr();
assertEquals(ip, inetAddress.getHostName());
}
use of bisq.core.btc.BitcoinNodes.BtcNode in project bisq-core by bisq-network.
the class PeerAddressesRepositoryTest method testGetPeerAddressesWhenOnionNodesOnly.
@Test
public void testGetPeerAddressesWhenOnionNodesOnly() {
BtcNode node = mock(BtcNode.class);
when(node.hasClearNetAddress()).thenReturn(true);
BtcNode onionNode = mock(BtcNode.class);
when(node.hasOnionAddress()).thenReturn(true);
BtcNodeConverter converter = mock(BtcNodeConverter.class, RETURNS_DEEP_STUBS);
PeerAddressesRepository repository = new PeerAddressesRepository(converter, Lists.newArrayList(node, onionNode));
List<PeerAddress> peers = repository.getPeerAddresses(mock(Socks5Proxy.class), false);
assertEquals(1, peers.size());
}
use of bisq.core.btc.BitcoinNodes.BtcNode in project bisq-core by bisq-network.
the class PeerAddressesRepositoryTest method testGetPeerAddressesWhenProxyAndClearNodes.
@Test
public void testGetPeerAddressesWhenProxyAndClearNodes() {
BtcNode node = mock(BtcNode.class);
when(node.hasClearNetAddress()).thenReturn(true);
BtcNode onionNode = mock(BtcNode.class);
when(node.hasOnionAddress()).thenReturn(true);
BtcNodeConverter converter = mock(BtcNodeConverter.class, RETURNS_DEEP_STUBS);
PeerAddressesRepository repository = new PeerAddressesRepository(converter, Lists.newArrayList(node, onionNode));
List<PeerAddress> peers = repository.getPeerAddresses(mock(Socks5Proxy.class), true);
assertEquals(2, peers.size());
}
use of bisq.core.btc.BitcoinNodes.BtcNode in project bisq-core by bisq-network.
the class PeerAddressesRepositoryTest method testGetPeerAddressesWhenClearNodes.
@Test
public void testGetPeerAddressesWhenClearNodes() {
BtcNode node = mock(BtcNode.class);
when(node.hasClearNetAddress()).thenReturn(true);
BtcNodeConverter converter = mock(BtcNodeConverter.class, RETURNS_DEEP_STUBS);
PeerAddressesRepository repository = new PeerAddressesRepository(converter, Collections.singletonList(node));
List<PeerAddress> peers = repository.getPeerAddresses(null, false);
assertFalse(peers.isEmpty());
}
Aggregations