diff --git a/tests/core/test_squeak_core.py b/tests/core/test_squeak_core.py index ac838384..2b1e19e9 100644 --- a/tests/core/test_squeak_core.py +++ b/tests/core/test_squeak_core.py @@ -41,7 +41,7 @@ from tests.utils import sha256 @pytest.fixture -def lightning_host_port(): +def external_lightning_address(): return LightningAddressHostPort(host="my_lightning_host", port=8765) @@ -106,6 +106,13 @@ def info(uris): ) +@pytest.fixture +def info_with_no_uris(): + yield Info( + uris=[], + ) + + @pytest.fixture def invoice(payment_request, price_msat, creation_date, expiry): yield Invoice( @@ -231,6 +238,11 @@ def lightning_client_with_failed_payment(info, invoice, pay_req, failed_payment) return MockLightningClient(info, invoice, pay_req, failed_payment) +@pytest.fixture +def lightning_client_with_no_uris(info_with_no_uris, invoice, pay_req, failed_payment): + return MockLightningClient(info_with_no_uris, invoice, pay_req, failed_payment) + + @pytest.fixture def squeak_core(bitcoin_client, lightning_client): yield SqueakCore(bitcoin_client, lightning_client) @@ -241,6 +253,11 @@ def squeak_core_with_failed_payment(bitcoin_client, lightning_client_with_failed yield SqueakCore(bitcoin_client, lightning_client_with_failed_payment) +@pytest.fixture +def squeak_core_with_no_uris(bitcoin_client, lightning_client_with_no_uris): + yield SqueakCore(bitcoin_client, lightning_client_with_no_uris) + + @pytest.fixture def peer_address(): yield PeerAddress( @@ -377,6 +394,33 @@ def test_packaged_offer(squeak, packaged_offer): assert packaged_offer is not None +def test_package_offer_with_no_lnd_uris( + squeak_core_with_no_uris, + created_offer, +): + packaged_offer = squeak_core_with_no_uris.package_offer( + created_offer, + None, + ) + + assert packaged_offer.host == '' + assert packaged_offer.port == 0 + + +def test_package_offer_with_no_lnd_uris_with_external_address( + squeak_core_with_no_uris, + created_offer, + external_lightning_address, +): + packaged_offer = squeak_core_with_no_uris.package_offer( + created_offer, + external_lightning_address, + ) + + assert packaged_offer.host == external_lightning_address.host + assert packaged_offer.port == external_lightning_address.port + + def test_unpacked_offer(unpacked_offer): assert unpacked_offer is not None