receiver amount to existential deposit in benchmarks
Signed-off-by: Uncle Stretch <uncle.stretch@ghostchain.io>
This commit is contained in:
parent
aa336d9c55
commit
9f5a214cd5
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ghost-weaver"
|
||||
version = "0.0.11"
|
||||
version = "0.0.12"
|
||||
description = "Weaving a secure cryptographic tapestry across different external chains."
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
use super::*;
|
||||
use frame_benchmarking::v2::*;
|
||||
use frame_system::RawOrigin;
|
||||
use sp_runtime::traits::Saturating;
|
||||
use sp_std::vec;
|
||||
|
||||
use ghost_helpers::networks::NetworkDataBuilder;
|
||||
@ -144,6 +145,17 @@ mod benchmarks {
|
||||
let max_history_depth = a as usize;
|
||||
let (network_id, _, _) = prepare_pallet::<T>(1, None);
|
||||
|
||||
let expected_receiver_bytes = hex::decode("1657090d02985f0cdb41436fe2d5a83a3acb1995d963a698e7e619e927bdcc5e").unwrap();
|
||||
let mut receiver_raw = [0u8; 32];
|
||||
receiver_raw.copy_from_slice(&expected_receiver_bytes);
|
||||
|
||||
let transfer_amount: u64 = 153348847;
|
||||
let receiver = T::AccountId::decode(&mut &receiver_raw[..])
|
||||
.expect("32-byte array must cleanly decode into T::AccountId");
|
||||
|
||||
let existential_deposit = <T as Config>::Currency::minimum_balance();
|
||||
<T as Config>::Currency::set_balance(&receiver, existential_deposit);
|
||||
|
||||
// Real world tx at block #481838
|
||||
// Block https://blockstream.info/block/0000000000000000011bdccb39e19e942a60edffdccd9779653c5b46b337904a
|
||||
// Transaction: https://blockstream.info/tx/4a3fdd9ebb30b9c6df05d4199f8474b2f0c795d1f40a58d0d73342fc666b4a2e
|
||||
@ -322,11 +334,16 @@ mod benchmarks {
|
||||
let pulled_thread_key = thread_proof.get_unique_key(session, network_id);
|
||||
|
||||
assert!(!PulledThreads::<T>::contains_key(&pulled_thread_key));
|
||||
assert_eq!(T::Currency::balance(&receiver), existential_deposit);
|
||||
|
||||
#[extrinsic_call]
|
||||
pull_thread(RawOrigin::None, network_id, session, thread_proof);
|
||||
|
||||
let final_amount = existential_deposit.saturating_add(
|
||||
transfer_amount.unique_saturated_into()
|
||||
);
|
||||
assert!(PulledThreads::<T>::contains_key(&pulled_thread_key));
|
||||
assert_eq!(T::Currency::balance(&receiver), final_amount);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@ -352,8 +369,13 @@ mod benchmarks {
|
||||
.try_into()
|
||||
.expect("Hex string must be exactly 32 bytes long");
|
||||
|
||||
let receiver_account = sp_runtime::AccountId32::from(receiver_32);
|
||||
let transfer_amount: BalanceOf<T> = 420u64.unique_saturated_into();
|
||||
let receiver_account = sp_runtime::AccountId32::from(receiver_32);
|
||||
let receiver_account_t = T::AccountId::decode(&mut &receiver_32[..])
|
||||
.expect("32-byte array must cleanly decode into T::AccountId");
|
||||
|
||||
let existential_deposit = <T as Config>::Currency::minimum_balance();
|
||||
<T as Config>::Currency::set_balance(&receiver_account_t, existential_deposit);
|
||||
|
||||
let proof = vec![
|
||||
H256::from_slice(&hex::decode("7d831a4be9e37572687117870c3f96669a66bf07971e4fd705a36a0a4d6365b0").expect("Proof should be valid")),
|
||||
@ -370,7 +392,7 @@ mod benchmarks {
|
||||
.expect("Slot should be valid hex"),
|
||||
)];
|
||||
|
||||
let evm_thread_proof = EvmThreadProof::new(0, 1, receiver_account, transfer_amount, proof, slots);
|
||||
let evm_thread_proof = EvmThreadProof::new(0, 1, receiver_account.into(), transfer_amount, proof, slots);
|
||||
|
||||
let thread_proof = ThreadProof::EvmThreadProof(evm_thread_proof);
|
||||
let pulled_thread_key = thread_proof.get_unique_key(session, network_id);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user