Skip to content

Commit

Permalink
Fix benchmarking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ekovalev committed May 27, 2024
1 parent d4cab90 commit 4f41138
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions pallets/gear/src/benchmarking/tests/syscalls_integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use gear_core::ids::{CodeId, ReservationId};
use gear_core_errors::{ReplyCode, SuccessReplyReason};
use gear_wasm_instrument::syscalls::SyscallName;
use pallet_timestamp::Pallet as TimestampPallet;
use parity_scale_codec::{Decode, Encode};
use parity_scale_codec::{Decode, Encode, FullCodec};
use test_syscalls::{Kind, WASM_BINARY as SYSCALLS_TEST_WASM_BINARY};

pub fn read_big_state<T>()
Expand Down Expand Up @@ -600,13 +600,15 @@ where
next_user_mid,
);

let mp = vec![Kind::CreateProgram(
salt,
gas,
(expected_mid.into(), expected_pid.into()),
)]
.encode()
.into();
let mp = MessageParamsBuilder::new(
vec![Kind::CreateProgram(
salt,
gas,
(expected_mid.into(), expected_pid.into()),
)]
.encode(),
)
.with_value(CurrencyOf::<T>::minimum_balance().unique_saturated_into());

(TestCall::send_message(mp), None::<DefaultPostCheck>)
});
Expand Down Expand Up @@ -1044,7 +1046,7 @@ where
T: Config + frame_system::Config<AccountId = Id>,
// T::AccountId: Origin,
T::RuntimeOrigin: From<RawOrigin<Id>>,
Id: Clone + Origin,
Id: Clone + Origin + FullCodec,
// Post check
P: FnOnce(),
// Get syscall and post check
Expand All @@ -1056,6 +1058,7 @@ where
let child_wasm = simplest_gear_wasm::<T>();
let child_code = child_wasm.code;
let child_code_hash = child_wasm.hash;
let child_pid = ProgramId::generate_from_user(child_code_hash, b"");

let tester_pid =
ProgramId::generate_from_user(CodeId::generate(SYSCALLS_TEST_WASM_BINARY), b"");
Expand Down Expand Up @@ -1140,10 +1143,13 @@ where

// Manually reset the storage
Gear::<T>::reset();
let tester_account_id = tester_pid.cast();
let _ = CurrencyOf::<T>::slash(
&tester_pid.cast(),
CurrencyOf::<T>::free_balance(&tester_pid.cast()),
&tester_account_id,
CurrencyOf::<T>::free_balance(&tester_account_id),
);
frame_system::pallet::Account::<T>::remove(tester_account_id);
frame_system::pallet::Account::<T>::remove(child_pid.cast::<T::AccountId>());
}

type DefaultPostCheck = fn() -> ();
Expand Down

0 comments on commit 4f41138

Please sign in to comment.