mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 04:41:04 +00:00
Fix runtime benchmarks CI (#6545)
* debug (ci): ci config [skip ci] * debug (ci): fix runtime benchmarks * fix identity benchmarks * fix utility benchmarks * Revert "debug (ci): ci config [skip ci]" This reverts commit 081b175b5e95604520c79ea4e5822b84ea35ddaa. * change (ci): touch ci config to run CI Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Gav Wood <gavin@parity.io>
This commit is contained in:
@@ -263,7 +263,7 @@ test-wasmtime:
|
|||||||
variables:
|
variables:
|
||||||
<<: *default-vars
|
<<: *default-vars
|
||||||
# Enable debug assertions since we are running optimized builds for testing
|
# Enable debug assertions since we are running optimized builds for testing
|
||||||
# but still want to have debug assertions.
|
# but still want to have debug assertions.
|
||||||
RUSTFLAGS: -Cdebug-assertions=y
|
RUSTFLAGS: -Cdebug-assertions=y
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
except:
|
except:
|
||||||
@@ -289,7 +289,7 @@ test-runtime-benchmarks:
|
|||||||
- $DEPLOY_TAG
|
- $DEPLOY_TAG
|
||||||
script:
|
script:
|
||||||
- cd bin/node/cli
|
- cd bin/node/cli
|
||||||
- WASM_BUILD_NO_COLOR=1 time cargo test --release --verbose --features runtime-benchmarks
|
- WASM_BUILD_NO_COLOR=1 time cargo test --workspace --release --verbose --features runtime-benchmarks
|
||||||
- sccache -s
|
- sccache -s
|
||||||
|
|
||||||
test-linux-stable-int:
|
test-linux-stable-int:
|
||||||
|
|||||||
@@ -1151,7 +1151,7 @@ mod tests {
|
|||||||
ord_parameter_types,
|
ord_parameter_types,
|
||||||
};
|
};
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use frame_system::EnsureSignedBy;
|
use frame_system::{EnsureSignedBy, EnsureOneOf, EnsureRoot};
|
||||||
// The testing primitives are very useful for avoiding having to work with signatures
|
// The testing primitives are very useful for avoiding having to work with signatures
|
||||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -1221,6 +1221,16 @@ mod tests {
|
|||||||
pub const One: u64 = 1;
|
pub const One: u64 = 1;
|
||||||
pub const Two: u64 = 2;
|
pub const Two: u64 = 2;
|
||||||
}
|
}
|
||||||
|
type EnsureOneOrRoot = EnsureOneOf<
|
||||||
|
u64,
|
||||||
|
EnsureRoot<u64>,
|
||||||
|
EnsureSignedBy<One, u64>
|
||||||
|
>;
|
||||||
|
type EnsureTwoOrRoot = EnsureOneOf<
|
||||||
|
u64,
|
||||||
|
EnsureRoot<u64>,
|
||||||
|
EnsureSignedBy<Two, u64>
|
||||||
|
>;
|
||||||
impl Trait for Test {
|
impl Trait for Test {
|
||||||
type Event = ();
|
type Event = ();
|
||||||
type Currency = Balances;
|
type Currency = Balances;
|
||||||
@@ -1231,8 +1241,8 @@ mod tests {
|
|||||||
type MaxSubAccounts = MaxSubAccounts;
|
type MaxSubAccounts = MaxSubAccounts;
|
||||||
type MaxAdditionalFields = MaxAdditionalFields;
|
type MaxAdditionalFields = MaxAdditionalFields;
|
||||||
type MaxRegistrars = MaxRegistrars;
|
type MaxRegistrars = MaxRegistrars;
|
||||||
type RegistrarOrigin = EnsureSignedBy<One, u64>;
|
type RegistrarOrigin = EnsureOneOrRoot;
|
||||||
type ForceOrigin = EnsureSignedBy<Two, u64>;
|
type ForceOrigin = EnsureTwoOrRoot;
|
||||||
}
|
}
|
||||||
type System = frame_system::Module<Test>;
|
type System = frame_system::Module<Test>;
|
||||||
type Balances = pallet_balances::Module<Test>;
|
type Balances = pallet_balances::Module<Test>;
|
||||||
|
|||||||
@@ -20,11 +20,19 @@
|
|||||||
#![cfg(feature = "runtime-benchmarks")]
|
#![cfg(feature = "runtime-benchmarks")]
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use frame_system::RawOrigin;
|
use frame_system::{RawOrigin, EventRecord};
|
||||||
use frame_benchmarking::{benchmarks, account};
|
use frame_benchmarking::{benchmarks, account};
|
||||||
|
|
||||||
const SEED: u32 = 0;
|
const SEED: u32 = 0;
|
||||||
|
|
||||||
|
fn assert_last_event<T: Trait>(generic_event: <T as Trait>::Event) {
|
||||||
|
let events = frame_system::Module::<T>::events();
|
||||||
|
let system_event: <T as frame_system::Trait>::Event = generic_event.into();
|
||||||
|
// compare to the last event record
|
||||||
|
let EventRecord { event, .. } = &events[events.len() - 1];
|
||||||
|
assert_eq!(event, &system_event);
|
||||||
|
}
|
||||||
|
|
||||||
benchmarks! {
|
benchmarks! {
|
||||||
_ { }
|
_ { }
|
||||||
|
|
||||||
@@ -37,6 +45,9 @@ benchmarks! {
|
|||||||
}
|
}
|
||||||
let caller = account("caller", 0, SEED);
|
let caller = account("caller", 0, SEED);
|
||||||
}: _(RawOrigin::Signed(caller), calls)
|
}: _(RawOrigin::Signed(caller), calls)
|
||||||
|
verify {
|
||||||
|
assert_last_event::<T>(Event::BatchCompleted.into())
|
||||||
|
}
|
||||||
|
|
||||||
as_derivative {
|
as_derivative {
|
||||||
let u in 0 .. 1000;
|
let u in 0 .. 1000;
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ impl Filter<Call> for TestBaseCallFilter {
|
|||||||
fn filter(c: &Call) -> bool {
|
fn filter(c: &Call) -> bool {
|
||||||
match *c {
|
match *c {
|
||||||
Call::Balances(_) => true,
|
Call::Balances(_) => true,
|
||||||
|
// For benchmarking, this acts as a noop call
|
||||||
|
Call::System(frame_system::Call::remark(..)) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,7 +165,7 @@ fn as_derivative_filters() {
|
|||||||
assert_noop!(Utility::as_derivative(
|
assert_noop!(Utility::as_derivative(
|
||||||
Origin::signed(1),
|
Origin::signed(1),
|
||||||
1,
|
1,
|
||||||
Box::new(Call::System(frame_system::Call::remark(vec![]))),
|
Box::new(Call::System(frame_system::Call::suicide())),
|
||||||
), DispatchError::BadOrigin);
|
), DispatchError::BadOrigin);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -208,7 +210,7 @@ fn batch_with_signed_filters() {
|
|||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_ok!(
|
assert_ok!(
|
||||||
Utility::batch(Origin::signed(1), vec![
|
Utility::batch(Origin::signed(1), vec![
|
||||||
Call::System(frame_system::Call::remark(vec![]))
|
Call::System(frame_system::Call::suicide())
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
expect_event(Event::BatchInterrupted(0, DispatchError::BadOrigin));
|
expect_event(Event::BatchInterrupted(0, DispatchError::BadOrigin));
|
||||||
|
|||||||
Reference in New Issue
Block a user