(node_factory, bitcoind)
| 3163 | @pytest.mark.openchannel('v1') |
| 3164 | @pytest.mark.openchannel('v2') |
| 3165 | def test_dataloss_protection_no_broadcast(node_factory, bitcoind): |
| 3166 | # If l2 sends an old version, but *doesn't* send an error, l1 should not broadcast tx. |
| 3167 | # (https://github.com/lightning/bolts/issues/934) |
| 3168 | l1 = node_factory.get_node(may_reconnect=True, |
| 3169 | feerates=(7500, 7500, 7500, 7500), |
| 3170 | allow_warning=True, |
| 3171 | options={'dev-no-reconnect': None}) |
| 3172 | l2 = node_factory.get_node(may_reconnect=True, |
| 3173 | feerates=(7500, 7500, 7500, 7500), |
| 3174 | broken_log='Cannot broadcast our commitment tx: they have a future one', |
| 3175 | disconnect=['-WIRE_ERROR'], |
| 3176 | options={'dev-no-reconnect': None}) |
| 3177 | |
| 3178 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3179 | l1.fundchannel(l2, 10**6) |
| 3180 | l2.stop() |
| 3181 | |
| 3182 | # Save copy of the db. |
| 3183 | dbpath = os.path.join(l2.daemon.lightning_dir, TEST_NETWORK, "lightningd.sqlite3") |
| 3184 | orig_db = Path(dbpath).read_bytes() |
| 3185 | l2.start() |
| 3186 | |
| 3187 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3188 | # After an htlc, we should get different results (two more commits) |
| 3189 | l1.pay(l2, 200000000) |
| 3190 | |
| 3191 | # Make sure both sides consider it completely settled (has received both |
| 3192 | # REVOKE_AND_ACK) |
| 3193 | l1.daemon.wait_for_logs(["peer_in WIRE_REVOKE_AND_ACK"] * 2) |
| 3194 | l2.daemon.wait_for_logs(["peer_in WIRE_REVOKE_AND_ACK"] * 2) |
| 3195 | |
| 3196 | # Now, move l2 back in time. |
| 3197 | l2.stop() |
| 3198 | # Save new db |
| 3199 | new_db = Path(dbpath).read_bytes() |
| 3200 | # Overwrite with OLD db. |
| 3201 | Path(dbpath).write_bytes(orig_db) |
| 3202 | l2.start() |
| 3203 | |
| 3204 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3205 | # l2 should freak out! But fail when trying to send error |
| 3206 | l2.daemon.wait_for_logs(["Peer permanent failure in CHANNELD_NORMAL:.* Awaiting unilateral close", |
| 3207 | 'dev_disconnect: -WIRE_ERROR']) |
| 3208 | |
| 3209 | # l1 should NOT drop to chain, since it didn't receive an error. |
| 3210 | time.sleep(5) |
| 3211 | assert bitcoind.rpc.getrawmempool(False) == [] |
| 3212 | |
| 3213 | # fix up l2. |
| 3214 | l2.stop() |
| 3215 | Path(dbpath).write_bytes(new_db) |
| 3216 | l2.start() |
| 3217 | |
| 3218 | # All is forgiven |
| 3219 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3220 | l1.pay(l2, 200000000) |
| 3221 | |
| 3222 |
nothing calls this directly
no test coverage detected