Skip to content

Commit

Permalink
Merge pull request #93 from Psycho-Pirate/use_stash
Browse files Browse the repository at this point in the history
fix: Modified Reestablish test to use new methods and used stash to grab values
  • Loading branch information
vincenzopalazzo authored Jun 19, 2023
2 parents 27ff761 + 6cd0791 commit e51fb97
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions tests/test_bolt2-02-reestablish.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
ExpectMsg,
Msg,
RawMsg,
KeySet,
CreateFunding,
Commit,
Runner,
Expand All @@ -24,7 +23,6 @@
CheckEq,
msat,
remote_funding_privkey,
bitfield,
negotiated,
)
from lnprototest.stash import (
Expand All @@ -36,15 +34,19 @@
funding_txid,
funding_tx,
funding,
stash_field_from_event,
)
from lnprototest.utils import (
BitcoinUtils,
run_runner,
merge_events_sequences,
utxo,
tx_spendable,
funding_amount_for_utxo,
pubkey_of,
gen_random_keyset,
)
from lnprototest.utils.ln_spec_utils import connect_to_node_helper

# FIXME: bolt9.featurebits?
# BOLT #9:
Expand All @@ -62,29 +64,14 @@

def test_reestablish(runner: Runner) -> None:
local_funding_privkey = "20"

local_keyset = KeySet(
revocation_base_secret="21",
payment_base_secret="22",
htlc_base_secret="24",
delayed_payment_base_secret="23",
shachain_seed="00" * 32,
local_keyset = gen_random_keyset(int(local_funding_privkey))
connections_events = connect_to_node_helper(
runner=runner,
tx_spendable=tx_spendable,
conn_privkey="02",
)
test = [
Block(blockheight=102, txs=[tx_spendable]),
Connect(connprivkey="02"),
ExpectMsg("init"),
TryAll(
Msg("init", globalfeatures="", features=bitfield(data_loss_protect)),
Msg("init", globalfeatures="", features=bitfield(static_remotekey)),
Msg(
"init",
globalfeatures="",
features=bitfield(static_remotekey, anchor_outputs),
),
# And nothing.
Msg("init", globalfeatures="", features=""),
),

test_events = [
Msg(
"open_channel",
chain_hash=BitcoinUtils.blockchain_hash(),
Expand Down Expand Up @@ -115,7 +102,7 @@ def test_reestablish(runner: Runner) -> None:
delayed_payment_basepoint=remote_delayed_payment_basepoint(),
htlc_basepoint=remote_htlc_basepoint(),
first_per_commitment_point=remote_per_commitment_point(0),
minimum_depth=3,
minimum_depth=stash_field_from_event("accept_channel", dummy_val=3),
channel_reserve_satoshis=9998,
),
# Create and stash Funding object and FundingTx
Expand Down Expand Up @@ -151,7 +138,13 @@ def test_reestablish(runner: Runner) -> None:
"funding_signed", channel_id=channel_id(), signature=commitsig_to_recv()
),
# Mine it and get it deep enough to confirm channel.
Block(blockheight=103, number=3, txs=[funding_tx()]),
Block(
blockheight=103,
number=stash_field_from_event(
"accept_channel", field_name="minimum_depth", dummy_val=3
),
txs=[funding_tx()],
),
ExpectMsg(
"channel_ready",
channel_id=channel_id(),
Expand Down Expand Up @@ -215,4 +208,4 @@ def test_reestablish(runner: Runner) -> None:
# the wrong info!
]

run_runner(runner, test)
run_runner(runner, merge_events_sequences(connections_events, test_events))

0 comments on commit e51fb97

Please sign in to comment.