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

Function test_sources

plugins/currencyrate-plugin/src/oracle.rs:619–777  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

617
618#[test]
619fn test_sources() {
620 use crate::add_default_sources;
621 use serde_json::json;
622 let mut sources = Vec::new();
623 add_default_sources(&mut sources, false);
624 let mut responses = HashMap::new();
625
626 let coingecko_price = 72732f64;
627 let coingecko_response = json!({"bitcoin": {"usd": coingecko_price}});
628 responses.insert("coingecko", (coingecko_response, coingecko_price));
629
630 let kraken_price = 72745.00000;
631 let kraken_response = json!({
632 "error": [],
633 "result": {
634 "XXBTZUSD": {
635 "a": ["72745.00000", "1", "1.000"],
636 "b": ["72744.90000", "3", "3.000"],
637 "c": [kraken_price, "0.00033610"],
638 "v": ["299.69911717", "640.87872182"],
639 "p": ["73231.75442", "73435.07382"],
640 "t": [17317, 39634],
641 "l": ["72613.70000", "72613.70000"],
642 "h": ["73960.00000", "74070.00000"],
643 "o": "73569.90000",
644 }
645 },
646 });
647 responses.insert("kraken", (kraken_response, kraken_price));
648
649 let blockchain_info_price = 72749.07;
650 let blockchain_info_response = json!({
651 "ARS": {
652 "15m": 1.0250388182e8,
653 "last": 1.0250388182e8,
654 "buy": 1.0250388182e8,
655 "sell": 1.0250388182e8,
656 "symbol": "ARS",
657 },
658 "AUD": {
659 "15m": 101319.81,
660 "last": 101319.81,
661 "buy": 101319.81,
662 "sell": 101319.81,
663 "symbol": "AUD",
664 },
665 "BRL": {
666 "15m": 366724.43,
667 "last": 366724.43,
668 "buy": 366724.43,
669 "sell": 366724.43,
670 "symbol": "BRL",
671 },
672 "CAD": {
673 "15m": 100512.08,
674 "last": 100512.08,
675 "buy": 100512.08,
676 "sell": 100512.08,

Callers

nothing calls this directly

Calls 7

add_default_sourcesFunction · 0.85
reply_membersMethod · 0.80
insertMethod · 0.45
unwrapMethod · 0.45
getMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected