From 861ffa61cf2803a24d396829faab977dae605450 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Sat, 2 Dec 2023 18:51:32 +0100 Subject: [PATCH] adjust tests --- tests/conftest.py | 2 +- tests/test_mint_operations.py | 18 +++++++++++------- tests/test_wallet_htlc.py | 8 ++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 90562137..b2c286a6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -60,7 +60,7 @@ async def start_mint_init(ledger: Ledger): await ledger.load_used_proofs() await ledger.init_keysets() - database_name = "test" + database_name = "mint" if not settings.mint_database.startswith("postgres"): # clear sqlite database diff --git a/tests/test_mint_operations.py b/tests/test_mint_operations.py index 0371f661..7bcf2ffa 100644 --- a/tests/test_mint_operations.py +++ b/tests/test_mint_operations.py @@ -75,7 +75,9 @@ async def test_split_with_input_less_than_outputs(wallet1: Wallet, ledger: Ledge pay_if_regtest(invoice.bolt11) await wallet1.mint(64, id=invoice.id) - keep_proofs, send_proofs = await wallet1.split_to_send(wallet1.proofs, 10) + keep_proofs, send_proofs = await wallet1.split_to_send( + wallet1.proofs, 10, set_reserved=False + ) all_send_proofs = send_proofs + keep_proofs @@ -93,30 +95,32 @@ async def test_split_with_input_less_than_outputs(wallet1: Wallet, ledger: Ledge ) # make sure we can still spend our tokens - keep_proofs, send_proofs = await wallet1.split_to_send(wallet1.proofs, 10) + keep_proofs, send_proofs = await wallet1.split(wallet1.proofs, 10) @pytest.mark.asyncio async def test_split_with_input_more_than_outputs(wallet1: Wallet, ledger: Ledger): - invoice = await wallet1.request_mint(12345) + invoice = await wallet1.request_mint(128) pay_if_regtest(invoice.bolt11) - await wallet1.mint(12345, id=invoice.id) + await wallet1.mint(128, id=invoice.id) inputs = wallet1.proofs # less outputs than inputs - output_amounts = [p.amount for p in inputs[:2]] + output_amounts = [8] secrets, rs, derivation_paths = await wallet1.generate_n_secrets( len(output_amounts) ) outputs, rs = wallet1._construct_outputs(output_amounts, secrets, rs) + await assert_err( ledger.split(proofs=inputs, outputs=outputs), - "inputs do not have same amount as outputs.", + "inputs do not have same amount as outputs", ) # make sure we can still spend our tokens - keep_proofs, send_proofs = await wallet1.split_to_send(wallet1.proofs, 10) + keep_proofs, send_proofs = await wallet1.split(inputs, 10) + print(keep_proofs, send_proofs) @pytest.mark.asyncio diff --git a/tests/test_wallet_htlc.py b/tests/test_wallet_htlc.py index b64557f8..0f6cbff3 100644 --- a/tests/test_wallet_htlc.py +++ b/tests/test_wallet_htlc.py @@ -191,7 +191,7 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_correct_signature( secret = await wallet1.create_htlc_lock( preimage=preimage, hashlock_pubkey=pubkey_wallet2, - locktime_seconds=5, + locktime_seconds=2, locktime_pubkey=pubkey_wallet1, ) _, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret) @@ -206,7 +206,7 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_correct_signature( "Mint Error: HTLC hash lock signatures did not match.", ) - await asyncio.sleep(5) + await asyncio.sleep(2) # should succeed since lock time has passed and we provided wallet1 signature for timelock await wallet1.redeem(send_proofs) @@ -225,7 +225,7 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_wrong_signature( secret = await wallet1.create_htlc_lock( preimage=preimage, hashlock_pubkey=pubkey_wallet2, - locktime_seconds=5, + locktime_seconds=2, locktime_pubkey=pubkey_wallet1, ) _, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret) @@ -242,7 +242,7 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_wrong_signature( "Mint Error: HTLC hash lock signatures did not match.", ) - await asyncio.sleep(5) + await asyncio.sleep(2) # should fail since lock time has passed and we provided a wrong signature for timelock await assert_err( wallet1.redeem(send_proofs),