From c7fa4ec47cd24b10624c6ea21aa4a7e8255e64fd Mon Sep 17 00:00:00 2001 From: Jonathan Zernik Date: Tue, 12 Oct 2021 19:29:21 -0700 Subject: [PATCH] Add test for send payment with failure (#1586) --- tests/core/test_squeak_core.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/core/test_squeak_core.py b/tests/core/test_squeak_core.py index 12be8cc6..2882262e 100644 --- a/tests/core/test_squeak_core.py +++ b/tests/core/test_squeak_core.py @@ -226,11 +226,21 @@ def lightning_client(info, invoice, pay_req, successful_payment): return MockLightningClient(info, invoice, pay_req, successful_payment) +@pytest.fixture +def lightning_client_with_failed_payment(info, invoice, pay_req, failed_payment): + return MockLightningClient(info, invoice, pay_req, failed_payment) + + @pytest.fixture def squeak_core(bitcoin_client, lightning_client): yield SqueakCore(bitcoin_client, lightning_client) +@pytest.fixture +def squeak_core_with_failed_payment(bitcoin_client, lightning_client_with_failed_payment): + yield SqueakCore(bitcoin_client, lightning_client_with_failed_payment) + + @pytest.fixture def peer_address(): yield PeerAddress( @@ -396,6 +406,13 @@ def test_sent_payment(sent_payment): assert sent_payment is not None +def test_send_payment_with_failure(squeak_core_with_failed_payment, unpacked_offer): + + with pytest.raises(Exception) as excinfo: + squeak_core_with_failed_payment.pay_offer(unpacked_offer) + assert "Payment failed with error" in str(excinfo.value) + + def test_unlock_squeak(squeak_core, squeak, squeak_content, sent_payment): decrypted_content = squeak_core.get_decrypted_content( squeak,