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

Function test_apis_batch2

tests/test_currencyrate.py:94–135  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

92
93
94def test_apis_batch2(node_factory):
95 opts = {
96 "currencyrate-disable-source": [
97 "coingecko",
98 "kraken",
99 "blockchain.info",
100 "coindesk",
101 "binance",
102 ],
103 }
104 l1 = node_factory.get_node(options=opts)
105
106 rateslist = l1.rpc.call("listcurrencyrates", ["USD"])['currencyrates']
107 LOGGER.info(rateslist)
108 rates = {entry["source"]: entry["amount"] for entry in rateslist}
109
110 assert "bitstamp" in rates
111 assert "coinbase" in rates
112
113 assert "coingecko" not in rates
114 assert "kraken" not in rates
115 assert "blockchain.info" not in rates
116 assert "coindesk" not in rates
117 assert "binance" not in rates
118
119 assert rates["bitstamp"] > 0
120 assert rates["coinbase"] > 0
121
122 rates = [
123 rates["bitstamp"],
124 rates["coinbase"],
125 ]
126 rates.sort()
127
128 convert = l1.rpc.call("currencyconvert", [100, "USD"])
129 LOGGER.info(convert)
130
131 assert "msat" in convert
132 assert convert["msat"] > 0
133 assert convert["msat"] in median_conversion(100, rateslist)
134
135 assert int(l1.rpc.currencyrate("USD")['rate']) in median_rate(rateslist)
136
137
138def test_custom_source(node_factory):

Callers

nothing calls this directly

Calls 5

median_conversionFunction · 0.85
median_rateFunction · 0.85
sortMethod · 0.80
get_nodeMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected