saifi009 / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
0 stars 0 forks source link

BitcoinSerializerTest.testVersion unit test fails if Message.SELF_CHECK enabled #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If I set the Message.SELF_CHECK flag to true then the 
BitcoinSerializerTest.testVersion unit test fails with the following message:

Serialization is wrong: 
000000000000000000000000000000000000ffff0a000001f6da vs 
010000000000000000000000000000000000ffff0a000001daf6

It looks like there are two issues:
1. Zero is always written instead of the services field value.
2. The upper and lower port bytes are written in the opposite order to the way 
they're read.

Original issue reported on code.google.com by nathan.baulch on 14 Jun 2011 at 5:11

GoogleCodeExporter commented 9 years ago
Thank you for the report. The PeerAddress roundtrip serialization is indeed 
broken. The attached patch contains a test case that doesn't rely on SELF_CHECK 
being set, as well as fixing the actual problem.

Original comment by noa.res...@gmail.com on 21 Jun 2011 at 12:34

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r101.

Original comment by hearn@google.com on 24 Jun 2011 at 1:03

GoogleCodeExporter commented 9 years ago
It doesn't look like the PeerAddress.services variable is every initialized, 
which causes an NPE on connection:
java.lang.NullPointerException
    at com.google.bitcoin.core.Utils.uint64ToByteStreamLE(Unknown Source)
    at com.google.bitcoin.core.PeerAddress.bitcoinSerializeToStream(Unknown Source)
    at com.google.bitcoin.core.VersionMessage.bitcoinSerializeToStream(Unknown Source)
    at com.google.bitcoin.core.Message.bitcoinSerialize(Unknown Source)
    at com.google.bitcoin.core.BitcoinSerializer.serialize(Unknown Source)
    at com.google.bitcoin.core.NetworkConnection.writeMessage(Unknown Source)
    at com.google.bitcoin.core.NetworkConnection.<init>(Unknown Source)

Original comment by stuh...@gmail.com on 25 Jun 2011 at 8:55

GoogleCodeExporter commented 9 years ago
Sorry about that. The attached patch adds a testcase for serializing a 
PeerAddress constructed without parsing, and a fix to the problem.

Original comment by noa.res...@gmail.com on 25 Jun 2011 at 3:57

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, this fixes the issue.

Original comment by stuh...@gmail.com on 26 Jun 2011 at 7:37

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r103.

Original comment by hearn@google.com on 27 Jun 2011 at 11:25

GoogleCodeExporter commented 9 years ago
I checked in a modified version of the patch to not rely on the localhost 
address (which is not the same as the loopback address).

Original comment by hearn@google.com on 27 Jun 2011 at 11:26