mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 07:12:17 +00:00
Bugfix from Noa Resare. Resolves issue 29.
This commit is contained in:
parent
66e596a8eb
commit
212faf078c
@ -46,6 +46,7 @@ public class PeerAddress extends Message {
|
|||||||
this.addr = addr;
|
this.addr = addr;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.protocolVersion = protocolVersion;
|
this.protocolVersion = protocolVersion;
|
||||||
|
this.services = BigInteger.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
public void bitcoinSerializeToStream(OutputStream stream) throws IOException {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright 2011 Noa Resare
|
* Copyright 2011 Google Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with 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 com.google.bitcoin.bouncycastle.util.encoders.Hex;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class PeerAddressTest
|
public class PeerAddressTest
|
||||||
{
|
{
|
||||||
@Test
|
@Test
|
||||||
public void testPeerAddressSerialize() throws Exception
|
public void testPeerAddressRoundtrip() throws Exception {
|
||||||
{
|
|
||||||
// copied verbatim from https://en.bitcoin.it/wiki/Protocol_specification#Network_address
|
// copied verbatim from https://en.bitcoin.it/wiki/Protocol_specification#Network_address
|
||||||
String fromSpec = "010000000000000000000000000000000000ffff0a000001208d";
|
String fromSpec = "010000000000000000000000000000000000ffff0a000001208d";
|
||||||
PeerAddress pa = new PeerAddress(NetworkParameters.prodNet(),
|
PeerAddress pa = new PeerAddress(NetworkParameters.prodNet(),
|
||||||
@ -33,4 +34,11 @@ public class PeerAddressTest
|
|||||||
String reserialized = Utils.bytesToHexString(pa.bitcoinSerialize());
|
String reserialized = Utils.bytesToHexString(pa.bitcoinSerialize());
|
||||||
assertEquals(reserialized,fromSpec );
|
assertEquals(reserialized,fromSpec );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBitcoinSerialize() throws Exception {
|
||||||
|
PeerAddress pa = new PeerAddress(InetAddress.getByName(null), 8333, 0);
|
||||||
|
assertEquals("000000000000000000000000000000000000ffff7f000001208d",
|
||||||
|
Utils.bytesToHexString(pa.bitcoinSerialize()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user