Sha256: d7594b605f32392123b06a0cf0514285a31f2d86a54abe50d58c628e3654154b

Contents?: true

Size: 923 Bytes

Versions: 5

Compression:

Stored size: 923 Bytes

Contents

require_relative '../spec_helper'

RSpec.describe TxCatcher::Transaction do

  before(:each) do
    @hextx = File.read(File.dirname(__FILE__) + "/../fixtures/transaction.txt").strip
    @transaction = TxCatcher::Transaction.create(hex: @hextx)
  end

  it "parses rawtx using bitcoind" do
    expect(@transaction.txid).to eq("faf8368fec418a971e8fa94943e951490759498e0b2d3c4d5b9b12212c4f2e5a")
  end

  it "creates addresses and deposits" do
    expect(TxCatcher::Address.where(address: "323LGzCm43NgbtoYJhT6oKSwmKFTQ7AHzH").first.received).to eq(466700000)
    expect(TxCatcher::Address.where(address: "36u6xv2TvZqPPYdogzfLZpMAXrYdW4Vwjp").first.received).to eq(1332776478)
  end

  it "doesn't create duplicate deposits if valid? called manually before save" do
    transaction = TxCatcher::Transaction.new(hex: @hextx)
    transaction.valid?
    transaction.save
    expect(transaction.deposits.size).to eq(2)
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
txcatcher-0.1.4 spec/models/transaction_spec.rb
txcatcher-0.1.3 spec/models/transaction_spec.rb
txcatcher-0.1.2 spec/models/transaction_spec.rb
txcatcher-0.1.1 spec/models/transaction_spec.rb
txcatcher-0.1.0 spec/models/transaction_spec.rb