I would like to avoid the most pallet config initialisation and just want to use the actual runtime configuration for the (unit) tests. This would simplify my mock process a lot. The only thing that comes into mind is to mock the balances.

So I need to implement ExtBuilder. The reason to take this approach is because I always need to copy stuff from my actual runtime to the mock, but in my case it's always the same configuration.

1 Answer 1


It is important to have the mock.rs inside the runtime folder. Then you can just import all runtime parameters with use crate::*; inside the mock.rs.

Just found out that I can just use Runtime instead of Test as a generic to all instances of the test and mock. In addition to that, you need to create Accounts as actual accounts and not just numbers.

use sp_core::{sr25519, Pair, Public, H256};
use sp_runtime::traits::{IdentifyAccount, Verify};

type AccountPublic = <Signature as Verify>::Signer;

/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
    TPublic::Pair::from_string(&format!("//{seed}"), None)
        .expect("static values are valid; qed")

/// Helper function to generate an account ID from seed
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
    AccountPublic: From<<TPublic::Pair as Pair>::Public>,

pub fn alice() -> AccountId {

pub fn bob() -> AccountId {

pub fn charlie() -> AccountId {

pub fn dave() -> AccountId {

pub fn eva() -> AccountId {

pub fn fred() -> AccountId {

You can leave the ExtBuilder as it is. It just builds the execution environment with the actual runtime as a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.