@@ -4,12 +4,12 @@ use frame_support::{assert_ok, traits::Currency, weights::Weight};
44use pallet_evm:: { FeeCalculator , FixedGasWeightMapping , GasWeightMapping , Runner } ;
55use sp_core:: { H160 , U256 } ;
66use sp_runtime:: traits:: UniqueSaturatedInto ;
7- use sp_std:: str:: FromStr ;
87
98use crate :: { mock:: * , * } ;
109
1110mod currency;
1211mod fungible;
12+ mod fungible_conformance;
1313
1414#[ test]
1515fn basic_setup_works ( ) {
@@ -29,7 +29,7 @@ fn basic_setup_works() {
2929#[ test]
3030fn evm_fee_deduction ( ) {
3131 new_test_ext ( ) . execute_with_ext ( |_| {
32- let charlie = H160 :: from_str ( "1000000000000000000000000000000000000003" ) . unwrap ( ) ;
32+ let charlie = 3 ;
3333
3434 // Seed account
3535 let _ = <Test as pallet_evm:: Config >:: Currency :: deposit_creating ( & charlie, 100 ) ;
@@ -38,14 +38,14 @@ fn evm_fee_deduction() {
3838 // Deduct fees as 10 units
3939 let imbalance =
4040 <<Test as pallet_evm:: Config >:: OnChargeTransaction as pallet_evm:: OnChargeEVMTransaction < Test > >:: withdraw_fee (
41- & charlie,
41+ & H160 :: from_low_u64_be ( charlie) ,
4242 U256 :: from ( 10 ) ,
4343 )
4444 . unwrap ( ) ;
4545 assert_eq ! ( EvmBalances :: free_balance( & charlie) , 90 ) ;
4646
4747 // Refund fees as 5 units
48- <<Test as pallet_evm:: Config >:: OnChargeTransaction as pallet_evm:: OnChargeEVMTransaction < Test > >:: correct_and_deposit_fee ( & charlie, U256 :: from ( 5 ) , U256 :: from ( 5 ) , imbalance) ;
48+ <<Test as pallet_evm:: Config >:: OnChargeTransaction as pallet_evm:: OnChargeEVMTransaction < Test > >:: correct_and_deposit_fee ( & H160 :: from_low_u64_be ( charlie) , U256 :: from ( 5 ) , U256 :: from ( 5 ) , imbalance) ;
4949 assert_eq ! ( EvmBalances :: free_balance( & charlie) , 95 ) ;
5050 } ) ;
5151}
@@ -59,8 +59,8 @@ fn evm_issuance_after_tip() {
5959 let weight_limit = FixedGasWeightMapping :: < Test > :: gas_to_weight ( gas_limit, true ) ;
6060
6161 assert_ok ! ( <Test as pallet_evm:: Config >:: Runner :: call(
62- alice ( ) ,
63- bob ( ) ,
62+ alice_h160 ( ) ,
63+ bob_h160 ( ) ,
6464 Vec :: new( ) ,
6565 U256 :: from( 1 ) ,
6666 gas_limit,
@@ -89,7 +89,7 @@ fn evm_issuance_after_tip() {
8989#[ test]
9090fn evm_refunds_should_work ( ) {
9191 new_test_ext ( ) . execute_with_ext ( |_| {
92- let before_call = EVM :: account_basic ( & alice ( ) ) . 0 . balance ;
92+ let before_call = EVM :: account_basic ( & alice_h160 ( ) ) . 0 . balance ;
9393 // Gas price is not part of the actual fee calculations anymore, only the base fee.
9494 //
9595 // Because we first deduct max_fee_per_gas * gas_limit (2_000_000_000 * 1000000) we need
@@ -99,8 +99,8 @@ fn evm_refunds_should_work() {
9999 let weight_limit = FixedGasWeightMapping :: < Test > :: gas_to_weight ( gas_limit, true ) ;
100100
101101 let _ = <Test as pallet_evm:: Config >:: Runner :: call (
102- alice ( ) ,
103- bob ( ) ,
102+ alice_h160 ( ) ,
103+ bob_h160 ( ) ,
104104 Vec :: new ( ) ,
105105 U256 :: from ( 1 ) ,
106106 gas_limit,
@@ -117,15 +117,15 @@ fn evm_refunds_should_work() {
117117
118118 let ( base_fee, _) = <Test as pallet_evm:: Config >:: FeeCalculator :: min_gas_price ( ) ;
119119 let total_cost = ( U256 :: from ( 21_000 ) * base_fee) + U256 :: from ( 1 ) ;
120- let after_call = EVM :: account_basic ( & alice ( ) ) . 0 . balance ;
120+ let after_call = EVM :: account_basic ( & alice_h160 ( ) ) . 0 . balance ;
121121 assert_eq ! ( after_call, before_call - total_cost) ;
122122 } ) ;
123123}
124124
125125#[ test]
126126fn evm_refunds_and_priority_should_work ( ) {
127127 new_test_ext ( ) . execute_with_ext ( |_| {
128- let before_call = EVM :: account_basic ( & alice ( ) ) . 0 . balance ;
128+ let before_call = EVM :: account_basic ( & alice_h160 ( ) ) . 0 . balance ;
129129 // We deliberately set a base fee + max tip > max fee.
130130 // The effective priority tip will be 1GWEI instead 1.5GWEI:
131131 // (max_fee_per_gas - base_fee).min(max_priority_fee)
@@ -138,8 +138,8 @@ fn evm_refunds_and_priority_should_work() {
138138 let weight_limit = FixedGasWeightMapping :: < Test > :: gas_to_weight ( gas_limit, true ) ;
139139
140140 let _ = <Test as pallet_evm:: Config >:: Runner :: call (
141- alice ( ) ,
142- bob ( ) ,
141+ alice_h160 ( ) ,
142+ bob_h160 ( ) ,
143143 Vec :: new ( ) ,
144144 U256 :: from ( 1 ) ,
145145 gas_limit,
@@ -157,7 +157,7 @@ fn evm_refunds_and_priority_should_work() {
157157 let ( base_fee, _) = <Test as pallet_evm:: Config >:: FeeCalculator :: min_gas_price ( ) ;
158158 let actual_tip = ( max_fee_per_gas - base_fee) . min ( tip) * used_gas;
159159 let total_cost = ( used_gas * base_fee) + U256 :: from ( actual_tip) + U256 :: from ( 1 ) ;
160- let after_call = EVM :: account_basic ( & alice ( ) ) . 0 . balance ;
160+ let after_call = EVM :: account_basic ( & alice_h160 ( ) ) . 0 . balance ;
161161 // The tip is deducted but never refunded to the caller.
162162 assert_eq ! ( after_call, before_call - total_cost) ;
163163 } ) ;
@@ -173,8 +173,8 @@ fn evm_call_should_fail_with_priority_greater_than_max_fee() {
173173 let weight_limit = FixedGasWeightMapping :: < Test > :: gas_to_weight ( gas_limit, true ) ;
174174
175175 let result = <Test as pallet_evm:: Config >:: Runner :: call (
176- alice ( ) ,
177- bob ( ) ,
176+ alice_h160 ( ) ,
177+ bob_h160 ( ) ,
178178 Vec :: new ( ) ,
179179 U256 :: from ( 1 ) ,
180180 gas_limit,
@@ -205,8 +205,8 @@ fn evm_call_should_succeed_with_priority_equal_to_max_fee() {
205205 // Mimics the input for pre-eip-1559 transaction types where `gas_price`
206206 // is used for both `max_fee_per_gas` and `max_priority_fee_per_gas`.
207207 let result = <Test as pallet_evm:: Config >:: Runner :: call (
208- alice ( ) ,
209- bob ( ) ,
208+ alice_h160 ( ) ,
209+ bob_h160 ( ) ,
210210 Vec :: new ( ) ,
211211 U256 :: from ( 1 ) ,
212212 gas_limit,
0 commit comments