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.rsdiffbeforeafterboth--- a/crates/evm-coder/tests/conditional_is.rs
+++ b/crates/evm-coder/tests/conditional_is.rs
@@ -4,14 +4,14 @@
#[solidity_interface(name = A)]
impl Contract {
- fn method_a() -> Result<void> {
+ fn method_a() -> Result<()> {
Ok(())
}
}
#[solidity_interface(name = B)]
impl Contract {
- fn method_b() -> Result<void> {
+ fn method_b() -> Result<()> {
Ok(())
}
}
crates/evm-coder/tests/generics.rsdiffbeforeafterboth--- a/crates/evm-coder/tests/generics.rs
+++ b/crates/evm-coder/tests/generics.rs
@@ -16,19 +16,20 @@
use std::marker::PhantomData;
use evm_coder::{execution::Result, generate_stubgen, solidity_interface, types::*};
+use primitive_types::U256;
pub struct Generic<T>(PhantomData<T>);
#[solidity_interface(name = GenericIs)]
impl<T> Generic<T> {
- fn test_1(&self) -> Result<uint256> {
+ fn test_1(&self) -> Result<U256> {
unreachable!()
}
}
#[solidity_interface(name = Generic, is(GenericIs))]
impl<T: Into<u32>> Generic<T> {
- fn test_2(&self) -> Result<uint256> {
+ fn test_2(&self) -> Result<U256> {
unreachable!()
}
}
@@ -40,7 +41,7 @@
where
T: core::fmt::Debug,
{
- fn test_3(&self) -> Result<uint256> {
+ fn test_3(&self) -> Result<U256> {
unreachable!()
}
}
crates/evm-coder/tests/log.rsdiffbeforeafterboth--- a/crates/evm-coder/tests/log.rs
+++ b/crates/evm-coder/tests/log.rs
@@ -17,6 +17,7 @@
#![allow(dead_code)]
use evm_coder::{ToLog, types::*};
+use primitive_types::U256;
#[derive(ToLog)]
enum ERC721Log {
@@ -25,11 +26,11 @@
from: address,
#[indexed]
to: address,
- value: uint256,
+ value: U256,
},
Eee {
#[indexed]
aaa: address,
- bbb: uint256,
+ bbb: U256,
},
}
crates/evm-coder/tests/random.rsdiffbeforeafterboth--- a/crates/evm-coder/tests/random.rs
+++ b/crates/evm-coder/tests/random.rs
@@ -19,19 +19,20 @@
use evm_coder::{
abi::AbiType, ToLog, execution::Result, solidity_interface, types::*, solidity, weight,
};
+use primitive_types::U256;
pub struct Impls;
#[solidity_interface(name = OurInterface)]
impl Impls {
- fn fn_a(&self, _input: uint256) -> Result<bool> {
+ fn fn_a(&self, _input: U256) -> Result<bool> {
unreachable!()
}
}
#[solidity_interface(name = OurInterface1)]
impl Impls {
- fn fn_b(&self, _input: uint128) -> Result<uint32> {
+ fn fn_b(&self, _input: u128) -> Result<u32> {
unreachable!()
}
}
@@ -39,12 +40,12 @@
#[derive(ToLog)]
enum OurEvents {
Event1 {
- field1: uint32,
+ field1: u32,
},
Event2 {
- field1: uint32,
+ field1: u32,
#[indexed]
- field2: uint32,
+ field2: u32,
},
}
@@ -56,27 +57,27 @@
)]
impl Impls {
#[solidity(rename_selector = "fnK")]
- fn fn_c(&self, _input: uint32) -> Result<uint8> {
+ fn fn_c(&self, _input: u32) -> Result<u8> {
unreachable!()
}
- fn fn_d(&self, _value: uint32) -> Result<uint32> {
+ fn fn_d(&self, _value: u32) -> Result<u32> {
unreachable!()
}
- fn caller_sensitive(&self, _caller: caller) -> Result<uint8> {
+ fn caller_sensitive(&self, _caller: caller) -> Result<u8> {
unreachable!()
}
- fn payable(&mut self, _value: value) -> Result<uint8> {
+ fn payable(&mut self, _value: value) -> Result<u8> {
unreachable!()
}
#[weight(*_weight)]
- fn with_weight(&self, _weight: uint64) -> Result<void> {
+ fn with_weight(&self, _weight: u64) -> Result<()> {
unreachable!()
}
/// Doccoment example
- fn with_doc(&self) -> Result<void> {
+ fn with_doc(&self) -> Result<()> {
unreachable!()
}
}
crates/evm-coder/tests/solidity_generation.rsdiffbeforeafterboth--- a/crates/evm-coder/tests/solidity_generation.rs
+++ b/crates/evm-coder/tests/solidity_generation.rs
@@ -15,19 +15,20 @@
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
use evm_coder::{abi::AbiType, execution::Result, generate_stubgen, solidity_interface, types::*};
+use primitive_types::U256;
pub struct ERC20;
#[solidity_interface(name = ERC20)]
impl ERC20 {
- fn decimals(&self) -> Result<uint8> {
+ fn decimals(&self) -> Result<u8> {
unreachable!()
}
/// Get balance of specified owner
- fn balance_of(&self, _owner: address) -> Result<uint256> {
+ fn balance_of(&self, _owner: address) -> Result<U256> {
unreachable!()
}
- fn transfer(&mut self, _caller: caller, _to: address, _value: uint256) -> Result<bool> {
+ fn transfer(&mut self, _caller: caller, _to: address, _value: U256) -> Result<bool> {
unreachable!()
}
fn transfer_from(
@@ -35,14 +36,14 @@
_caller: caller,
_from: address,
_to: address,
- _value: uint256,
+ _value: U256,
) -> Result<bool> {
unreachable!()
}
- fn approve(&mut self, _caller: caller, _spender: address, _value: uint256) -> Result<bool> {
+ fn approve(&mut self, _caller: caller, _spender: address, _value: U256) -> Result<bool> {
unreachable!()
}
- fn allowance(&self, _owner: address, _spender: address) -> Result<uint256> {
+ fn allowance(&self, _owner: address, _spender: address) -> Result<U256> {
unreachable!()
}
}