Sha256: 7fb828dcfd071521fdcc8cea0ea6270756c2357f55b2938b30c1dadbff2d817f

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

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
    TxCatcher::Transaction.select_all.delete
    transaction = TxCatcher::Transaction.new(hex: @hextx)
    transaction.valid?
    transaction.save
    expect(transaction.deposits.size).to eq(2)
    transaction.update(block_height: 1)
    expect(TxCatcher::Transaction.where(txid: transaction.txid).count).to eq(1)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
txcatcher-0.1.5 spec/models/transaction_spec.rb