Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pallets/mining-rewards/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use frame_support::{
parameter_types,
traits::{ConstU32, Everything, Hooks},
};
use pallet_treasury;
use qp_poseidon::PoseidonHasher;
use sp_consensus_pow::POW_ENGINE_ID;
use sp_runtime::{
Expand Down
5 changes: 0 additions & 5 deletions pallets/multisig/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,3 @@ std = [
"sp-io/std",
"sp-runtime/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
25 changes: 23 additions & 2 deletions pallets/multisig/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ use frame_support::{traits::fungible::Mutate, BoundedBTreeMap};

const SEED: u32 = 0;

/// Multisig address used by the `propose_high_security` benchmark (signer1+signer2+caller).
/// Exposed so the mock `HighSecurity` can treat it as HS in unit tests.
#[cfg(any(test, feature = "runtime-benchmarks"))]
#[allow(dead_code)]
pub fn propose_high_security_benchmark_multisig_address<T>() -> T::AccountId
where
T: Config + pallet_balances::Config,
BalanceOf2<T>: From<u128>,
{
use frame_benchmarking::v2::{account, whitelisted_caller};
let caller: T::AccountId = whitelisted_caller();
let signer1: T::AccountId = account("signer1", 0, SEED);
let signer2: T::AccountId = account("signer2", 1, SEED);
let mut signers = vec![caller, signer1, signer2];
signers.sort();
Multisig::<T>::derive_multisig_address(&signers, 2, 0)
}

// Helper to fund an account
type BalanceOf2<T> = <T as pallet_balances::Config>::Balance;

Expand Down Expand Up @@ -113,6 +131,7 @@ mod benchmarks {
}

/// Insert a single proposal into storage. `approvals` = list of account ids that have approved.
#[allow(clippy::too_many_arguments)]
fn insert_proposal<T: Config>(
multisig_address: &T::AccountId,
proposal_id: u32,
Expand Down Expand Up @@ -202,11 +221,13 @@ mod benchmarks {

/// Benchmark `propose` for high-security multisigs.
/// Uses signer1/signer2 so multisig address matches genesis (ReversibleTransfers::
/// initial_high_security_accounts). HighSecurityAccounts::contains_key reads from trie.
/// initial_high_security_accounts) or mock's HighSecurity (unit tests).
/// Uses whitelisted call (remark "safe") so HS path accepts it.
#[benchmark]
fn propose_high_security(
c: Linear<0, { T::MaxCallSize::get().saturating_sub(100) }>,
) -> Result<(), BenchmarkError> {
let _ = c;
let (caller, signers) = setup_funded_signer_set_hs::<T>();
let threshold = 2u32;
let multisig_address = insert_multisig::<T>(&caller, &signers, threshold, 0, 0, 0);
Expand All @@ -216,7 +237,7 @@ mod benchmarks {
);
set_block::<T>(100);

let new_call = frame_system::Call::<T>::remark { remark: vec![99u8; c as usize] };
let new_call = frame_system::Call::<T>::remark { remark: b"safe".to_vec() };
let encoded_call = <T as Config>::RuntimeCall::from(new_call).encode();
let expiry = frame_system::Pallet::<T>::block_number() + 1000u32.into();

Expand Down
Empty file removed pallets/multisig/src/migration.rs
Empty file.
10 changes: 9 additions & 1 deletion pallets/multisig/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ pub struct MockHighSecurity;
impl HighSecurityInspector<AccountId32, RuntimeCall> for MockHighSecurity {
fn is_high_security(who: &AccountId32) -> bool {
// For testing, account 100 is high security
who == &account_id(100)
if who == &account_id(100) {
return true;
}
// So that bench_propose_high_security passes (mock has no ReversibleTransfers genesis)
#[cfg(feature = "runtime-benchmarks")]
if who == &crate::benchmarking::propose_high_security_benchmark_multisig_address::<Test>() {
return true;
}
false
}
fn is_whitelisted(call: &RuntimeCall) -> bool {
// For testing, only remarks with "safe" are whitelisted
Expand Down
101 changes: 49 additions & 52 deletions pallets/treasury/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,58 +1,55 @@
#[cfg(test)]
mod tests {
use crate::{
mock::{account_id, new_test_ext, Test, Treasury},
Error,
};
use frame_support::{assert_err, assert_ok};
use crate::{
mock::{account_id, new_test_ext, Test, Treasury},
Error,
};
use frame_support::{assert_err, assert_ok};

#[test]
fn genesis_sets_treasury_config() {
new_test_ext().execute_with(|| {
assert_eq!(Treasury::account_id(), account_id(1));
assert_eq!(Treasury::portion(), 50);
});
}
#[test]
fn genesis_sets_treasury_config() {
new_test_ext().execute_with(|| {
assert_eq!(Treasury::account_id(), account_id(1));
assert_eq!(Treasury::portion(), 50);
});
}

#[test]
fn set_treasury_account_works() {
new_test_ext().execute_with(|| {
assert_ok!(Treasury::set_treasury_account(
frame_system::RawOrigin::Root.into(),
account_id(99)
));
assert_eq!(Treasury::account_id(), account_id(99));
});
}
#[test]
fn set_treasury_account_works() {
new_test_ext().execute_with(|| {
assert_ok!(Treasury::set_treasury_account(
frame_system::RawOrigin::Root.into(),
account_id(99)
));
assert_eq!(Treasury::account_id(), account_id(99));
});
}

#[test]
fn set_treasury_account_requires_root() {
new_test_ext().execute_with(|| {
assert_err!(
Treasury::set_treasury_account(
frame_system::RawOrigin::Signed(account_id(1)).into(),
account_id(99)
),
sp_runtime::DispatchError::BadOrigin
);
});
}
#[test]
fn set_treasury_account_requires_root() {
new_test_ext().execute_with(|| {
assert_err!(
Treasury::set_treasury_account(
frame_system::RawOrigin::Signed(account_id(1)).into(),
account_id(99)
),
sp_runtime::DispatchError::BadOrigin
);
});
}

#[test]
fn set_treasury_portion_works() {
new_test_ext().execute_with(|| {
assert_ok!(Treasury::set_treasury_portion(frame_system::RawOrigin::Root.into(), 30));
assert_eq!(Treasury::portion(), 30);
});
}
#[test]
fn set_treasury_portion_works() {
new_test_ext().execute_with(|| {
assert_ok!(Treasury::set_treasury_portion(frame_system::RawOrigin::Root.into(), 30));
assert_eq!(Treasury::portion(), 30);
});
}

#[test]
fn set_treasury_portion_rejects_invalid() {
new_test_ext().execute_with(|| {
assert_err!(
Treasury::set_treasury_portion(frame_system::RawOrigin::Root.into(), 101),
Error::<Test>::InvalidPortion
);
});
}
#[test]
fn set_treasury_portion_rejects_invalid() {
new_test_ext().execute_with(|| {
assert_err!(
Treasury::set_treasury_portion(frame_system::RawOrigin::Root.into(), 101),
Error::<Test>::InvalidPortion
);
});
}
1 change: 0 additions & 1 deletion pallets/wormhole/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,3 @@ std = [
"sp-io/std",
"sp-runtime/std",
]
try-runtime = ["frame-support/try-runtime", "frame-system/try-runtime"]
4 changes: 1 addition & 3 deletions pallets/wormhole/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ mod benchmarks {

// Extract values from aggregated public inputs
let block_number_u32 = aggregated_inputs.block_data.block_number;
let block_hash_bytes: [u8; 32] = (*aggregated_inputs.block_data.block_hash)
.try_into()
.map_err(|_| BenchmarkError::Stop("Invalid block hash length"))?;
let block_hash_bytes = *aggregated_inputs.block_data.block_hash;

// Ensure nullifiers haven't been used
for nullifier in &aggregated_inputs.nullifiers {
Expand Down
1 change: 0 additions & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ try-runtime = [
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-wormhole/try-runtime",
"sp-runtime/try-runtime",
]

Expand Down
9 changes: 3 additions & 6 deletions runtime/tests/governance/tech_collective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ mod tests {
use quantus_runtime::configs::TechReferendaInstance;

use quantus_runtime::{
Balances, OriginCaller, Preimage, Runtime, RuntimeCall, RuntimeOrigin, System,
TechCollective, TechReferenda, UNIT,
Balances, OriginCaller, Preimage, Runtime, RuntimeCall, RuntimeOrigin, TechCollective,
TechReferenda, UNIT,
};

use sp_runtime::{
traits::{AccountIdConversion, Hash, StaticLookup},
MultiAddress,
};
use sp_runtime::{traits::Hash, MultiAddress};

const TRACK_ID: u16 = 0;

Expand Down
Loading