mirror of
https://github.com/aljazceru/nutshell.git
synced 2026-02-18 07:04:21 +01:00
Tests: split wallet test from mint test pipeline (#748)
* split wallet test from mint test pipeline * regtest mint and wallet * fix * fix * move mint tests * real invoice in regtest mpp
This commit is contained in:
@@ -3,7 +3,12 @@ import pytest
|
||||
from cashu.core.base import MintKeyset, Unit
|
||||
from cashu.core.settings import settings
|
||||
from cashu.mint.ledger import Ledger
|
||||
from tests.test_mint_init import DECRYPTON_KEY, DERIVATION_PATH, ENCRYPTED_SEED, SEED
|
||||
from tests.mint.test_mint_init import (
|
||||
DECRYPTON_KEY,
|
||||
DERIVATION_PATH,
|
||||
ENCRYPTED_SEED,
|
||||
SEED,
|
||||
)
|
||||
|
||||
|
||||
async def assert_err(f, msg):
|
||||
@@ -73,19 +78,30 @@ async def test_keyset_0_15_0_encrypted():
|
||||
)
|
||||
assert keyset.id == "009a1f293253e41e"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_keyset_rotation(ledger: Ledger):
|
||||
keyset_sat = next(filter(lambda k: k.unit == Unit["sat"] and k.active, ledger.keysets.values()))
|
||||
new_keyset_sat = await ledger.rotate_next_keyset(unit=Unit["sat"], max_order=20, input_fee_ppk=1)
|
||||
keyset_sat = next(
|
||||
filter(lambda k: k.unit == Unit["sat"] and k.active, ledger.keysets.values())
|
||||
)
|
||||
new_keyset_sat = await ledger.rotate_next_keyset(
|
||||
unit=Unit["sat"], max_order=20, input_fee_ppk=1
|
||||
)
|
||||
|
||||
keyset_sat_derivation = keyset_sat.derivation_path.split("/")
|
||||
new_keyset_sat_derivation = keyset_sat.derivation_path.split("/")
|
||||
|
||||
assert keyset_sat_derivation[:-1] == new_keyset_sat_derivation[:-1], "keyset derivation does not match up to the counter branch"
|
||||
assert int(new_keyset_sat_derivation[-1].replace("'", "")) - int(keyset_sat_derivation[-1].replace("'", "")) == 0, "counters should differ by exactly 1"
|
||||
assert (
|
||||
keyset_sat_derivation[:-1] == new_keyset_sat_derivation[:-1]
|
||||
), "keyset derivation does not match up to the counter branch"
|
||||
assert (
|
||||
int(new_keyset_sat_derivation[-1].replace("'", ""))
|
||||
- int(keyset_sat_derivation[-1].replace("'", ""))
|
||||
== 0
|
||||
), "counters should differ by exactly 1"
|
||||
|
||||
assert new_keyset_sat.input_fee_ppk == 1
|
||||
assert len(new_keyset_sat.private_keys.values()) == 20
|
||||
|
||||
old_keyset = (await ledger.crud.get_keyset(db=ledger.db, id=keyset_sat.id))[0]
|
||||
assert not old_keyset.active, "old keyset is still active"
|
||||
assert not old_keyset.active, "old keyset is still active"
|
||||
@@ -17,6 +17,7 @@ from tests.helpers import (
|
||||
assert_err,
|
||||
cancel_invoice,
|
||||
get_hold_invoice,
|
||||
get_real_invoice,
|
||||
is_fake,
|
||||
partial_pay_real_invoice,
|
||||
pay_if_regtest,
|
||||
@@ -51,7 +52,7 @@ async def test_regtest_pay_mpp(wallet: Wallet, ledger: Ledger):
|
||||
assert wallet.balance == 128
|
||||
|
||||
# this is the invoice we want to pay in two parts
|
||||
preimage, invoice_dict = get_hold_invoice(64)
|
||||
invoice_dict = get_real_invoice(64)
|
||||
invoice_payment_request = str(invoice_dict["payment_request"])
|
||||
|
||||
async def _mint_pay_mpp(invoice: str, amount: int, proofs: List[Proof]):
|
||||
@@ -116,7 +117,7 @@ async def test_regtest_pay_mpp_incomplete_payment(wallet: Wallet, ledger: Ledger
|
||||
assert wallet.balance == 384
|
||||
|
||||
# this is the invoice we want to pay in two parts
|
||||
preimage, invoice_dict = get_hold_invoice(64)
|
||||
invoice_dict = get_real_invoice(64)
|
||||
invoice_payment_request = str(invoice_dict["payment_request"])
|
||||
|
||||
async def pay_mpp(amount: int, proofs: List[Proof], delay: float = 0.0):
|
||||
Reference in New Issue
Block a user