Skip to content
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

Improve CID handling #142

Open
vmx opened this issue Feb 25, 2022 · 0 comments
Open

Improve CID handling #142

vmx opened this issue Feb 25, 2022 · 0 comments

Comments

@vmx
Copy link
Member

vmx commented Feb 25, 2022

Based on the discussion at #140 (comment) I open this issue to track the problem of possible ways to return a CID when it was not intended.

One example to show this issue:

#[test]
fn ipld_deserialize_link_wrong_newtype_struct() {
    let cid = Cid::try_from("bafkreie74tgmnxqwojhtumgh5dzfj46gi4mynlfr7dmm7duwzyvnpw7h7m").unwrap();
    let ipld = Ipld::Link(cid);
    assert_de_tokens(
        &ipld,
        &[
            Token::NewtypeStruct { name: "foobar" },
            Token::Bytes(&[
                1, 85, 18, 32, 159, 228, 204, 198, 222, 22, 114, 79, 58, 48, 199, 232, 242, 84,
                243, 198, 71, 25, 134, 172, 177, 248, 216, 207, 142, 150, 206, 42, 215, 219, 231,
                251,
            ]),
        ],
    );
}

The problem here is that it should work with a Newtype Struct named foobar, but only with one named after the CID_SERDE_PRIVATE_IDENTIFIER.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant