I have written tests.rs and mock.rs

everything is working except a function which has checks for root

    pub fn create_something(
        origin: OriginFor<T>,
        org: T::Hash
    ) -> DispatchResult {
        // TODO: ensure origin == controller

My test something like:

assert_ok!(MyVeryFirstModuleModule::create_something(Origin::signed(ALICE), H256::random()));

If I don't comment ensure_root I am getting Bad_Origin panic. How can I mock root?

1 Answer 1


If this is for tests, have you tried using:


Example here:

assert_ok!(Balances::set_balance(RuntimeOrigin::root(), 1, 1_000, 0));

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.