Test out the Version message

This commit is contained in:
Nick Thomas
2011-05-19 21:40:26 +01:00
parent 7e31f3976d
commit dd2c02a206
2 changed files with 39 additions and 19 deletions

View File

@@ -231,11 +231,32 @@ describe ::BtcWireProto do
describe Message do
context "Version message" do
it "should have a Version payload" do
m = Message::new
puts m.inspect
puts m.header.inspect
m.header.command = "version"
v.payload.class.should == Version
m = Message::new(:header => {:command => 'version'})
m.payload.selection.should == "version"
end
it "should parse binary data correctly" do
m = Message::read(binary(%w{
F9 BE B4 D9 76 65 72 73 69 6F 6E 00 00 00 00 00 55 00 00
00 9C 7C 00 00 01 00 00 00 00 00 00 00 E6 15 10 4D 00 00
00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 FF FF 0A 00 00 01 DA F6 01 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 FF FF 0A 00 00 02 20 8D DD 9D 20
2C 3A B4 57 13 00 55 81 01 00
}))
m.header.magic.should == BtcWireProto::NETWORKS[:main]
m.header.command.should == "version\x00\x00\x00\x00\x00"
m.header.payload_len.should == 85
m.header.has_parameter?(:checksum).should be_false
m.payload.version.should == 31900
m.payload.services.node_network.should == 1
m.payload.timestamp.should == 1292899814
m.payload.addr_me.class.should == NetAddr
m.payload.addr_you.class.should == NetAddr
m.payload.nonce.should == 0x1357B43A2C209DDD
m.payload.sub_version.should == ""
m.payload.start_height.should == 98645
end
end
end