spec/bitcoin/protocol/version_spec.rb in bitcoin-ruby-0.0.1 vs spec/bitcoin/protocol/version_spec.rb in bitcoin-ruby-0.0.2
- old
+ new
@@ -1,5 +1,7 @@
+# encoding: ascii-8bit
+
require_relative '../spec_helper.rb'
describe 'Bitcoin::Protocol::Parser (version)' do
class Version_Handler < Bitcoin::Protocol::Handler
@@ -17,11 +19,11 @@
parser.parse(pkt + "AAAA").should == "AAAA"
pkt = handler.pkt
pkt.fields.should == {
:version => 60000,
- :services => "\x01\x00\x00\x00\x00\x00\x00\x00",
+ :services => Bitcoin::Protocol::Version::NODE_NETWORK,
:time => 1329775027,
:from => "127.0.0.1:18333",
:to => "127.0.0.1:57802",
:nonce => 12576309328653329813,
:user_agent => "/bitcoin-qt:0.6.0/",
@@ -37,16 +39,16 @@
parser.parse(pkt + "AAAA").should == "AAAA"
pkt = handler.pkt
pkt.fields.should == {
:version => 40000,
- :services => "\x01\x00\x00\x00\x00\x00\x00\x00",
+ :services => Bitcoin::Protocol::Version::NODE_NETWORK,
:time => 1321812496,
:from => "127.0.0.1:18333",
:to => "127.0.0.1:1234",
:nonce => 8210299263586646091,
- :user_agent => nil,
+ :user_agent => '',
:last_block => 250
}
end
it 'creates version packets' do
@@ -61,11 +63,11 @@
parser = Bitcoin::Protocol::Parser.new( handler = Version_Handler.new )
parser.parse( version.to_pkt )
pkt = handler.pkt
pkt.fields.should == {
- :version => Bitcoin::Protocol::VERSION,
- :services => "\x01\x00\x00\x00\x00\x00\x00\x00",
+ :version => Bitcoin.network[:protocol_version],
+ :services => Bitcoin::Protocol::Version::NODE_NETWORK,
:time => 1337,
:to => "127.0.0.1:8333",
:from => "127.0.0.1:1234",
:nonce => 123,
:user_agent => "/bitcoin-ruby:#{Bitcoin::VERSION}/",