difftreelog
fix unit tests
in: master
6 files changed
crates/evm-coder/src/abi/test.rsdiffbeforeafterboth393940#[test]40#[test]41fn encode_decode_uint8() {41fn encode_decode_uint8() {42 test_impl_uint!(uint8);42 test_impl_uint!(u8);43}43}444445#[test]45#[test]46fn encode_decode_uint32() {46fn encode_decode_uint32() {47 test_impl_uint!(uint32);47 test_impl_uint!(u32);48}48}494950#[test]50#[test]51fn encode_decode_uint128() {51fn encode_decode_uint128() {52 test_impl_uint!(uint128);52 test_impl_uint!(u128);53}53}545455#[test]55#[test]56fn encode_decode_uint256() {56fn encode_decode_uint256() {57 test_impl::<uint256>(57 test_impl::<U256>(58 0xdeadbeef,58 0xdeadbeef,59 U256([255, 0, 0, 0]),59 U256([255, 0, 0, 0]),60 &hex!(60 &hex!(101101102#[test]102#[test]103fn encode_decode_vec_tuple_address_uint256() {103fn encode_decode_vec_tuple_address_uint256() {104 test_impl::<Vec<(address, uint256)>>(104 test_impl::<Vec<(address, U256)>>(105 0x1ACF2D55,105 0x1ACF2D55,106 vec![106 vec![107 (107 (138138139#[test]139#[test]140fn encode_decode_vec_tuple_uint256_string() {140fn encode_decode_vec_tuple_uint256_string() {141 test_impl::<Vec<(uint256, string)>>(141 test_impl::<Vec<(U256, string)>>(142 0xdeadbeef,142 0xdeadbeef,143 vec![143 vec![144 (1.into(), "Test URI 0".to_string()),144 (1.into(), "Test URI 0".to_string()),261 let (call, mut decoder) = AbiReader::new_call(encoded_data).unwrap();261 let (call, mut decoder) = AbiReader::new_call(encoded_data).unwrap();262 assert_eq!(call, u32::to_be_bytes(decoded_data.0));262 assert_eq!(call, u32::to_be_bytes(decoded_data.0));263 let address = decoder.address().unwrap();263 let address = decoder.address().unwrap();264 let data = <Vec<(uint256, string)>>::abi_read(&mut decoder).unwrap();264 let data = <Vec<(U256, string)>>::abi_read(&mut decoder).unwrap();265 assert_eq!(data, decoded_data.1);265 assert_eq!(data, decoded_data.1);266266267 let mut writer = AbiWriter::new_call(decoded_data.0);267 let mut writer = AbiWriter::new_call(decoded_data.0);crates/evm-coder/tests/conditional_is.rsdiffbeforeafterboth445#[solidity_interface(name = A)]5#[solidity_interface(name = A)]6impl Contract {6impl Contract {7 fn method_a() -> Result<void> {7 fn method_a() -> Result<()> {8 Ok(())8 Ok(())9 }9 }10}10}111112#[solidity_interface(name = B)]12#[solidity_interface(name = B)]13impl Contract {13impl Contract {14 fn method_b() -> Result<void> {14 fn method_b() -> Result<()> {15 Ok(())15 Ok(())16 }16 }17}17}crates/evm-coder/tests/generics.rsdiffbeforeafterboth161617use std::marker::PhantomData;17use std::marker::PhantomData;18use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};18use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};19use primitive_types::U256;192020pub struct Generic<T>(PhantomData<T>);21pub struct Generic<T>(PhantomData<T>);212222#[solidity_interface(name = GenericIs)]23#[solidity_interface(name = GenericIs)]23impl<T> Generic<T> {24impl<T> Generic<T> {24 fn test_1(&self) -> Result<uint256> {25 fn test_1(&self) -> Result<U256> {25 unreachable!()26 unreachable!()26 }27 }27}28}282929#[solidity_interface(name = Generic, is(GenericIs))]30#[solidity_interface(name = Generic, is(GenericIs))]30impl<T: Into<u32>> Generic<T> {31impl<T: Into<u32>> Generic<T> {31 fn test_2(&self) -> Result<uint256> {32 fn test_2(&self) -> Result<U256> {32 unreachable!()33 unreachable!()33 }34 }34}35}40where41where41 T: core::fmt::Debug,42 T: core::fmt::Debug,42{43{43 fn test_3(&self) -> Result<uint256> {44 fn test_3(&self) -> Result<U256> {44 unreachable!()45 unreachable!()45 }46 }46}47}crates/evm-coder/tests/log.rsdiffbeforeafterboth17#![allow(dead_code)]17#![allow(dead_code)]181819use evm_coder::{ToLog, types::*};19use evm_coder::{ToLog, types::*};20use primitive_types::U256;202121#[derive(ToLog)]22#[derive(ToLog)]22enum ERC721Log {23enum ERC721Log {25 from: address,26 from: address,26 #[indexed]27 #[indexed]27 to: address,28 to: address,28 value: uint256,29 value: U256,29 },30 },30 Eee {31 Eee {31 #[indexed]32 #[indexed]32 aaa: address,33 aaa: address,33 bbb: uint256,34 bbb: U256,34 },35 },35}36}3637crates/evm-coder/tests/random.rsdiffbeforeafterboth19use evm_coder::{19use evm_coder::{20 abi::AbiType, ToLog, execution::Result, solidity_interface, types::*, solidity, weight,20 abi::AbiType, ToLog, execution::Result, solidity_interface, types::*, solidity, weight,21};21};22use primitive_types::U256;222323pub struct Impls;24pub struct Impls;242525#[solidity_interface(name = OurInterface)]26#[solidity_interface(name = OurInterface)]26impl Impls {27impl Impls {27 fn fn_a(&self, _input: uint256) -> Result<bool> {28 fn fn_a(&self, _input: U256) -> Result<bool> {28 unreachable!()29 unreachable!()29 }30 }30}31}313232#[solidity_interface(name = OurInterface1)]33#[solidity_interface(name = OurInterface1)]33impl Impls {34impl Impls {34 fn fn_b(&self, _input: uint128) -> Result<uint32> {35 fn fn_b(&self, _input: u128) -> Result<u32> {35 unreachable!()36 unreachable!()36 }37 }37}38}383939#[derive(ToLog)]40#[derive(ToLog)]40enum OurEvents {41enum OurEvents {41 Event1 {42 Event1 {42 field1: uint32,43 field1: u32,43 },44 },44 Event2 {45 Event2 {45 field1: uint32,46 field1: u32,46 #[indexed]47 #[indexed]47 field2: uint32,48 field2: u32,48 },49 },49}50}505156)]57)]57impl Impls {58impl Impls {58 #[solidity(rename_selector = "fnK")]59 #[solidity(rename_selector = "fnK")]59 fn fn_c(&self, _input: uint32) -> Result<uint8> {60 fn fn_c(&self, _input: u32) -> Result<u8> {60 unreachable!()61 unreachable!()61 }62 }62 fn fn_d(&self, _value: uint32) -> Result<uint32> {63 fn fn_d(&self, _value: u32) -> Result<u32> {63 unreachable!()64 unreachable!()64 }65 }656666 fn caller_sensitive(&self, _caller: caller) -> Result<uint8> {67 fn caller_sensitive(&self, _caller: caller) -> Result<u8> {67 unreachable!()68 unreachable!()68 }69 }69 fn payable(&mut self, _value: value) -> Result<uint8> {70 fn payable(&mut self, _value: value) -> Result<u8> {70 unreachable!()71 unreachable!()71 }72 }727373 #[weight(*_weight)]74 #[weight(*_weight)]74 fn with_weight(&self, _weight: uint64) -> Result<void> {75 fn with_weight(&self, _weight: u64) -> Result<()> {75 unreachable!()76 unreachable!()76 }77 }777878 /// Doccoment example79 /// Doccoment example79 fn with_doc(&self) -> Result<void> {80 fn with_doc(&self) -> Result<()> {80 unreachable!()81 unreachable!()81 }82 }82}83}crates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use evm_coder::{abi::AbiType, execution::Result, generate_stubgen, solidity_interface, types::*};17use evm_coder::{abi::AbiType, execution::Result, generate_stubgen, solidity_interface, types::*};18use primitive_types::U256;181919pub struct ERC20;20pub struct ERC20;202121#[solidity_interface(name = ERC20)]22#[solidity_interface(name = ERC20)]22impl ERC20 {23impl ERC20 {23 fn decimals(&self) -> Result<uint8> {24 fn decimals(&self) -> Result<u8> {24 unreachable!()25 unreachable!()25 }26 }26 /// Get balance of specified owner27 /// Get balance of specified owner27 fn balance_of(&self, _owner: address) -> Result<uint256> {28 fn balance_of(&self, _owner: address) -> Result<U256> {28 unreachable!()29 unreachable!()29 }30 }30 fn transfer(&mut self, _caller: caller, _to: address, _value: uint256) -> Result<bool> {31 fn transfer(&mut self, _caller: caller, _to: address, _value: U256) -> Result<bool> {31 unreachable!()32 unreachable!()32 }33 }33 fn transfer_from(34 fn transfer_from(34 &mut self,35 &mut self,35 _caller: caller,36 _caller: caller,36 _from: address,37 _from: address,37 _to: address,38 _to: address,38 _value: uint256,39 _value: U256,39 ) -> Result<bool> {40 ) -> Result<bool> {40 unreachable!()41 unreachable!()41 }42 }42 fn approve(&mut self, _caller: caller, _spender: address, _value: uint256) -> Result<bool> {43 fn approve(&mut self, _caller: caller, _spender: address, _value: U256) -> Result<bool> {43 unreachable!()44 unreachable!()44 }45 }45 fn allowance(&self, _owner: address, _spender: address) -> Result<uint256> {46 fn allowance(&self, _owner: address, _spender: address) -> Result<U256> {46 unreachable!()47 unreachable!()47 }48 }48}49}