Skip to content

Commit

Permalink
Fix benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthamastro committed Jan 15, 2024
1 parent 01eb5ee commit d5f37bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pallets/thea/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sp-runtime = { default-features = false, workspace = true }
sp-std = { workspace = true, default-features = false }
polkadex-primitives = { workspace = true, default-features = false }
pallet-timestamp = { workspace = true, default-features = false }
pallet-balances = { workspace = true, default-features = false }
frame-benchmarking = { workspace = true, default-features = false, optional = true }
sp-core = { workspace = true, default-features = false, features = ["serde"] }
thea-primitives = { path = "../../primitives/thea", default-features = false }
Expand Down Expand Up @@ -49,10 +50,12 @@ std = [
"sp-io/std",
"polkadex-primitives/std",
"pallet-timestamp/std",
"pallet-balances/std",
"sp-core/std",
"frame-benchmarking?/std",
]
runtime-benchmarks = [
"pallet-balances/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
Expand Down
11 changes: 7 additions & 4 deletions pallets/thea/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

use super::*;
use frame_benchmarking::benchmarks;
use frame_support::BoundedVec;
use frame_support::{traits::fungible::Mutate, BoundedVec};
use frame_system::RawOrigin;
use parity_scale_codec::Decode;
use polkadex_primitives::UNIT_BALANCE;
Expand Down Expand Up @@ -52,10 +52,13 @@ benchmarks! {
let mut set: BoundedVec<<T as crate::Config>::TheaId, <T as crate::Config>::MaxAuthorities> = BoundedVec::with_bounded_capacity(1);
set.try_push(key).unwrap();
<Authorities::<T>>::insert(0, set);
}: _(RawOrigin::None, message, 100*UNIT_BALANCE)
let relayer: T::AccountId = T::AccountId::decode(&mut &[0u8; 32][..]).unwrap();
<T as pallet::Config>::Currency::mint_into(&relayer, (100000*UNIT_BALANCE).saturated_into()).unwrap();
}: _(RawOrigin::Signed(relayer), message, 10000*UNIT_BALANCE)
verify {
assert!(<IncomingNonce::<T>>::get(0) == 1);
assert!(<IncomingMessages::<T>>::iter().count() == 1);
// Nonce is updated only after execute_at number of blocks
assert_eq!(<IncomingNonce::<T>>::get(0),0);
assert_eq!(<IncomingMessages::<T>>::iter().count(), 0);
}

send_thea_message {
Expand Down

0 comments on commit d5f37bb

Please sign in to comment.