Skip to content

Decoding of fixed bytes order may be wrong #71

Description

@ermvrs

Ensure bytes decoded correctly via adding new tests.

It includes more tests for fixed sized bytes and dynamic sizes (bytes) also string

Example test

#[test]
fn test_decode_bytes32_zeroes() {
    let mut data: Bytes = BytesTrait::blank();

    data.append_u256(0x00000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
    let mut calldata = cd(data);

    let decoded = calldata.decode(array![EVMTypes::Bytes32].span());
    assert_eq!(*decoded.at(0), 0x1);
    assert_eq!(*decoded.at(1), 0x000fffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
    assert_eq!(*decoded.at(2), 0x00);
    assert_eq!(*decoded.at(3), 0x1);
}

But im not sure the second part should be 0x00 or 0xff (first byte or last byte)

Activity

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

Metadata

Metadata

Assignees

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