Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Dec 2, 2023
1 parent 7ac7613 commit 861ffa6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 11 additions & 7 deletions tests/test_mint_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/test_wallet_htlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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),
Expand Down

0 comments on commit 861ffa6

Please sign in to comment.