Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions crates/pvm-contract-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ impl<T: SolArrayElement + StaticDecode + StaticEncodedLen, const N: usize> Stati
as usize;
unsafe { T::decode_unchecked(input, offset + field_offset) }
} else {
unsafe { T::decode_unchecked(input, i * T::SLOT_SIZE) }
unsafe { T::decode_unchecked(input, offset + i * T::SLOT_SIZE) }
}
};

Expand Down Expand Up @@ -1604,4 +1604,16 @@ impl_tuple_sol!((0: A), (1: B), (2: C), (3: D), (4: E), (5: F), (6: G), (7: H_),
impl_tuple_sol!((0: A), (1: B), (2: C), (3: D), (4: E), (5: F), (6: G), (7: H_), (8: I), (9: J), (10: K), (11: L));

#[cfg(test)]
mod tests;
Comment thread
pkhry marked this conversation as resolved.
mod tests {
use super::*;

#[test]
fn decode_unchecked_failure() {
Comment thread
pkhry marked this conversation as resolved.
Outdated
let mut buf = [0; 256];
(10u32, [5u32, 10]).encode_to(&mut buf);
assert_eq!(
unsafe { <(u32, [u32; 2])>::decode_unchecked(&buf, 0) },
(10u32, [5u32, 10])
);
}
}
Loading