tests: lnhelpers: (trivial) mark method private, add type hints
What changed, and why it matters
This commit only touches test helper files. It renames a helper function to start with an underscore (a Python convention for 'private'), adds a couple of type hints, and adds blank lines. There is no change to production wallet code, no bug fix, and no security relevance.
No action needed; this is a trivial test-only refactoring change with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
Diff modifies tests/lnhelpers.py and tests/test_lnchannel.py. In lnhelpers.py, create_channel_state is renamed to _create_channel_state and its two call sites are updated; _create_mock_lnwallet gains type hints on the ‘name’ and ‘has_anchors’ parameters; blank lines are added. In test_lnchannel.py, force_state_transition gains type hints for its parameters and return type. These are purely cosmetic/test-code quality changes.
Changed components
tests/lnhelpers.pytests/test_lnchannel.pyInspect captured patch +7 / −5
diff --git a/tests/lnhelpers.py b/tests/lnhelpers.py
index e46c853..3e8ce3d 100644
--- a/tests/lnhelpers.py
+++ b/tests/lnhelpers.py
@@ -105,7 +105,8 @@ class MockStandardWallet(Standard_Wallet):
assert passphrase
return passphrase # lol, super secure name
-def _create_mock_lnwallet(*, name, has_anchors, data_dir: str) -> 'MockLNWallet':
+
+def _create_mock_lnwallet(*, name: str, has_anchors: bool, data_dir: str) -> 'MockLNWallet':
config = SimpleConfig({}, read_user_dir_function=lambda: data_dir)
config.TEST_LN_OPEN_SRK_CHANNELS = not has_anchors
config.INITIAL_TRAMPOLINE_FEE_LEVEL = 0
@@ -125,6 +126,7 @@ def _create_mock_lnwallet(*, name, has_anchors, data_dir: str) -> 'MockLNWallet'
lnworker.logger.info(f"created LNWallet[{name}] with nodeID={lnworker.node_keypair.pubkey.hex()}")
return lnworker
+
class MockLNWallet(LNWallet):
MPP_EXPIRY = 2 # HTLC timestamps are cast to int, so this cannot be 1
TIMEOUT_SHUTDOWN_FAIL_PENDING_HTLCS = 0
@@ -353,7 +355,7 @@ def _convert_to_rconfig_from_lconfig(lconfig: LocalConfig) -> RemoteConfig:
return rconfig
-def create_channel_state(
+def _create_channel_state(
*,
funding_txid: str,
funding_index: int,
@@ -460,7 +462,7 @@ def create_test_channels(
alice, bob = (
lnchannel.Channel(
- create_channel_state(
+ _create_channel_state(
funding_txid=funding_txid,
funding_index=funding_index,
funding_sat=funding_sat,
@@ -475,7 +477,7 @@ def create_test_channels(
lnworker=alice_lnwallet,
),
lnchannel.Channel(
- create_channel_state(
+ _create_channel_state(
funding_txid=funding_txid,
funding_index=funding_index,
funding_sat=funding_sat,
diff --git a/tests/test_lnchannel.py b/tests/test_lnchannel.py
index c7a15f3..9eedcd5 100644
--- a/tests/test_lnchannel.py
+++ b/tests/test_lnchannel.py
@@ -1014,7 +1014,7 @@ class TestDustNoAnchors(TestDust):
TEST_ANCHOR_CHANNELS = False
-def force_state_transition(chanA, chanB):
+def force_state_transition(chanA: Channel, chanB: Channel) -> None:
chanB.receive_new_commitment(*chanA.sign_next_commitment())
rev = chanB.revoke_current_commitment()
bob_sig, bob_htlc_sigs = chanB.sign_next_commitment()
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.