diff --git a/src/ability/ucan/assert.rs b/src/ability/ucan/assert.rs index 62946c23..5fe7c874 100644 --- a/src/ability/ucan/assert.rs +++ b/src/ability/ucan/assert.rs @@ -1,6 +1,6 @@ use crate::ability::command::Command; use crate::task::Task; -use libipld_core::{cid::Cid, ipld::Ipld}; +use libipld_core::cid::Cid; // Things that you can assert include content and receipts @@ -8,12 +8,11 @@ use libipld_core::{cid::Cid, ipld::Ipld}; pub struct Ran { ran: Cid, out: Box>, - fx: Vec, // FIXME may be more than "just" a task + next: Vec, // FIXME may be more than "just" a task } impl Command for Ran { - const COMMAND: &'static str = "/ucan/assert/ran"; - // const COMMAND: &'static str = "/ucan/ran";???? + const COMMAND: &'static str = "/ucan/ran"; } /////////////// @@ -23,8 +22,8 @@ impl Command for Ran { #[derive(Debug, PartialEq)] pub struct Claim { claim: T, -} // Where Ipld: From +} impl Command for Claim { - const COMMAND: &'static str = "/ucan/assert/claim"; + const COMMAND: &'static str = "/ucan/claim"; } diff --git a/src/delegation/policy/selector/filter.rs b/src/delegation/policy/selector/filter.rs index 96343a5a..7e69ec8e 100644 --- a/src/delegation/policy/selector/filter.rs +++ b/src/delegation/policy/selector/filter.rs @@ -297,7 +297,7 @@ mod tests { use super::*; proptest! { - #[test] + #[test_log::test] fn test_filter_round_trip(filter: Filter) { let serialized = filter.to_string(); let deserialized = serialized.parse(); diff --git a/src/delegation/policy/selector/select.rs b/src/delegation/policy/selector/select.rs index 7506cc63..9d5270ed 100644 --- a/src/delegation/policy/selector/select.rs +++ b/src/delegation/policy/selector/select.rs @@ -1,7 +1,6 @@ -use super::Selector; // FIXME cycle? +use super::Selector; use super::{error::SelectorErrorReason, filter::Filter, Selectable, SelectorError}; use libipld_core::ipld::Ipld; -use serde::{Deserialize, Serialize}; use std::cmp::Ordering; use std::fmt; use std::str::FromStr; @@ -200,27 +199,35 @@ mod tests { use proptest::prelude::*; use testresult::TestResult; + fn simple() -> Ipld { + libipld::ipld!({ + "foo": 42, + "bar": "baz", + "qux": true + }) + } + + fn email() -> Ipld { + libipld::ipld!({ + "from": "alice@example.com", + "to": ["bob@example.com", "fraud@example.com"], + "cc": ["carol@example.com"], + "subject": "Quarterly Reports", + "body": "Here's Q2 the reports ..." + }) + } + + fn nested_data() -> Ipld { + libipld::ipld!({ + "name": "Alice", + "age": 42, + "friends": ["Bob", "Charlie"] + }) + } + mod get { use super::*; - fn nested_data() -> Ipld { - Ipld::Map( - vec![ - ("name".to_string(), Ipld::String("Alice".to_string())), - ("age".to_string(), Ipld::Integer(42)), - ( - "friends".to_string(), - Ipld::List(vec![ - Ipld::String("Bob".to_string()), - Ipld::String("Charlie".to_string()), - ]), - ), - ] - .into_iter() - .collect(), - ) - } - proptest! { #[test_log::test] fn test_identity(data: ipld::Newtype) { @@ -248,13 +255,19 @@ mod tests { let selector: Select = Select::new(filters); let cleaned_data = match data.0.clone() { - Ipld::Map(mut m) => { - m.remove("foo").map_or(Ipld::Null, |v| v) - } - ipld => ipld + Ipld::Map(mut m) => m.remove("foo").map_or(Ipld::Null, |v| v), + ipld => ipld, }; prop_assert_eq!(selector.get(&cleaned_data)?, Ipld::Null); } } + + #[test_log::test] + fn test_eq_dot_field_ending_try_null() -> TestResult { + let s = Select::from_str(".from.not?")?; + + pretty::assert_eq!(s.get(&email()), Ok(Ipld::Null)); + Ok(()) + } } }