diff --git a/src/com/google/bitcoin/core/PeerAddress.java b/src/com/google/bitcoin/core/PeerAddress.java index f4aae94b..d83a825b 100644 --- a/src/com/google/bitcoin/core/PeerAddress.java +++ b/src/com/google/bitcoin/core/PeerAddress.java @@ -46,6 +46,7 @@ public class PeerAddress extends Message { this.addr = addr; this.port = port; this.protocolVersion = protocolVersion; + this.services = BigInteger.ZERO; } public void bitcoinSerializeToStream(OutputStream stream) throws IOException { diff --git a/tests/com/google/bitcoin/core/PeerAddressTest.java b/tests/com/google/bitcoin/core/PeerAddressTest.java index 9a6ee711..6d22f106 100644 --- a/tests/com/google/bitcoin/core/PeerAddressTest.java +++ b/tests/com/google/bitcoin/core/PeerAddressTest.java @@ -1,5 +1,5 @@ -/** - * Copyright 2011 Noa Resare +/* + * Copyright 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,14 @@ package com.google.bitcoin.core; import com.google.bitcoin.bouncycastle.util.encoders.Hex; import org.junit.Test; +import java.net.InetAddress; + import static org.junit.Assert.assertEquals; public class PeerAddressTest { @Test - public void testPeerAddressSerialize() throws Exception - { + public void testPeerAddressRoundtrip() throws Exception { // copied verbatim from https://en.bitcoin.it/wiki/Protocol_specification#Network_address String fromSpec = "010000000000000000000000000000000000ffff0a000001208d"; PeerAddress pa = new PeerAddress(NetworkParameters.prodNet(), @@ -33,4 +34,11 @@ public class PeerAddressTest String reserialized = Utils.bytesToHexString(pa.bitcoinSerialize()); assertEquals(reserialized,fromSpec ); } + + @Test + public void testBitcoinSerialize() throws Exception { + PeerAddress pa = new PeerAddress(InetAddress.getByName(null), 8333, 0); + assertEquals("000000000000000000000000000000000000ffff7f000001208d", + Utils.bytesToHexString(pa.bitcoinSerialize())); + } }