Skip to content

Commit 24bc7b0

Browse files
authored
Test coverage for bundlr manifest + filename use case (#4865)
1 parent 385fd3f commit 24bc7b0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

graph/src/components/link_resolver.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,35 @@ pub enum ArweaveClientError {
141141
#[error("Unknown error")]
142142
Unknown(#[from] reqwest::Error),
143143
}
144+
145+
#[cfg(test)]
146+
mod test {
147+
use serde_derive::Deserialize;
148+
149+
use crate::{
150+
components::link_resolver::{ArweaveClient, ArweaveResolver},
151+
data_source::offchain::Base64,
152+
};
153+
154+
// This test ensures that passing txid/filename works when the txid refers to manifest.
155+
// the actual data seems to have some binary header and footer so these ranges were found
156+
// by inspecting the data with hexdump.
157+
#[tokio::test]
158+
async fn fetch_bundler_url() {
159+
let url = Base64::from("Rtdn3QWEzM88MPC2dpWyV5waO7Vuz3VwPl_usS2WoHM/DriveManifest.json");
160+
#[derive(Deserialize, Debug, PartialEq)]
161+
struct Manifest {
162+
pub manifest: String,
163+
}
164+
165+
let client = ArweaveClient::default();
166+
let no_header = &client.get(&url).await.unwrap()[1295..320078];
167+
let content: Manifest = serde_json::from_slice(no_header).unwrap();
168+
assert_eq!(
169+
content,
170+
Manifest {
171+
manifest: "arweave/paths".to_string(),
172+
}
173+
);
174+
}
175+
}

0 commit comments

Comments
 (0)