diff --git a/crates/dyn-abi/src/dynamic/ty.rs b/crates/dyn-abi/src/dynamic/ty.rs index 2b6d80fe7..d7c64fde4 100644 --- a/crates/dyn-abi/src/dynamic/ty.rs +++ b/crates/dyn-abi/src/dynamic/ty.rs @@ -1108,10 +1108,10 @@ re-enc: {re_enc} assert!( packed == expected, " - type: {ty} - value: {value:?} -packed: {packed} -expect: {expected}", + type: {ty} + value: {value:?} + packed: {packed} +expected: {expected}", packed = hex::encode(packed), expected = hex::encode(expected), ); @@ -1175,6 +1175,30 @@ expect: {expected}", bytes_2("bytes", "0001", "0001"), bytes_3("bytes", "000102", "000102"), + fbytes_1("bytes1", "00", "00"), + fbytes_2("bytes2", "1234", "1234"), + fbytes_3("(address,bytes20)", "(\ + 1111111111111111111111111111111111111111,\ + 2222222222222222222222222222222222222222\ + )", " + 1111111111111111111111111111111111111111 + 2222222222222222222222222222222222222222 + "), + fbytes_4("bytes20[]", "[\ + 1111111111111111111111111111111111111111,\ + 2222222222222222222222222222222222222222\ + ]", " + 0000000000000000000000001111111111111111111111111111111111111111 + 0000000000000000000000002222222222222222222222222222222222222222 + "), + fbytes_5("bytes20[2]", "[\ + 1111111111111111111111111111111111111111,\ + 2222222222222222222222222222222222222222\ + ]", " + 0000000000000000000000001111111111111111111111111111111111111111 + 0000000000000000000000002222222222222222222222222222222222222222 + "), + dynamic_array_of_addresses("address[]", "[\ 1111111111111111111111111111111111111111,\ 2222222222222222222222222222222222222222\ diff --git a/crates/dyn-abi/src/dynamic/value.rs b/crates/dyn-abi/src/dynamic/value.rs index b2b15ee1b..fe0100fe0 100644 --- a/crates/dyn-abi/src/dynamic/value.rs +++ b/crates/dyn-abi/src/dynamic/value.rs @@ -677,7 +677,7 @@ impl DynSolValue { Self::Bool(b) => buf.push(*b as u8), Self::String(s) => buf.extend_from_slice(s.as_bytes()), Self::Bytes(bytes) => buf.extend_from_slice(bytes), - Self::FixedBytes(word, size) => buf.extend_from_slice(&word[..(*size).max(32)]), + Self::FixedBytes(word, size) => buf.extend_from_slice(&word[..(*size).min(32)]), Self::Int(num, size) => { let byte_size = *size / 8; let start = 32usize.saturating_sub(byte_size);