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

Function main

common/test/run-amount.c:255–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

253 } while (0)
254
255int main(int argc, char *argv[])
256{
257 struct amount_msat msat;
258 struct amount_sat sat;
259
260 common_setup(argv[0]);
261
262 /* Grossly malformed */
263 FAIL_MSAT(&msat, "x");
264 FAIL_MSAT(&msat, "x100");
265
266 PASS_MSAT(&msat, "0", 0);
267 PASS_MSAT(&msat, "1", 1);
268 PASS_MSAT(&msat, "2100000000000000000", 2100000000000000000ULL);
269 FAIL_MSAT(&msat, "0.0");
270 FAIL_MSAT(&msat, "0.00000000");
271 FAIL_MSAT(&msat, "0.00000000000");
272 FAIL_MSAT(&msat, "0.00000000msat");
273 FAIL_MSAT(&msat, "-1");
274
275 PASS_MSAT(&msat, "0msat", 0);
276 PASS_MSAT(&msat, "1msat", 1);
277 PASS_MSAT(&msat, "2100000000000000000msat", 2100000000000000000ULL);
278 FAIL_MSAT(&msat, "-1msat");
279
280 PASS_MSAT(&msat, "0sat", 0);
281 PASS_MSAT(&msat, "1sat", 1000);
282 PASS_MSAT(&msat, "2100000000000000sat", 2100000000000000000ULL);
283 FAIL_MSAT(&msat, "-1sat");
284
285 PASS_MSAT(&msat, "0.00000000btc", 0);
286 PASS_MSAT(&msat, "0.00000000000btc", 0);
287 PASS_MSAT(&msat, "0.00000001btc", 1000);
288 PASS_MSAT(&msat, "0.00000000001btc", 1);
289 PASS_MSAT(&msat, "1.2btc", 120000000000);
290 PASS_MSAT(&msat, "1.23btc", 123000000000);
291 PASS_MSAT(&msat, "1.234btc", 123400000000);
292 PASS_MSAT(&msat, "1.2345btc", 123450000000);
293 PASS_MSAT(&msat, "1.23456btc", 123456000000);
294 PASS_MSAT(&msat, "1.234567btc", 123456700000);
295 PASS_MSAT(&msat, "1.2345678btc", 123456780000);
296 PASS_MSAT(&msat, "1.23456789btc", 123456789000);
297 PASS_MSAT(&msat, "1.234567890btc", 123456789000);
298 PASS_MSAT(&msat, "1.2345678901btc", 123456789010);
299 PASS_MSAT(&msat, "1.23456789012btc", 123456789012);
300 FAIL_MSAT(&msat, "1.000000000000btc");
301 FAIL_MSAT(&msat, "-1.23456789btc");
302 FAIL_MSAT(&msat, "-1.23456789012btc");
303
304 /* Overflowingly big. */
305 FAIL_MSAT(&msat, "21000000000000000000000000.00000000btc");
306
307 /* Grossly malformed */
308 FAIL_SAT(&sat, "x");
309 FAIL_SAT(&sat, "x100");
310
311 PASS_SAT(&sat, "0", 0);
312 PASS_SAT(&sat, "1", 1);

Callers

nothing calls this directly

Calls 12

common_setupFunction · 0.85
fmt_amount_m_as_satFunction · 0.85
fmt_amount_msat_btcFunction · 0.85
strendsFunction · 0.85
fmt_amount_sat_btcFunction · 0.85
test_amount_with_feeFunction · 0.85
test_amount_divFunction · 0.85
common_shutdownFunction · 0.85
parse_amount_msatFunction · 0.70
fmt_amount_msatFunction · 0.70
parse_amount_satFunction · 0.70
fmt_amount_satFunction · 0.70

Tested by

no test coverage detected