--- a/crates/evm-coder/src/abi/test.rs +++ b/crates/evm-coder/src/abi/test.rs @@ -538,3 +538,68 @@ assert_eq!(p1, 0x0a); assert_eq!(p2, 0x0b); } + +#[test] +fn encode_decode_option_uint8_some() { + test_impl::>( + 0xdeadbeef, + Some(44), + &hex!( + " + deadbeef + 0000000000000000000000000000000000000000000000000000000000000001 + 000000000000000000000000000000000000000000000000000000000000002c + " + ), + ); +} + +#[test] +fn encode_decode_option_uint8_none() { + test_impl::>( + 0xdeadbeef, + None, + &hex!( + " + deadbeef + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + " + ), + ); +} + +#[test] +fn encode_decode_option_string_some() { + test_impl::>( + 0xdeadbeef, + Some("some string".to_string()), + &hex!( + " + deadbeef + 0000000000000000000000000000000000000000000000000000000000000020 + 0000000000000000000000000000000000000000000000000000000000000001 + 0000000000000000000000000000000000000000000000000000000000000040 + 000000000000000000000000000000000000000000000000000000000000000b + 736f6d6520737472696e67000000000000000000000000000000000000000000 + " + ), + ); +} + +#[test] +fn encode_decode_option_string_none() { + test_impl::>( + 0xdeadbeef, + None, + &hex!( + " + deadbeef + 0000000000000000000000000000000000000000000000000000000000000020 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000040 + 0000000000000000000000000000000000000000000000000000000000000000 + " + ), + ); +}