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

Function test_waitblockheight

tests/test_misc.py:2869–2907  ·  view source on GitHub ↗
(node_factory, executor, bitcoind)

Source from the content-addressed store, hash-verified

2867
2868
2869def test_waitblockheight(node_factory, executor, bitcoind):
2870 node = node_factory.get_node()
2871
2872 sync_blockheight(bitcoind, [node])
2873
2874 blockheight = node.rpc.getinfo()['blockheight']
2875
2876 # Should succeed without waiting.
2877 node.rpc.waitblockheight(blockheight - 2)
2878 node.rpc.waitblockheight(blockheight - 1)
2879 node.rpc.waitblockheight(blockheight)
2880
2881 # Developer mode polls bitcoind every second, so 60 seconds is plenty.
2882 time = 60
2883
2884 # Should not succeed yet.
2885 fut2 = executor.submit(node.rpc.waitblockheight, blockheight + 2, time)
2886 fut1 = executor.submit(node.rpc.waitblockheight, blockheight + 1, time)
2887 assert not fut1.done()
2888 assert not fut2.done()
2889
2890 # Should take about ~1second and time out.
2891 with pytest.raises(RpcError):
2892 node.rpc.waitblockheight(blockheight + 2, 1)
2893
2894 # Others should still not be done.
2895 assert not fut1.done()
2896 assert not fut2.done()
2897
2898 # Trigger just one more block.
2899 bitcoind.generate_block(1)
2900 sync_blockheight(bitcoind, [node])
2901 fut1.result(5)
2902 assert not fut2.done()
2903
2904 # Trigger two blocks.
2905 bitcoind.generate_block(1)
2906 sync_blockheight(bitcoind, [node])
2907 fut2.result(5)
2908
2909
2910def test_sendcustommsg(node_factory):

Callers

nothing calls this directly

Calls 5

sync_blockheightFunction · 0.90
waitblockheightMethod · 0.80
generate_blockMethod · 0.80
get_nodeMethod · 0.45
getinfoMethod · 0.45

Tested by

no test coverage detected