Search in sources :

Example 1 with Facade

use of bisq.core.btc.wallet.BtcNodeConverter.Facade in project bisq-core by bisq-network.

the class BtcNodeConverterTest method testConvertOnionHostOnFailure.

@Test
public void testConvertOnionHostOnFailure() throws UnknownHostException {
    BtcNode node = mock(BtcNode.class);
    when(node.getOnionAddress()).thenReturn("aaa.onion");
    Facade facade = mock(Facade.class);
    when(facade.onionHostToInetAddress(any())).thenThrow(UnknownHostException.class);
    PeerAddress peerAddress = new BtcNodeConverter(facade).convertOnionHost(node);
    assertNull(peerAddress);
}
Also used : Facade(bisq.core.btc.wallet.BtcNodeConverter.Facade) PeerAddress(org.bitcoinj.core.PeerAddress) BtcNode(bisq.core.btc.BitcoinNodes.BtcNode) Test(org.junit.Test)

Example 2 with Facade

use of bisq.core.btc.wallet.BtcNodeConverter.Facade in project bisq-core by bisq-network.

the class BtcNodeConverterTest method testConvertOnionHost.

@Test
public void testConvertOnionHost() throws UnknownHostException {
    BtcNode node = mock(BtcNode.class);
    when(node.getOnionAddress()).thenReturn("aaa.onion");
    InetAddress inetAddress = mock(InetAddress.class);
    Facade facade = mock(Facade.class);
    when(facade.onionHostToInetAddress(any())).thenReturn(inetAddress);
    PeerAddress peerAddress = new BtcNodeConverter(facade).convertOnionHost(node);
    // noinspection ConstantConditions
    assertEquals(inetAddress, peerAddress.getAddr());
}
Also used : Facade(bisq.core.btc.wallet.BtcNodeConverter.Facade) PeerAddress(org.bitcoinj.core.PeerAddress) BtcNode(bisq.core.btc.BitcoinNodes.BtcNode) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 3 with Facade

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

Aggregations

BtcNode (bisq.core.btc.BitcoinNodes.BtcNode)3 Facade (bisq.core.btc.wallet.BtcNodeConverter.Facade)3 PeerAddress (org.bitcoinj.core.PeerAddress)3 Test (org.junit.Test)3 InetAddress (java.net.InetAddress)2 Socks5Proxy (com.runjva.sourceforge.jsocks.protocol.Socks5Proxy)1