Tests: mint operations (#328)

* mint operations

* fix spelling

* add pending test

* fix tag

* make htlc tests less likelyto fail
This commit is contained in:
callebtc
2023-09-24 18:54:49 +02:00
committed by GitHub
parent 638324940a
commit 2d3a9234f5
6 changed files with 90 additions and 19 deletions

View File

@@ -99,7 +99,7 @@ async def test_htlc_redeem_with_wrong_preimage(wallet1: Wallet, wallet2: Wallet)
await wallet1.mint(64, hash=invoice.hash)
preimage = "00000000000000000000000000000000"
# preimage_hash = hashlib.sha256(bytes.fromhex(preimage)).hexdigest()
secret = await wallet1.create_htlc_lock(preimage=preimage[:-1] + "1")
secret = await wallet1.create_htlc_lock(preimage=preimage[:-5] + "11111")
# p2pk test
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
for p in send_proofs:
@@ -117,7 +117,7 @@ async def test_htlc_redeem_with_no_signature(wallet1: Wallet, wallet2: Wallet):
pubkey_wallet1 = await wallet1.create_p2pk_pubkey()
# preimage_hash = hashlib.sha256(bytes.fromhex(preimage)).hexdigest()
secret = await wallet1.create_htlc_lock(
preimage=preimage, hacklock_pubkey=pubkey_wallet1
preimage=preimage, hashlock_pubkey=pubkey_wallet1
)
# p2pk test
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
@@ -137,15 +137,15 @@ async def test_htlc_redeem_with_wrong_signature(wallet1: Wallet, wallet2: Wallet
pubkey_wallet1 = await wallet1.create_p2pk_pubkey()
# preimage_hash = hashlib.sha256(bytes.fromhex(preimage)).hexdigest()
secret = await wallet1.create_htlc_lock(
preimage=preimage, hacklock_pubkey=pubkey_wallet1
preimage=preimage, hashlock_pubkey=pubkey_wallet1
)
# p2pk test
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
signatures = await wallet1.sign_p2pk_proofs(send_proofs)
for p, s in zip(send_proofs, signatures):
p.htlcpreimage = preimage
p.htlcsignature = s[:-1] + "1" # wrong signature
p.htlcsignature = s[:-5] + "11111" # wrong signature
await assert_err(
wallet2.redeem(send_proofs),
@@ -161,7 +161,7 @@ async def test_htlc_redeem_with_correct_signature(wallet1: Wallet, wallet2: Wall
pubkey_wallet1 = await wallet1.create_p2pk_pubkey()
# preimage_hash = hashlib.sha256(bytes.fromhex(preimage)).hexdigest()
secret = await wallet1.create_htlc_lock(
preimage=preimage, hacklock_pubkey=pubkey_wallet1
preimage=preimage, hashlock_pubkey=pubkey_wallet1
)
# p2pk test
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, 8, secret_lock=secret)
@@ -186,7 +186,7 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_correct_signature(
# preimage_hash = hashlib.sha256(bytes.fromhex(preimage)).hexdigest()
secret = await wallet1.create_htlc_lock(
preimage=preimage,
hacklock_pubkey=pubkey_wallet2,
hashlock_pubkey=pubkey_wallet2,
locktime_seconds=5,
locktime_pubkey=pubkey_wallet1,
)
@@ -221,7 +221,7 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_wrong_signature(
# preimage_hash = hashlib.sha256(bytes.fromhex(preimage)).hexdigest()
secret = await wallet1.create_htlc_lock(
preimage=preimage,
hacklock_pubkey=pubkey_wallet2,
hashlock_pubkey=pubkey_wallet2,
locktime_seconds=5,
locktime_pubkey=pubkey_wallet1,
)
@@ -231,7 +231,7 @@ async def test_htlc_redeem_hashlock_wrong_signature_timelock_wrong_signature(
signatures = await wallet1.sign_p2pk_proofs(send_proofs)
for p, s in zip(send_proofs, signatures):
p.htlcpreimage = preimage
p.htlcsignature = s[:-1] + "1" # wrong signature
p.htlcsignature = s[:-5] + "11111" # wrong signature
# should error because we used wallet2 signatures for the hash lock
await assert_err(