2

Trying to benchmark an extrinsic, but I keep getting error:

./target/release/rmrk-substrate benchmark --pallet pallet-rmrk-core --extrinsic 'create_collection'
Error: Input("InsufficientBalance")

Here's the code:

benchmarks! {
    create_collection {
        let origin: T::AccountId = whitelisted_caller();
        T::Currency::make_free_balance_be(&origin, T::Currency::minimum_balance() * 20_000_000u32.into());
    }: _(RawOrigin::Signed(origin), bvec![0u8; 20], Some(5), bvec![0u8; 15])
    verify {
    }
    impl_benchmark_test_suite!(Template, crate::mock::ExtBuilder::default().build(whitelisted_caller()), crate::mock::Test);
}

I've tried various manipulations of the T::Currency::make_free_balance_be line, without success. The code compiles successfully with cargo build --release --features runtime-benchmarks, but still fails on this extrinsic.

This is my first attempt at benchmarking. Likely something simple.

1 Answer 1

3

Turns out it was due to insufficient balance. I needed to change the code to:

T::Currency::make_free_balance_be(&origin, DepositBalanceOf::<T>::max_value());

Where DepositBalanceOf is (for me at least):

type DepositBalanceOf<T> = <<T as pallet_uniques::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
1
  • In my case, I also needed to remember to use the Currency trait. For some reason, it did not error out.
    – Yatusabes
    Jan 11 at 19:52

Your Answer

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

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