mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 06:51:07 +00:00
Generate Unit Tests for Benchmarks (#5527)
* Update to latest staking * generate tests for benchmarking * add tests, fix warnings * starting on democracy * impl_benchmark_tests * Way more readable * add test feature flag (does this work?) * Fix `successful_origin` impl * democracry benchmark tests * Fix example benchmarks, add tests * identity benchmark tests * Update im-online benchmark tests * try to add session benchmarking tests (problem with mock) * staking and timestamp * add test for treasury, issue with dynamic contains * utility * Vesting * test instead of check * hide until we figure out what is wrong * add docs * close code * Create custom mock for session-pallet-benchmarking * Use refcell pattern * make un-pub * test-linux-stable includes `runtime-benchmarks` feature * Revert "test-linux-stable includes `runtime-benchmarks` feature" This reverts commit a2dab38abd18ac3eb8a6220e4a00e687740bd38c. * run tests in `--release` * undo balance change * build wasm
This commit is contained in:
@@ -445,3 +445,44 @@ benchmarks! {
|
||||
|
||||
}: _(RawOrigin::Signed(proxy), referendum_index)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::tests::{new_test_ext, Test};
|
||||
use frame_support::assert_ok;
|
||||
|
||||
#[test]
|
||||
fn test_benchmarks() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(test_benchmark_propose::<Test>());
|
||||
assert_ok!(test_benchmark_second::<Test>());
|
||||
assert_ok!(test_benchmark_vote::<Test>());
|
||||
assert_ok!(test_benchmark_proxy_vote::<Test>());
|
||||
assert_ok!(test_benchmark_emergency_cancel::<Test>());
|
||||
assert_ok!(test_benchmark_external_propose::<Test>());
|
||||
assert_ok!(test_benchmark_external_propose_majority::<Test>());
|
||||
assert_ok!(test_benchmark_external_propose_default::<Test>());
|
||||
assert_ok!(test_benchmark_fast_track::<Test>());
|
||||
assert_ok!(test_benchmark_veto_external::<Test>());
|
||||
assert_ok!(test_benchmark_cancel_referendum::<Test>());
|
||||
assert_ok!(test_benchmark_cancel_queued::<Test>());
|
||||
assert_ok!(test_benchmark_open_proxy::<Test>());
|
||||
assert_ok!(test_benchmark_activate_proxy::<Test>());
|
||||
assert_ok!(test_benchmark_close_proxy::<Test>());
|
||||
assert_ok!(test_benchmark_deactivate_proxy::<Test>());
|
||||
assert_ok!(test_benchmark_delegate::<Test>());
|
||||
assert_ok!(test_benchmark_undelegate::<Test>());
|
||||
assert_ok!(test_benchmark_clear_public_proposals::<Test>());
|
||||
assert_ok!(test_benchmark_note_preimage::<Test>());
|
||||
assert_ok!(test_benchmark_note_imminent_preimage::<Test>());
|
||||
assert_ok!(test_benchmark_reap_preimage::<Test>());
|
||||
assert_ok!(test_benchmark_unlock::<Test>());
|
||||
assert_ok!(test_benchmark_remove_vote::<Test>());
|
||||
assert_ok!(test_benchmark_remove_other_vote::<Test>());
|
||||
assert_ok!(test_benchmark_proxy_delegate::<Test>());
|
||||
assert_ok!(test_benchmark_proxy_undelegate::<Test>());
|
||||
assert_ok!(test_benchmark_proxy_remove_vote::<Test>());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +126,8 @@ impl Contains<u64> for OneToFive {
|
||||
fn sorted_members() -> Vec<u64> {
|
||||
vec![1, 2, 3, 4, 5]
|
||||
}
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn add(_m: &u64) {}
|
||||
}
|
||||
thread_local! {
|
||||
static PREIMAGE_BYTE_DEPOSIT: RefCell<u64> = RefCell::new(0);
|
||||
@@ -162,7 +164,7 @@ impl super::Trait for Test {
|
||||
type Scheduler = Scheduler;
|
||||
}
|
||||
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
pallet_balances::GenesisConfig::<Test>{
|
||||
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
|
||||
|
||||
Reference in New Issue
Block a user