New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test delegation store #12
Conversation
> where | ||
Ipld: Encode<C>, | ||
Payload<DID>: TryFrom<Named<Ipld>>, | ||
Named<Ipld>: From<Payload<DID>>, | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change in the above file using to_ipld_envelope
was way more subtle than it should have been. basically previously the payload types individually implemented libipld::Encode<C>
, but that was (evidently) confusing. It took longer than I'd like to admit to find the bug it caused.
@@ -46,9 +46,9 @@ impl<T> Select<T> { | |||
|
|||
impl<T: Selectable> Select<T> { | |||
pub fn get(self, ctx: &Ipld) -> Result<T, SelectorError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Try
behaviour in this method could probably be more elegant, but I really don't want to have to write more custom Try
(AKA .?
) parsing 😅
@@ -160,7 +160,7 @@ impl< | |||
where | |||
Named<Ipld>: From<delegation::Payload<DID>>, | |||
delegation::Payload<DID>: TryFrom<Named<Ipld>>, | |||
Delegation<DID, V, Enc>: Encode<Enc>, | |||
Ipld: Encode<Enc>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted in an Issue comment above
@@ -173,7 +173,7 @@ where | |||
// FIXME | |||
} | |||
|
|||
fn insert( | |||
fn insert_keyed( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lets us automagically calculate the CID on insert
, but let the trait implementer work with the lower level interface rather than forcing them to figure out the CID stuff themselves.
for delegate_pred in delegation.payload.policy.iter() { | ||
let comparison = | ||
target_pred.harmonize(delegate_pred, vec![], vec![]); | ||
// FIXME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sitting in a commented-out FIXME
until we write the predicate subsumption logic (which I'll switch back to after fixing a couple other things that I'm unblocking)
} | ||
|
||
#[test_log::test] | ||
fn test_looking_for_narrower_command() -> TestResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy of the original integration test, but without the Agent
bits. i.e. testing a smaller surface.
|
||
pub trait Store<T, DID: Did, V: varsig::Header<C>, C: Codec + Into<u64> + TryFrom<u64>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just made the modules layout the same as all of the other stores. This probably should be in its own PR, but it was driving me up the wall while working 😅
Ipld: Encode<C>, | ||
Payload<DID>: TryFrom<Named<Ipld>>, | ||
Named<Ipld>: From<Payload<DID>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This combination of constraints comes up repeatedly a bit.
Perhaps worth keeping in the back of our minds whether we should turn this into a trait that combines all these constraints? Personally I'd also appreciate getting away from From
and TryFrom
for parsing. IMO they can make code & compiler errors less readable.
Not in this PR though! Let's just keep it in mind.
Wrote some tests for the (now fixed?) delegation store. It still has some commented-out work for the predicate language, but that is queued up for after we get the basics working for the server.
Changes
get_chain
store.insert(delegation)
method as a convenience to not need to take the CID manuallyjq
-styleSelector
logic that was causing issues at the higher levelsdelegation::store
intodelegation::store::memory
and::traits
, just like the other stores