mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-19 13:45:48 +00:00
PeerAddressTest: Tidy up parse and bitcoinSerialize tests.
This commit is contained in:
parent
321ac5dbf2
commit
144818ea06
@ -31,12 +31,21 @@ public class PeerAddressTest {
|
|||||||
private static final NetworkParameters MAINNET = MainNetParams.get();
|
private static final NetworkParameters MAINNET = MainNetParams.get();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPeerAddressRoundtrip() throws Exception {
|
public void parse_ancientProtocolVersion() throws Exception {
|
||||||
// copied verbatim from https://en.bitcoin.it/wiki/Protocol_specification#Network_address
|
// copied from https://en.bitcoin.it/wiki/Protocol_documentation#Network_address
|
||||||
String fromSpec = "010000000000000000000000000000000000ffff0a000001208d";
|
String hex = "010000000000000000000000000000000000ffff0a000001208d";
|
||||||
PeerAddress pa = new PeerAddress(MAINNET, HEX.decode(fromSpec), 0, 0);
|
PeerAddress pa = new PeerAddress(MAINNET, HEX.decode(hex), 0, 0);
|
||||||
String reserialized = Utils.HEX.encode(pa.unsafeBitcoinSerialize());
|
assertEquals(26, pa.length);
|
||||||
assertEquals(reserialized, fromSpec);
|
assertEquals(VersionMessage.NODE_NETWORK, pa.getServices().longValue());
|
||||||
|
assertEquals("10.0.0.1", pa.getAddr().getHostAddress());
|
||||||
|
assertEquals(8333, pa.getPort());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void bitcoinSerialize_ancientProtocolVersion() throws Exception {
|
||||||
|
PeerAddress pa = new PeerAddress(MAINNET, InetAddress.getByName(null), 8333, 0, BigInteger.ZERO);
|
||||||
|
assertEquals(26, pa.length);
|
||||||
|
assertEquals("000000000000000000000000000000000000ffff7f000001208d", Utils.HEX.encode(pa.bitcoinSerialize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -89,10 +98,4 @@ public class PeerAddressTest {
|
|||||||
assertEquals(BigInteger.ZERO, pa2.getServices());
|
assertEquals(BigInteger.ZERO, pa2.getServices());
|
||||||
assertEquals(-1, pa2.getTime());
|
assertEquals(-1, pa2.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBitcoinSerialize() throws Exception {
|
|
||||||
PeerAddress pa = new PeerAddress(MAINNET, InetAddress.getByName(null), 8333, 0, BigInteger.ZERO);
|
|
||||||
assertEquals("000000000000000000000000000000000000ffff7f000001208d", Utils.HEX.encode(pa.bitcoinSerialize()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user