Skip to content

Commit

Permalink
feat: apply code suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshvarma committed Oct 19, 2023
1 parent 09b30d8 commit 66c6235
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/integration/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ mod shibuya {
<Runtime as pallet_evm::Config>::AddressMapping::into_account_id(address)
}

/// Deploy an EVM contract with code.
/// Deploy an EVM contract with code via ALICE as origin.
pub fn deploy_evm_contract(code: &str) -> H160 {
assert_ok!(EVM::create2(
RuntimeOrigin::root(),
Expand Down Expand Up @@ -97,16 +97,20 @@ mod shibuya {
address
}

/// Call a wasm smart contract method with ALICE as origin
pub fn call_wasm_contract_method<V: Decode>(contract_id: AccountId, data: Vec<u8>) -> V {
/// Call a wasm smart contract method
pub fn call_wasm_contract_method<V: Decode>(
origin: AccountId,
contract_id: AccountId,
data: Vec<u8>,
) -> V {
let (value, _, _) = astar_test_utils::call_wasm_contract_method::<Runtime, V>(
ALICE,
origin,
contract_id,
0,
Weight::from_parts(10_000_000_000, 1024 * 1024),
None,
data,
true,
false,
);
value
}
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/src/unified_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fn unified_accounts_chain_extension_works() {
// mapped h160 address should None
assert_eq!(
call_wasm_contract_method::<Option<H160>>(
ALICE,
contract_id.clone(),
[GET_H160.to_vec(), ALICE.encode()].concat()
),
Expand All @@ -64,6 +65,7 @@ fn unified_accounts_chain_extension_works() {
// default h160 address should match
assert_eq!(
call_wasm_contract_method::<H160>(
ALICE,
contract_id.clone(),
[GET_H160_OR_DEFAULT.to_vec(), ALICE.encode()].concat()
),
Expand All @@ -72,6 +74,7 @@ fn unified_accounts_chain_extension_works() {
// mapped native address should be None
assert_eq!(
call_wasm_contract_method::<Option<AccountId>>(
ALICE,
contract_id.clone(),
[GET_NATIVE.to_vec(), alith().encode()].concat()
),
Expand All @@ -80,6 +83,7 @@ fn unified_accounts_chain_extension_works() {
// default native address should match
assert_eq!(
call_wasm_contract_method::<AccountId>(
ALICE,
contract_id.clone(),
[GET_NATIVE_OR_DEFAULT.to_vec(), alith().encode()].concat()
),
Expand All @@ -94,6 +98,7 @@ fn unified_accounts_chain_extension_works() {
// ALICE mapped h160 address should be alith
assert_eq!(
call_wasm_contract_method::<Option<H160>>(
ALICE,
contract_id.clone(),
[GET_H160.to_vec(), ALICE.encode()].concat()
),
Expand All @@ -103,6 +108,7 @@ fn unified_accounts_chain_extension_works() {
// alith mapped native address should ALICE
assert_eq!(
call_wasm_contract_method::<Option<AccountId>>(
ALICE,
contract_id.clone(),
[GET_NATIVE.to_vec(), alith().encode()].concat()
),
Expand Down

0 comments on commit 66c6235

Please sign in to comment.