#![cfg(not(target_arch = "wasm32"))]
mod common;
use common::*;
use dig_urn_resolver::{ResolveOutcome, Resolver};
const PNG: &[u8] = &[
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, b'I', b'H', b'D', b'R', ];
#[tokio::test]
async fn sage_nft_image_resolves_over_rpc_with_no_node_running() {
let key = "nft/image.png";
let fx = build_fixture(key, PNG, None);
let urn = format!("urn:dig:chia:{STORE_HEX}:{}/{}", fx.root_hex, key);
let transport = MockTransport::new(
Box::new(|_url: &str| Err(transport_err())),
Box::new(move |_url: &str, body: &str| {
let req: serde_json::Value = serde_json::from_str(body).unwrap();
match req["method"].as_str().unwrap() {
"dig.getContent" => Ok(rpc_ok(get_content_result(&fx))),
other => panic!("root-pinned URN should only call dig.getContent, got {other}"),
}
}),
);
let outcome = Resolver::new(transport).resolve(&urn).await.unwrap();
let data = match outcome {
ResolveOutcome::Success(d) => d,
other => panic!("expected the image to resolve over rpc, got {other:?}"),
};
assert_eq!(data.bytes, PNG, "the exact NFT image bytes");
assert_eq!(data.content_type, "image/png");
}