Search in sources :

Example 11 with PeerAddress

use of org.bitcoinj.core.PeerAddress 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());
}
Also used : PeerAddress(org.bitcoinj.core.PeerAddress) BtcNode(bisq.core.btc.BitcoinNodes.BtcNode) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) InetAddress(java.net.InetAddress) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 12 with PeerAddress

use of org.bitcoinj.core.PeerAddress 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());
}
Also used : PeerAddress(org.bitcoinj.core.PeerAddress) Socks5Proxy(com.runjva.sourceforge.jsocks.protocol.Socks5Proxy) BtcNode(bisq.core.btc.BitcoinNodes.BtcNode) Test(org.junit.Test)

Example 13 with PeerAddress

use of org.bitcoinj.core.PeerAddress 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());
}
Also used : PeerAddress(org.bitcoinj.core.PeerAddress) Socks5Proxy(com.runjva.sourceforge.jsocks.protocol.Socks5Proxy) BtcNode(bisq.core.btc.BitcoinNodes.BtcNode) Test(org.junit.Test)

Example 14 with PeerAddress

use of org.bitcoinj.core.PeerAddress 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());
}
Also used : PeerAddress(org.bitcoinj.core.PeerAddress) BtcNode(bisq.core.btc.BitcoinNodes.BtcNode) Test(org.junit.Test)

Aggregations

PeerAddress (org.bitcoinj.core.PeerAddress)14 BtcNode (bisq.core.btc.BitcoinNodes.BtcNode)8 Test (org.junit.Test)8 InetAddress (java.net.InetAddress)5 Nullable (javax.annotation.Nullable)4 Facade (bisq.core.btc.wallet.BtcNodeConverter.Facade)3 Socks5Proxy (com.runjva.sourceforge.jsocks.protocol.Socks5Proxy)3 UnknownHostException (java.net.UnknownHostException)2 DnsLookupException (bisq.network.DnsLookupException)1 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 File (java.io.File)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 InetSocketAddress (java.net.InetSocketAddress)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 AddressMessage (org.bitcoinj.core.AddressMessage)1 BlockChain (org.bitcoinj.core.BlockChain)1 Peer (org.bitcoinj.core.Peer)1 PeerGroup (org.bitcoinj.core.PeerGroup)1