1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
pub use ipfs_unixfs as ll;
mod cat;
pub use cat::{cat, StartingPoint, TraversalFailed};
#[cfg(test)]
mod tests {
#[test]
fn test_file_cid() {
let content = "\u{8}\u{2}\u{12}\u{12}Here is some data\n\u{18}\u{12}";
let mut adder = ipfs_unixfs::file::adder::FileAdder::default();
let (mut blocks, consumed) = adder.push(content.as_bytes());
assert_eq!(consumed, content.len(), "should had consumed all content");
assert_eq!(
blocks.next(),
None,
"should not had produced any blocks yet"
);
let mut blocks = adder.finish();
let (cid, _block) = blocks.next().unwrap();
assert_eq!(blocks.next(), None, "should had been the last");
assert_eq!(
"QmQZE72h2Vdm3F5gWr9RLuzSw3rUJEkKedWEa8t8XVygT5",
cid.to_string(),
"matches cid from go-ipfs 0.6.0"
);
}
}