@@ -3,11 +3,12 @@ use ink_e2e::{
3
3
ContractsRegistry ,
4
4
Keypair ,
5
5
} ;
6
- use ink_sandbox:: {
7
- api:: balance_api:: BalanceAPI ,
8
- AccountId32 ,
9
- } ;
10
- use pallet_contracts:: ExecReturnValue ;
6
+ use ink_sandbox:: { api:: prelude:: * , AccountId32 , DefaultSandbox , Sandbox } ;
7
+ use pallet_revive:: ExecReturnValue ;
8
+ use ink:: H160 ;
9
+ use ink:: primitives:: { AccountId , DepositLimit } ;
10
+ use ink_e2e:: subxt:: tx:: Signer ;
11
+ const STORAGE_DEPOSIT_LIMIT : DepositLimit < u128 > = DepositLimit :: Unchecked ;
11
12
12
13
#[ test]
13
14
fn call_rlp_encoded_message ( ) {
@@ -24,34 +25,39 @@ fn call_rlp_encoded_message() {
24
25
)
25
26
. unwrap_or_else ( |_| panic ! ( "Failed to mint tokens" ) ) ;
26
27
28
+ let origin = DefaultSandbox :: convert_account_to_origin ( AccountId32 :: from ( caller. public_key ( ) . 0 ) ) ;
29
+ sandbox. map_account ( origin. clone ( ) ) . expect ( "unable to map" ) ;
30
+
27
31
// given
28
32
let constructor = RlpRef :: new ( false ) ;
29
33
let params = constructor
30
34
. endowment ( 0u32 . into ( ) )
31
- . code_hash ( ink:: primitives:: Clear :: CLEAR_HASH )
32
- . salt_bytes ( Vec :: new ( ) )
35
+ . code_hash ( ink:: primitives:: H256 :: zero ( ) )
36
+ . salt_bytes ( None )
33
37
. params ( ) ;
34
38
let exec_input = params. exec_input ( ) ;
35
39
40
+ // TODO: could potentially simplify if helpers are exposed.
41
+
36
42
let code = contracts. load_code ( "rlp" ) ;
37
- let contract_account_id = <ink_e2e :: DefaultSandbox as ink_sandbox:: api:: contracts_api :: ContractAPI >
43
+ let contract_addr = <DefaultSandbox as ink_sandbox:: api:: revive_api :: ContractAPI >
38
44
:: deploy_contract (
39
45
& mut sandbox,
40
46
code,
41
47
0 ,
42
48
ink:: scale:: Encode :: encode ( & exec_input) ,
43
- vec ! [ 0u8 ] ,
44
- caller. public_key ( ) . 0 . into ( ) ,
45
- <ink_e2e:: DefaultSandbox as ink_sandbox:: Sandbox >:: default_gas_limit ( ) ,
49
+ // salt
46
50
None ,
51
+ origin,
52
+ <DefaultSandbox as Sandbox >:: default_gas_limit ( ) ,
53
+ STORAGE_DEPOSIT_LIMIT
47
54
)
48
55
. result
49
- . expect ( "sandbox deploy contract failed" )
50
- . account_id ;
56
+ . expect ( "sandbox deploy contract failed" ) . addr ;
51
57
52
58
let mut contract = ContractSandbox {
53
59
sandbox,
54
- contract_account_id ,
60
+ contract_addr : contract_addr ,
55
61
} ;
56
62
57
63
// set value
@@ -66,7 +72,7 @@ fn call_rlp_encoded_message() {
66
72
67
73
struct ContractSandbox {
68
74
sandbox : ink_e2e:: DefaultSandbox ,
69
- contract_account_id : AccountId32 ,
75
+ contract_addr : H160 ,
70
76
}
71
77
72
78
impl ContractSandbox {
@@ -98,18 +104,19 @@ impl ContractSandbox {
98
104
result. data
99
105
}
100
106
107
+
101
108
fn call_raw ( & mut self , data : Vec < u8 > , caller : Keypair ) -> ExecReturnValue {
109
+ let origin = DefaultSandbox :: convert_account_to_origin ( AccountId32 :: from ( caller. public_key ( ) . 0 ) ) ;
102
110
let result =
103
- <ink_e2e :: DefaultSandbox as ink_sandbox:: api:: contracts_api :: ContractAPI >
111
+ <DefaultSandbox as ink_sandbox:: api:: revive_api :: ContractAPI >
104
112
:: call_contract (
105
- & mut self . sandbox ,
106
- self . contract_account_id . clone ( ) ,
107
- 0 ,
108
- data,
109
- caller. public_key ( ) . 0 . into ( ) ,
110
- <ink_e2e:: DefaultSandbox as ink_sandbox:: Sandbox >:: default_gas_limit ( ) ,
111
- None ,
112
- pallet_contracts:: Determinism :: Enforced ,
113
+ & mut self . sandbox ,
114
+ self . contract_addr . clone ( ) ,
115
+ 0 ,
116
+ data,
117
+ origin,
118
+ <DefaultSandbox as Sandbox >:: default_gas_limit ( ) ,
119
+ STORAGE_DEPOSIT_LIMIT ,
113
120
)
114
121
. result
115
122
. expect ( "sandbox call contract failed" ) ;
0 commit comments