spec/cleaner_spec.rb in txcatcher-0.2.4 vs spec/cleaner_spec.rb in txcatcher-0.2.6
- old
+ new
@@ -7,11 +7,11 @@
require_relative '../lib/txcatcher/cleaner'
RSpec.describe TxCatcher::Cleaner do
before(:each) do
- allow(TxCatcher.rpc_node).to receive(:decoderawtransaction).and_return({ "vout" => []})
+ # allow(TxCatcher.rpc_node).to receive(:decoderawtransaction).and_return({ "vout" => []})
end
it "doesn't clean anything if transaction count is below threshold" do
create_transactions(9)
clean_transactions
@@ -41,22 +41,24 @@
expect(TxCatcher::Deposit.count).to eq(10)
expect(TxCatcher::Address.count).to eq(10)
end
it "protects checked transactions" do
- protected_txs = create_transactions(3, { protected: true })
+ protected_txs = create_transactions(3, { protected: true, prefix: "protected" })
regular_txs = create_transactions(15)
clean_transactions
expect(TxCatcher::Transaction.count).to eq(12)
expect(TxCatcher::Deposit.count).to eq(12)
expect(TxCatcher::Address.count).to eq(12)
end
def create_transactions(n, attrs={})
+ prefix = attrs.delete(:prefix)
(1..n).to_a.map do |i|
d = TxCatcher::Deposit.new(address_string: "addr#{i}", amount: 0)
- tx = TxCatcher::Transaction.new(attrs)
+ tx = TxCatcher::Transaction.new(attrs.merge(hex: File.read(File.dirname(__FILE__) + "/fixtures/transaction.txt").strip))
+ tx.txid = "#{prefix}_tx#{i}"
tx.deposits << d
tx.save
tx
end
end