Skip to content

Improve CID handling #142

Open
Open

Description

@vmx

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions