From 1500011fc6858c5e24c8826b73d0df09e56c6ff8 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Fri, 23 Apr 2021 11:26:26 -0700 Subject: [PATCH] get_packed_len() now correctly handles u32/i32 types --- sdk/program/src/borsh.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/program/src/borsh.rs b/sdk/program/src/borsh.rs index e971da2e95..e85d685040 100644 --- a/sdk/program/src/borsh.rs +++ b/sdk/program/src/borsh.rs @@ -46,7 +46,7 @@ fn get_declaration_packed_len( None => match declaration { "u8" | "i8" => 1, "u16" | "i16" => 2, - "u32" | "i32" => 2, + "u32" | "i32" => 4, "u64" | "i64" => 8, "u128" | "i128" => 16, "nil" => 0, @@ -99,7 +99,8 @@ mod tests { #[derive(BorshSerialize, BorshDeserialize, BorshSchema)] struct TestStruct { pub array: [u64; 16], - pub number: u128, + pub number_u128: u128, + pub number_u32: u32, pub tuple: (u8, u16), pub enumeration: TestEnum, } @@ -152,6 +153,7 @@ mod tests { get_packed_len::(), size_of::() * 16 + size_of::() + + size_of::() + size_of::() + size_of::() + get_packed_len::()