diff --git a/tests/test_mint_api.py b/tests/test_mint_api.py index 0ca822e8..6ea54fb0 100644 --- a/tests/test_mint_api.py +++ b/tests/test_mint_api.py @@ -6,7 +6,7 @@ from cashu.core.base import CheckSpendableRequest, CheckSpendableResponse, Proof from cashu.mint.ledger import Ledger from cashu.wallet.wallet import Wallet -from tests.helpers import pay_if_regtest +from tests.helpers import get_real_invoice, is_regtest, pay_if_regtest BASE_URL = "http://localhost:3337" @@ -201,9 +201,16 @@ async def test_melt(ledger: Ledger, wallet: Wallet): assert wallet.balance == 64 # create invoice to melt to - # we melt 2 satoshis less because of the fee reserve + # use 2 sat less because we need to pay the fee invoice = await wallet.request_mint(62) - quote = await wallet.melt_quote(invoice.bolt11) + + invoice_payment_request = invoice.bolt11 + if is_regtest: + invoice_dict = get_real_invoice(62) + invoice_payment_request = invoice_dict["payment_request"] + str(invoice_dict["r_hash"]) + + quote = await wallet.melt_quote(invoice_payment_request) inputs_payload = [p.to_dict() for p in wallet.proofs] # outputs for change diff --git a/tests/test_mint_operations.py b/tests/test_mint_operations.py index 78dfd062..e02eea6e 100644 --- a/tests/test_mint_operations.py +++ b/tests/test_mint_operations.py @@ -6,7 +6,7 @@ from cashu.wallet.wallet import Wallet from cashu.wallet.wallet import Wallet as Wallet1 from tests.conftest import SERVER_ENDPOINT -from tests.helpers import pay_if_regtest +from tests.helpers import get_real_invoice, is_regtest, pay_if_regtest @pytest_asyncio.fixture(scope="function") @@ -29,14 +29,18 @@ async def test_melt(wallet1: Wallet, ledger: Ledger): invoice = await wallet1.request_mint(64) pay_if_regtest(invoice.bolt11) await wallet1.mint(64, id=invoice.id) + invoice_payment_request = invoice.bolt11 + if is_regtest: + invoice_dict = get_real_invoice(64) + invoice_payment_request = invoice_dict["payment_request"] + str(invoice_dict["r_hash"]) + assert wallet1.balance == 128 - mint_quote = await wallet1.get_pay_amount_with_fees(invoice.bolt11) - # mint_fees = await ledger._get_lightning_fees(invoice.bolt11) - # assert mint_fees == mint_quote.fee_reserve + mint_quote = await wallet1.get_pay_amount_with_fees(invoice_payment_request) total_amount = mint_quote.amount + mint_quote.fee_reserve keep_proofs, send_proofs = await wallet1.split_to_send(wallet1.proofs, total_amount) melt_quote = await ledger.melt_quote( - PostMeltQuoteRequest(request=invoice.bolt11, unit="sat") + PostMeltQuoteRequest(request=invoice_payment_request, unit="sat") ) await ledger.melt(proofs=send_proofs, quote=melt_quote.quote)