(node_factory, bitcoind)
| 3105 | @pytest.mark.openchannel('v1') |
| 3106 | @pytest.mark.openchannel('v2') |
| 3107 | def test_dataloss_protection(node_factory, bitcoind): |
| 3108 | l1 = node_factory.get_node(may_reconnect=True, options={'log-level': 'io'}, |
| 3109 | allow_warning=True, |
| 3110 | feerates=(7500, 7500, 7500, 7500)) |
| 3111 | l2 = node_factory.get_node(may_reconnect=True, options={'log-level': 'io'}, |
| 3112 | broken_log='Cannot broadcast our commitment tx: they have a future one|Unknown commitment .*, recovering our funds', |
| 3113 | feerates=(7500, 7500, 7500, 7500)) |
| 3114 | |
| 3115 | lf = expected_peer_features() |
| 3116 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3117 | # l1 should send out WIRE_INIT (0010) |
| 3118 | l1.daemon.wait_for_log(r"\[OUT\] 0010.*" |
| 3119 | # lflen |
| 3120 | + format(len(lf) // 2, '04x') |
| 3121 | + lf) |
| 3122 | |
| 3123 | l1.fundchannel(l2, 10**6) |
| 3124 | l2.stop() |
| 3125 | |
| 3126 | # Save copy of the db. |
| 3127 | dbpath = os.path.join(l2.daemon.lightning_dir, TEST_NETWORK, "lightningd.sqlite3") |
| 3128 | orig_db = Path(dbpath).read_bytes() |
| 3129 | l2.start() |
| 3130 | |
| 3131 | # l1 should have sent WIRE_CHANNEL_REESTABLISH with extra fields. |
| 3132 | l1.daemon.wait_for_log(r"\[OUT\] 0088" |
| 3133 | # channel_id |
| 3134 | "[0-9a-f]{64}" |
| 3135 | # next_local_commitment_number |
| 3136 | "0000000000000001" |
| 3137 | # next_remote_revocation_number |
| 3138 | "0000000000000000" |
| 3139 | # your_last_per_commitment_secret (funding_depth may |
| 3140 | # trigger a fee-update and commit, hence this may not |
| 3141 | # be zero) |
| 3142 | "[0-9a-f]{64}" |
| 3143 | # my_current_per_commitment_point |
| 3144 | "0[23][0-9a-f]{64}") |
| 3145 | |
| 3146 | # After an htlc, we should get different results (two more commits) |
| 3147 | l1.pay(l2, 200000000) |
| 3148 | |
| 3149 | # Make sure both sides consider it completely settled (has received both |
| 3150 | # REVOKE_AND_ACK) |
| 3151 | l1.daemon.wait_for_logs([r"\[IN\] 0085"] * 2) |
| 3152 | l2.daemon.wait_for_logs([r"\[IN\] 0085"] * 2) |
| 3153 | |
| 3154 | l2.restart() |
| 3155 | |
| 3156 | # l1 should have sent WIRE_CHANNEL_REESTABLISH with extra fields. |
| 3157 | l1.daemon.wait_for_log(r"\[OUT\] 0088" |
| 3158 | # channel_id |
| 3159 | "[0-9a-f]{64}" |
| 3160 | # next_local_commitment_number |
| 3161 | "000000000000000[1-9]" |
| 3162 | # next_remote_revocation_number |
| 3163 | "000000000000000[1-9]" |
| 3164 | # your_last_per_commitment_secret |
nothing calls this directly
no test coverage detected