Sha256: d5f29b55c8ef8a95c480ecc1384d4de4740a879c49a0a07704b15453dceec81c

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

# encoding: ascii-8bit

require_relative '../spec_helper.rb'

include Bitcoin::Protocol

describe 'TxIn' do

  describe '#initialize without specifying script_sig_length and script_sig' do
    it 'still creates a serializable TxIn' do
      prev_tx = Tx.new fixtures_file('rawtx-01.bin')
      tx_in = TxIn.new prev_tx.binary_hash, 0
      lambda { tx_in.to_payload }.should.not.raise
    end
  end

  it "should compare txins" do
    i1 = Tx.new(fixtures_file('rawtx-01.bin')).in[0]
    i1_1 = TxIn.new(i1.prev_out, i1.prev_out_index, i1.script_sig_length, i1.script_sig)
    i2 = Tx.new(fixtures_file('rawtx-02.bin')).in[0]

    (i1 == i1).should == true
    (i1 == i1_1).should == true
    (i1 == i2).should == false
    (i1 == nil).should == false
  end
  
  it "should be final only when sequence == 0xffffffff" do
    txin = TxIn.new
    txin.is_final?.should == true
    txin.sequence.should == TxIn::DEFAULT_SEQUENCE
    
    txin.sequence = "\x01\x00\x00\x00"
    txin.is_final?.should == false
    
    txin.sequence = "\x00\x00\x00\x00"
    txin.is_final?.should == false

    txin.sequence = "\xff\xff\xff\xff"
    txin.is_final?.should == true
  end
  

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
bitcoin-ruby-0.0.18 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.17 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.16 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.15 spec/bitcoin/protocol/txin_spec.rb
monacoin-ruby-0.1.3 spec/bitcoin/protocol/txin_spec.rb
monacoin-ruby-0.1.2 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.14 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.13 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.12 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.11 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.10 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.9 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.8 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.7 spec/bitcoin/protocol/txin_spec.rb
bitcoin-ruby-0.0.6 spec/bitcoin/protocol/txin_spec.rb