(node_factory, bitcoind)
| 3031 | @pytest.mark.openchannel('v2') |
| 3032 | @pytest.mark.developer("needs dev-disconnect, dev-no-reconnect") |
| 3033 | def test_dataloss_protection_no_broadcast(node_factory, bitcoind): |
| 3034 | # If l2 sends an old version, but *doesn't* send an error, l1 should not broadcast tx. |
| 3035 | # (https://github.com/lightning/bolts/issues/934) |
| 3036 | l1 = node_factory.get_node(may_reconnect=True, |
| 3037 | feerates=(7500, 7500, 7500, 7500), |
| 3038 | allow_warning=True, |
| 3039 | options={'dev-no-reconnect': None}) |
| 3040 | l2 = node_factory.get_node(may_reconnect=True, |
| 3041 | feerates=(7500, 7500, 7500, 7500), allow_broken_log=True, |
| 3042 | disconnect=['-WIRE_ERROR'], |
| 3043 | options={'dev-no-reconnect': None}) |
| 3044 | |
| 3045 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3046 | l1.fundchannel(l2, 10**6) |
| 3047 | l2.stop() |
| 3048 | |
| 3049 | # Save copy of the db. |
| 3050 | dbpath = os.path.join(l2.daemon.lightning_dir, TEST_NETWORK, "lightningd.sqlite3") |
| 3051 | orig_db = open(dbpath, "rb").read() |
| 3052 | l2.start() |
| 3053 | |
| 3054 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3055 | # After an htlc, we should get different results (two more commits) |
| 3056 | l1.pay(l2, 200000000) |
| 3057 | |
| 3058 | # Make sure both sides consider it completely settled (has received both |
| 3059 | # REVOKE_AND_ACK) |
| 3060 | l1.daemon.wait_for_logs(["peer_in WIRE_REVOKE_AND_ACK"] * 2) |
| 3061 | l2.daemon.wait_for_logs(["peer_in WIRE_REVOKE_AND_ACK"] * 2) |
| 3062 | |
| 3063 | # Now, move l2 back in time. |
| 3064 | l2.stop() |
| 3065 | # Save new db |
| 3066 | new_db = open(dbpath, "rb").read() |
| 3067 | # Overwrite with OLD db. |
| 3068 | open(dbpath, "wb").write(orig_db) |
| 3069 | l2.start() |
| 3070 | |
| 3071 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3072 | # l2 should freak out! |
| 3073 | l2.daemon.wait_for_logs(["Peer permanent failure in CHANNELD_NORMAL: Awaiting unilateral close"]) |
| 3074 | |
| 3075 | # l1 should NOT drop to chain, since it didn't receive an error. |
| 3076 | time.sleep(5) |
| 3077 | assert bitcoind.rpc.getrawmempool(False) == [] |
| 3078 | |
| 3079 | # fix up l2. |
| 3080 | l2.stop() |
| 3081 | open(dbpath, "wb").write(new_db) |
| 3082 | l2.start() |
| 3083 | |
| 3084 | # All is forgiven |
| 3085 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3086 | l1.pay(l2, 200000000) |
| 3087 | |
| 3088 | |
| 3089 | @pytest.mark.developer("needs dev_disconnect") |
nothing calls this directly
no test coverage detected