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

Function test_bcli

tests/test_plugin.py:2193–2237  ·  view source on GitHub ↗

This tests the bcli plugin, used to gather Bitcoin data from a local bitcoind. Mostly sanity checks of the interface..

(node_factory, bitcoind, chainparams)

Source from the content-addressed store, hash-verified

2191
2192
2193def test_bcli(node_factory, bitcoind, chainparams):
2194 """
2195 This tests the bcli plugin, used to gather Bitcoin data from a local
2196 bitcoind.
2197 Mostly sanity checks of the interface..
2198 """
2199 l1, l2 = node_factory.get_nodes(2)
2200
2201 # We cant stop it dynamically
2202 with pytest.raises(RpcError):
2203 l1.rpc.plugin_stop("bcli")
2204
2205 # Failure case of feerate is tested in test_misc.py
2206 estimates = l1.rpc.call("estimatefees")
2207 assert 'feerate_floor' in estimates
2208 assert [f['blocks'] for f in estimates['feerates']] == [2, 6, 12, 100]
2209
2210 resp = l1.rpc.call("getchaininfo", {"last_height": 0})
2211 assert resp["chain"] == chainparams['name']
2212 for field in ["headercount", "blockcount", "ibd"]:
2213 assert field in resp
2214
2215 # We shouldn't get upset if we ask for an unknown-yet block
2216 resp = l1.rpc.call("getrawblockbyheight", {"height": 500})
2217 assert resp["blockhash"] is resp["block"] is None
2218 resp = l1.rpc.call("getrawblockbyheight", {"height": 50})
2219 assert resp["blockhash"] is not None and resp["blockhash"] is not None
2220 # Some other bitcoind-failure cases for this call are covered in
2221 # tests/test_misc.py
2222
2223 l1.fundwallet(10**5)
2224 l1.connect(l2)
2225 fc = l1.rpc.fundchannel(l2.info["id"], 10**4 * 3)
2226 txo = l1.rpc.call("getutxout", {"txid": fc['txid'], "vout": fc['outnum']})
2227 assert (Millisatoshi(txo["amount"]) == Millisatoshi(10**4 * 3 * 10**3)
2228 and txo["script"].startswith("0020"))
2229 l1.rpc.close(l2.info["id"])
2230 # When output is spent, it should give us null !
2231 wait_for(lambda: l1.rpc.call("getutxout", {
2232 "txid": fc['txid'],
2233 "vout": fc['outnum']
2234 })['amount'] is None)
2235
2236 resp = l1.rpc.call("sendrawtransaction", {"tx": "dummy", "allowhighfees": False})
2237 assert not resp["success"] and "decode failed" in resp["errmsg"]
2238
2239
2240def test_bcli_concurrent(node_factory, bitcoind, executor):

Callers

nothing calls this directly

Calls 9

MillisatoshiClass · 0.90
wait_forFunction · 0.90
get_nodesMethod · 0.80
plugin_stopMethod · 0.80
fundwalletMethod · 0.80
callMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected