Skip to content

Commit 4c3f21c

Browse files
committed
test(integration): update RLP test to use revive
1 parent 019ad69 commit 4c3f21c

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

integration-tests/public/rlp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ink = { path = "../../../crates/ink", default-features = false }
1111
[dev-dependencies]
1212
ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] }
1313
ink_sandbox = { path = "../../../crates/e2e/sandbox" }
14-
pallet-contracts = { version = "38.0.0", default-features = false }
14+
pallet-revive = { git = "https://github.com/paritytech/polkadot-sdk", rev = "645878a27115db52e5d63115699b4bbb89034067", default-features = false }
1515
sha3 = { version = "0.10" }
1616

1717
[lib]

integration-tests/public/rlp/e2e_tests.rs

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ use ink_e2e::{
33
ContractsRegistry,
44
Keypair,
55
};
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;
1112

1213
#[test]
1314
fn call_rlp_encoded_message() {
@@ -24,34 +25,39 @@ fn call_rlp_encoded_message() {
2425
)
2526
.unwrap_or_else(|_| panic!("Failed to mint tokens"));
2627

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+
2731
// given
2832
let constructor = RlpRef::new(false);
2933
let params = constructor
3034
.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)
3337
.params();
3438
let exec_input = params.exec_input();
3539

40+
// TODO: could potentially simplify if helpers are exposed.
41+
3642
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>
3844
::deploy_contract(
3945
&mut sandbox,
4046
code,
4147
0,
4248
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
4650
None,
51+
origin,
52+
<DefaultSandbox as Sandbox>::default_gas_limit(),
53+
STORAGE_DEPOSIT_LIMIT
4754
)
4855
.result
49-
.expect("sandbox deploy contract failed")
50-
.account_id;
56+
.expect("sandbox deploy contract failed").addr;
5157

5258
let mut contract = ContractSandbox {
5359
sandbox,
54-
contract_account_id,
60+
contract_addr: contract_addr,
5561
};
5662

5763
// set value
@@ -66,7 +72,7 @@ fn call_rlp_encoded_message() {
6672

6773
struct ContractSandbox {
6874
sandbox: ink_e2e::DefaultSandbox,
69-
contract_account_id: AccountId32,
75+
contract_addr: H160,
7076
}
7177

7278
impl ContractSandbox {
@@ -98,18 +104,19 @@ impl ContractSandbox {
98104
result.data
99105
}
100106

107+
101108
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));
102110
let result =
103-
<ink_e2e::DefaultSandbox as ink_sandbox::api::contracts_api::ContractAPI>
111+
<DefaultSandbox as ink_sandbox::api::revive_api::ContractAPI>
104112
::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,
113120
)
114121
.result
115122
.expect("sandbox call contract failed");

0 commit comments

Comments
 (0)