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

Function test_addfunds_from_block

tests/test_wallet.py:235–272  ·  view source on GitHub ↗

Send funds to the daemon without telling it explicitly

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

233
234
235def test_addfunds_from_block(node_factory, bitcoind):
236 """Send funds to the daemon without telling it explicitly
237 """
238 # Previous runs with same bitcoind can leave funds!
239 coin_plugin = os.path.join(os.getcwd(), 'tests/plugins/coin_movements.py')
240 l1 = node_factory.get_node(random_hsm=True, options={'plugin': coin_plugin})
241
242 addr = l1.rpc.newaddr()['bech32']
243 bitcoind.rpc.sendtoaddress(addr, 0.1)
244 bitcoind.generate_block(1)
245
246 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) == 1)
247
248 outputs = l1.db_query('SELECT value FROM outputs WHERE status=0;')
249 assert only_one(outputs)['value'] == 10000000
250
251 # The address we detect must match what was paid to.
252 output = only_one(l1.rpc.listfunds()['outputs'])
253 assert output['address'] == addr
254
255 # Send all our money to a P2WPKH address this time.
256 addr = l1.rpc.newaddr("bech32")['bech32']
257 l1.rpc.withdraw(addr, "all")
258 bitcoind.generate_block(1)
259 sync_blockheight(bitcoind, [l1])
260
261 # The address we detect must match what was paid to.
262 output = only_one(l1.rpc.listfunds()['outputs'])
263 assert output['address'] == addr
264
265 # We don't print a 'external deposit' event
266 # for funds that come back to our own wallet
267 expected_utxos = {
268 '0': [('wallet', ['deposit'], ['withdrawal'], 'A')],
269 'A': [('wallet', ['deposit'], None, None)],
270 }
271
272 check_utxos_channel(l1, [], expected_utxos)
273
274
275def test_txprepare_multi(node_factory, bitcoind):

Callers

nothing calls this directly

Calls 11

wait_forFunction · 0.90
only_oneFunction · 0.90
sync_blockheightFunction · 0.90
check_utxos_channelFunction · 0.90
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