anchor-book
anchor-book copied to clipboard
bug about "Tic-Tac-Toe" project.
When i code flow this example Milestone Project - Tic-Tac-Toe.
I got an error " Error: AnchorError caused by account: game. Error Code: AccountDidNotSerialize. Error Number: 3004. Error Message: Failed to serialize the account." at anchor test.
I also see the notice.
(What about using mem::size_of<Game>()? This almost works but not quite. The issue is that borsh will always serialize an option as 1 byte for the variant identifier and then additional x bytes for the content if it's Some. Rust uses null-pointer optimization to make Option's variant identifier 0 bytes when it can, so an option is sometimes just as big as its contents. This is the case with Sign. This means the MAXIMUM_SIZE could also be expressed as mem::size_of<Game>() + 9.)
but it seems like lose 4 bit
of borsh space. Maybe the MAXIMUM_SIZE need change to pub const MAXIMUM_SIZE: usize = 4 + (32 * 2) + 1 + (9 * (1 + 1)) + (32 + 1);