akkounts/spec/services/nostr_manager/create_zap_receipt_spec.rb
Râu Cao eae370b737
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
Migrate from lockbox to ActiveRecord encryption (1/2)
2025-05-06 18:09:27 +04:00

46 lines
1.3 KiB
Ruby

require 'rails_helper'
RSpec.describe NostrManager::CreateZapReceipt, type: :model do
let(:user) { create :user, lndhub_username: "123456abcdef" }
let(:zap) { create :zap, user: user }
# before do
# user.save!
# zap.save!
# end
subject {
described_class.call(
zap: zap, paid_at: 1673428978,
preimage: "3539663535656537343331663432653165396430623966633664656664646563"
)
}
describe "Zap receipt" do
it "is a kind:9735 note" do
expect(subject).to be_a(Nostr::Event)
expect(subject.kind).to eq(9735)
end
it "sets created_at to when the invoice was paid" do
expect(subject.created_at).to eq(1673428978)
end
it "contains the zap recipient" do
expect(subject.tags.find{|t| t[0] == "p"}[1]).to eq("07e188a1ff87ce171d517b8ed2bb7a31b1d3453a0db3b15379ec07b724d232f3")
end
it "contains the bolt11 invoice" do
expect(subject.tags.find{|t| t[0] == "bolt11"}[1]).to eq(zap.payment_request)
end
it "contains the invoice preimage" do
expect(subject.tags.find{|t| t[0] == "preimage"}[1]).to eq("3539663535656537343331663432653165396430623966633664656664646563")
end
it "contains the serialized zap request event as description" do
expect(subject.tags.find{|t| t[0] == "description"}[1]).to eq(zap.request_event.to_json)
end
end
end