MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_dataloss_protection

Function test_dataloss_protection

tests/test_connection.py:3058–3159  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

3056@pytest.mark.openchannel('v1')
3057@pytest.mark.openchannel('v2')
3058def test_dataloss_protection(node_factory, bitcoind):
3059 l1 = node_factory.get_node(may_reconnect=True, options={'log-level': 'io'},
3060 allow_warning=True,
3061 feerates=(7500, 7500, 7500, 7500))
3062 l2 = node_factory.get_node(may_reconnect=True, options={'log-level': 'io'},
3063 broken_log='Cannot broadcast our commitment tx: they have a future one|Unknown commitment .*, recovering our funds',
3064 feerates=(7500, 7500, 7500, 7500))
3065
3066 lf = expected_peer_features()
3067 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3068 # l1 should send out WIRE_INIT (0010)
3069 l1.daemon.wait_for_log(r"\[OUT\] 0010.*"
3070 # lflen
3071 + format(len(lf) // 2, '04x')
3072 + lf)
3073
3074 l1.fundchannel(l2, 10**6)
3075 l2.stop()
3076
3077 # Save copy of the db.
3078 dbpath = os.path.join(l2.daemon.lightning_dir, TEST_NETWORK, "lightningd.sqlite3")
3079 orig_db = Path(dbpath).read_bytes()
3080 l2.start()
3081
3082 # l1 should have sent WIRE_CHANNEL_REESTABLISH with extra fields.
3083 l1.daemon.wait_for_log(r"\[OUT\] 0088"
3084 # channel_id
3085 "[0-9a-f]{64}"
3086 # next_local_commitment_number
3087 "0000000000000001"
3088 # next_remote_revocation_number
3089 "0000000000000000"
3090 # your_last_per_commitment_secret (funding_depth may
3091 # trigger a fee-update and commit, hence this may not
3092 # be zero)
3093 "[0-9a-f]{64}"
3094 # my_current_per_commitment_point
3095 "0[23][0-9a-f]{64}")
3096
3097 # After an htlc, we should get different results (two more commits)
3098 l1.pay(l2, 200000000)
3099
3100 # Make sure both sides consider it completely settled (has received both
3101 # REVOKE_AND_ACK)
3102 l1.daemon.wait_for_logs([r"\[IN\] 0085"] * 2)
3103 l2.daemon.wait_for_logs([r"\[IN\] 0085"] * 2)
3104
3105 l2.restart()
3106
3107 # l1 should have sent WIRE_CHANNEL_REESTABLISH with extra fields.
3108 l1.daemon.wait_for_log(r"\[OUT\] 0088"
3109 # channel_id
3110 "[0-9a-f]{64}"
3111 # next_local_commitment_number
3112 "000000000000000[1-9]"
3113 # next_remote_revocation_number
3114 "000000000000000[1-9]"
3115 # your_last_per_commitment_secret

Callers

nothing calls this directly

Calls 15

expected_peer_featuresFunction · 0.90
only_oneFunction · 0.90
formatEnum · 0.85
wait_for_logMethod · 0.80
joinMethod · 0.80
wait_for_logsMethod · 0.80
restartMethod · 0.80
is_in_logMethod · 0.80
generate_blockMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected