Add test for send payment with failure (#1586)

This commit is contained in:
Jonathan Zernik 2021-10-12 19:29:21 -07:00 committed by GitHub
parent dd927036a5
commit c7fa4ec47c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,