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

Function test_bwatch_same_owner_adds_twice

tests/test_plugin.py:5166–5190  ·  view source on GitHub ↗

Test that the same owner adding the same watch twice is idempotent

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

5164
5165
5166def test_bwatch_same_owner_adds_twice(node_factory, bitcoind):
5167 """Test that the same owner adding the same watch twice is idempotent"""
5168 l1 = node_factory.get_node(options=BWATCH_OPTS)
5169
5170 test_txid = "6" * 64
5171 test_outpoint = f"{test_txid}:0"
5172
5173 # Add watch with start_block 100
5174 l1.rpc.addoutpointwatch(owner='wallet/p2wpkh/0', outpoint=test_outpoint, start_block=100)
5175
5176 # Add same watch again with different start_block
5177 l1.rpc.addoutpointwatch(owner='wallet/p2wpkh/0', outpoint=test_outpoint, start_block=200)
5178
5179 # Should log that owner already exists
5180 l1.daemon.wait_for_log(r'Owner wallet/p2wpkh/0 already watching')
5181
5182 # Should still be just one datastore entry
5183 ds = l1.rpc.listdatastore(['bwatch', 'outpoint'])
5184 assert sum(1 for d in ds['datastore'] if d['key'] == ['bwatch', 'outpoint', test_outpoint]) == 1
5185
5186 # Removing once should delete the watch (only one owner, not two)
5187 l1.rpc.deloutpointwatch(owner='wallet/p2wpkh/0', outpoint=test_outpoint)
5188
5189 ds = l1.rpc.listdatastore(['bwatch', 'outpoint'])
5190 assert not any(d['key'] == ['bwatch', 'outpoint', test_outpoint] for d in ds['datastore'])
5191
5192
5193def test_bwatch_remove_one_owner_keeps_watch(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 4

wait_for_logMethod · 0.80
listdatastoreMethod · 0.80
anyClass · 0.50
get_nodeMethod · 0.45

Tested by

no test coverage detected