Limit number of relays to publish zap receipts to
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2024-05-10 13:57:25 +02:00
parent 2d1ff29eca
commit 48041630ca
4 changed files with 42 additions and 6 deletions

View File

@@ -6,11 +6,35 @@ RSpec.describe NostrManager::PublishZapReceipt, type: :model do
describe "Default/delayed execution" do
it "publishes zap receipts to all requested relays" do
2.times do
expect(NostrPublishEventJob).to receive(:perform_later).and_return(true)
end
expect(NostrPublishEventJob).to receive(:perform_later)
.exactly(2).times.and_return(true)
described_class.call(zap: zap)
end
context "with a long relay list" do
before do
relays = zap.request["tags"].find { |t| t.first == "relays" }
[
"wss://aegonstargaryen.example.com", "wss://visenya.example.com",
"wss://rhaenys.example.com", "wss://housevelaryon.example.com",
"wss://aemond.example.com", "wss://jaehaerys.example.com",
"wss://daenerys.example.com", "wss://corlys.example.com",
"wss://laenor.example.com", "wss://alysanne.example.com",
"wss://balerion.example.com", "wss://meraxes.example.com",
"wss://vhaegar.example.com", "wss://vermax.example.com",
"wss://caraxes.example.com"
].each do |url|
relays << url
end
end
it "limits publishing attempts to the first 12 relays" do
expect(NostrPublishEventJob).to receive(:perform_later)
.exactly(12).times.and_return(true)
described_class.call(zap: zap)
end
end
end
end