3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-01-30 23:02:15 +00:00

Bugfix from Noa Resare. Resolves issue 29.

This commit is contained in:
Mike Hearn 2011-06-27 11:25:43 +00:00
parent 66e596a8eb
commit 212faf078c
2 changed files with 13 additions and 4 deletions

View File

@ -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 {

View File

@ -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()));
}
}