git.delta.rocks / unique-network / refs/commits / c1366a22a49b

difftreelog

fix unit tests

Trubnikov Sergey2023-01-17parent: #c33e413.patch.diff
in: master

6 files changed

modifiedcrates/evm-coder/src/abi/test.rsdiffbeforeafterboth
3939
40#[test]40#[test]
41fn encode_decode_uint8() {41fn encode_decode_uint8() {
42 test_impl_uint!(uint8);42 test_impl_uint!(u8);
43}43}
4444
45#[test]45#[test]
46fn encode_decode_uint32() {46fn encode_decode_uint32() {
47 test_impl_uint!(uint32);47 test_impl_uint!(u32);
48}48}
4949
50#[test]50#[test]
51fn encode_decode_uint128() {51fn encode_decode_uint128() {
52 test_impl_uint!(uint128);52 test_impl_uint!(u128);
53}53}
5454
55#[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!(
101101
102#[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 (
138138
139#[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);
266266
267 let mut writer = AbiWriter::new_call(decoded_data.0);267 let mut writer = AbiWriter::new_call(decoded_data.0);
modifiedcrates/evm-coder/tests/conditional_is.rsdiffbeforeafterboth
44
5#[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}
1111
12#[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}
modifiedcrates/evm-coder/tests/generics.rsdiffbeforeafterboth
1616
17use 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;
1920
20pub struct Generic<T>(PhantomData<T>);21pub struct Generic<T>(PhantomData<T>);
2122
22#[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}
2829
29#[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}
40where41where
41 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}
modifiedcrates/evm-coder/tests/log.rsdiffbeforeafterboth
17#![allow(dead_code)]17#![allow(dead_code)]
1818
19use evm_coder::{ToLog, types::*};19use evm_coder::{ToLog, types::*};
20use primitive_types::U256;
2021
21#[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}
3637
modifiedcrates/evm-coder/tests/random.rsdiffbeforeafterboth
19use 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;
2223
23pub struct Impls;24pub struct Impls;
2425
25#[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}
3132
32#[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}
3839
39#[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}
5051
56)]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 }
6566
66 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 }
7273
73 #[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 }
7778
78 /// Doccoment example79 /// Doccoment example
79 fn with_doc(&self) -> Result<void> {80 fn with_doc(&self) -> Result<()> {
80 unreachable!()81 unreachable!()
81 }82 }
82}83}
modifiedcrates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth
15// 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/>.
1616
17use 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;
1819
19pub struct ERC20;20pub struct ERC20;
2021
21#[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 owner
27 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}