From 20c99441bd570c5dda30889b64d27e0a6e79e01a Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Wed, 09 Nov 2022 09:07:03 +0000 Subject: [PATCH] Merge pull request #707 from UniqueNetwork/feature/add_test-abi--test--encode_decode_vec_tuple_string_bytes add test abi::test::encode_decode_vec_tuple_string_bytes --- --- a/crates/evm-coder/src/abi.rs +++ b/crates/evm-coder/src/abi.rs @@ -808,6 +808,67 @@ ) ); + test_impl!( + vec_tuple_string_bytes, + Vec<(string, bytes)>, + 0xdeadbeef, + vec![ + ( + "Test URI 0".to_string(), + bytes(vec![ + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 + ]) + ), + ( + "Test URI 1".to_string(), + bytes(vec![ + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22 + ]) + ), + ("Test URI 2".to_string(), bytes(vec![0x33, 0x33])), + ], + &hex!( + " + deadbeef + 0000000000000000000000000000000000000000000000000000000000000020 + 0000000000000000000000000000000000000000000000000000000000000003 + + 0000000000000000000000000000000000000000000000000000000000000060 + 0000000000000000000000000000000000000000000000000000000000000140 + 0000000000000000000000000000000000000000000000000000000000000220 + + 0000000000000000000000000000000000000000000000000000000000000040 + 0000000000000000000000000000000000000000000000000000000000000080 + 000000000000000000000000000000000000000000000000000000000000000a + 5465737420555249203000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000030 + 1111111111111111111111111111111111111111111111111111111111111111 + 1111111111111111111111111111111100000000000000000000000000000000 + + 0000000000000000000000000000000000000000000000000000000000000040 + 0000000000000000000000000000000000000000000000000000000000000080 + 000000000000000000000000000000000000000000000000000000000000000a + 5465737420555249203100000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000000002f + 2222222222222222222222222222222222222222222222222222222222222222 + 2222222222222222222222222222220000000000000000000000000000000000 + + 0000000000000000000000000000000000000000000000000000000000000040 + 0000000000000000000000000000000000000000000000000000000000000080 + 000000000000000000000000000000000000000000000000000000000000000a + 5465737420555249203200000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000002 + 3333000000000000000000000000000000000000000000000000000000000000 + " + ) + ); + #[test] fn dynamic_after_static() { let mut encoder = AbiWriter::new(); --- a/crates/evm-coder/src/lib.rs +++ b/crates/evm-coder/src/lib.rs @@ -163,7 +163,7 @@ #[cfg(feature = "std")] define_simple_type!(type string = ::std::string::String); - #[derive(Default, Debug)] + #[derive(Default, Debug, PartialEq)] pub struct bytes(pub Vec); impl Signature for bytes { const SIGNATURE: SignatureUnit = make_signature!(new fixed("bytes")); -- gitstuff