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

Function test_addfunds_from_block

tests/test_wallet.py:270–307  ·  view source on GitHub ↗

Send funds to the daemon without telling it explicitly

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

268
269@unittest.skipIf(TEST_NETWORK == 'liquid-regtest', "BIP86 random_hsm not compatible with liquid-regtest bech32")
270def test_addfunds_from_block(node_factory, bitcoind):
271 """Send funds to the daemon without telling it explicitly
272 """
273 # Previous runs with same bitcoind can leave funds!
274 coin_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
275 l1 = node_factory.get_node(random_hsm=True, options={'plugin': coin_plugin})
276
277 addr = l1.rpc.newaddr(good_addrtype())[good_addrtype()]
278 bitcoind.rpc.sendtoaddress(addr, 0.1)
279 bitcoind.generate_block(1)
280
281 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1)
282
283 outputs = l1.db_query('SELECT value FROM outputs WHERE status=0;')
284 assert only_one(outputs)['value'] == 10000000
285
286 # The address we detect must match what was paid to.
287 output = only_one(l1.rpc.listfunds()['outputs'])
288 assert output['address'] == addr
289
290 # Send all our money to a P2WPKH address this time.
291 addr = l1.rpc.newaddr("bech32")['bech32']
292 l1.rpc.withdraw(addr, "all")
293 bitcoind.generate_block(1)
294 sync_blockheight(bitcoind, [l1])
295
296 # The address we detect must match what was paid to.
297 output = only_one(l1.rpc.listfunds()['outputs'])
298 assert output['address'] == addr
299
300 # We don't print a 'external deposit' event
301 # for funds that come back to our own wallet
302 expected_utxos = {
303 '0': [('wallet', ['deposit'], ['withdrawal'], 'A')],
304 'A': [('wallet', ['deposit'], None, None)],
305 }
306
307 check_utxos_channel(l1, [], expected_utxos)
308
309
310def test_txprepare_multi(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 12

wait_forFunction · 0.90
only_oneFunction · 0.90
sync_blockheightFunction · 0.90
check_utxos_channelFunction · 0.90
good_addrtypeFunction · 0.85
joinMethod · 0.80
generate_blockMethod · 0.80
db_queryMethod · 0.80
get_nodeMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45
withdrawMethod · 0.45

Tested by

no test coverage detected