spec/bitcoin/protocol/tx_spec.rb in bitcoin-ruby-0.0.7 vs spec/bitcoin/protocol/tx_spec.rb in bitcoin-ruby-0.0.8

- old
+ new

@@ -57,11 +57,11 @@ new_tx = JSON.parse(tx.to_json) script = Bitcoin::Script.from_string(new_tx['in'][0]['scriptSig']) script.chunks[0].bitcoin_pushdata = Bitcoin::Script::OP_PUSHDATA2 script.chunks[0].bitcoin_pushdata_length = script.chunks[0].bytesize new_tx['in'][0]['scriptSig'] = script.to_string - new_tx = Bitcoin::P::Tx.from_hash(new_tx) + new_tx = Bitcoin::P::Tx.from_hash(new_tx, false) new_tx.hash.should != tx.hash new_tx.normalized_hash.size.should == 64 new_tx.normalized_hash.should == "393a12b91d5b5e2449f2d27a22ffc0af937c3796a08c8213cc37690b10302e40" end @@ -82,9 +82,13 @@ tx = Tx.from_hash( orig_tx.to_hash ) tx.to_payload.size.should == @payload[0].size tx.to_payload.should == @payload[0] tx.to_hash.should == orig_tx.to_hash Tx.binary_from_hash( orig_tx.to_hash ).should == @payload[0] + + h = orig_tx.to_hash.merge("ver" => 123) + -> { tx = Tx.from_hash(h) }.should.raise(Exception) + .message.should == "Tx hash mismatch! Claimed: 6e9dd16625b62cfcd4bf02edb89ca1f5a8c30c4b1601507090fb28e59f2d02b4, Actual: 395cd28c334ac84ed125ec5ccd5bc29eadcc96b79c337d0a87a19df64ea3b548" end it 'Tx.binary_from_hash' do orig_tx = Tx.new( @payload[0] ) Tx.binary_from_hash( orig_tx.to_hash ).size.should == @payload[0].size