Sha256: c8c0da3936b8fab9cf59465946621d3e4ffd921964e1676e33b42cda8cbd5f3d
Contents?: true
Size: 1.5 KB
Versions: 33
Compression:
Stored size: 1.5 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 it "updates block height by making manual requests to RPC and searching if tx is included in one of the previous blocks" do expect(TxCatcher.rpc_node).to receive(:getblockhash).and_return("blockhash123") expect(TxCatcher.rpc_node).to receive(:getblock).and_return({ "height" => "123", "tx" => [@transaction.txid], "hash" => "blockhash123"}) @transaction.update_block_height! expect(@transaction.block_height).to eq(123) end end
Version data entries
33 entries across 33 versions & 1 rubygems