From 40914a72098c9ec1d15c9236f2f3193e69d2d8dc Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Sun, 23 Aug 2020 21:40:39 +0300 Subject: [PATCH] test: migrate resolving invalid list index case --- http/src/v0/refs/path.rs | 18 ------------------ src/dag.rs | 12 ++++++++++++ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/http/src/v0/refs/path.rs b/http/src/v0/refs/path.rs index 4fa4ec2f..9e25900f 100644 --- a/http/src/v0/refs/path.rs +++ b/http/src/v0/refs/path.rs @@ -72,24 +72,6 @@ mod tests { } } - #[test] - fn walk_mismatches() { - let (example_doc, _) = example_doc_and_a_cid(); - - let mismatches = [ - "bafyreielwgy762ox5ndmhx6kpi6go6il3gzahz3ngagb7xw3bj3aazeita/nested/0/more", - "bafyreielwgy762ox5ndmhx6kpi6go6il3gzahz3ngagb7xw3bj3aazeita/nested/even/-1", - "bafyreielwgy762ox5ndmhx6kpi6go6il3gzahz3ngagb7xw3bj3aazeita/nested/even/1000", - ]; - - for path in &mismatches { - let p = IpfsPath::try_from(*path).unwrap(); - // let doc_cid = p.take_root().unwrap(); - // using just unwrap_err as the context would be quite troublesome to write - walk(example_doc.clone(), &p).unwrap_err(); - } - } - fn walk(mut doc: Ipld, path: &'_ IpfsPath) -> Result<(WalkSuccess, Vec<&'_ str>), WalkFailed> { if path.iter().next().is_none() { return Ok((WalkSuccess::AtDestination(doc), path.iter().collect())); diff --git a/src/dag.rs b/src/dag.rs index 28cfeda3..b081526c 100644 --- a/src/dag.rs +++ b/src/dag.rs @@ -536,6 +536,18 @@ mod tests { super::resolve_local_ipld(example_doc, &mut p.iter().peekable()).unwrap_err(); } + #[test] + fn resolve_cbor_locally_non_usize_index() { + let (example_doc, _) = example_doc_and_cid(); + let p = IpfsPath::try_from( + "bafyreielwgy762ox5ndmhx6kpi6go6il3gzahz3ngagb7xw3bj3aazeita/nested/even/-1", + ) + .unwrap(); + + // FIXME: errors, again the number of matched + super::resolve_local_ipld(example_doc, &mut p.iter().peekable()).unwrap_err(); + } + #[tokio::test(max_threads = 1)] async fn resolve_through_link() { let Node { ipfs, bg_task: _bt } = Node::new("test_node").await;