Sha256: d505c3a34727dbf6d4e9d5e2448f4b348618ff8e34351e88c09573f0a3b3d5e8

Contents?: true

Size: 909 Bytes

Versions: 4

Compression:

Stored size: 909 Bytes

Contents

# encoding: ascii-8bit

require_relative '../spec_helper.rb'

include Bitcoin::Protocol

describe 'TxOut' do

  it '#initialize without specifying script_sig_length' do
    key = Bitcoin::Key.generate
    tx_out = TxOut.new(12345, Bitcoin::Script.from_string("OP_DUP OP_HASH160 #{key.hash160} OP_EQUALVERIFY OP_CHECKSIG").to_payload)
    lambda { tx_out.to_payload }.should.not.raise
  end

  it "should compare txouts" do
    o1 = Tx.new(fixtures_file('rawtx-01.bin')).out[0]
    o1_1 = TxOut.new(o1.value, o1.pk_script)
    o2 = Tx.new(fixtures_file('rawtx-02.bin')).out[0]

    (o1 == o1).should == true
    (o1 == o1_1).should == true
    (o1 == o2).should == false
    (o1 == nil).should == false
  end

  it "should update parsed script cache on script change" do
    out = TxOut.new(123, "abc")
    parsed = out.parsed_script
    out.pk_script = "def"
    out.parsed_script.should != parsed
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bitcoin-ruby-0.0.18 spec/bitcoin/protocol/txout_spec.rb
bitcoin-ruby-0.0.17 spec/bitcoin/protocol/txout_spec.rb
bitcoin-ruby-0.0.16 spec/bitcoin/protocol/txout_spec.rb
bitcoin-ruby-0.0.15 spec/bitcoin/protocol/txout_spec.rb