2

I am having a setup of relay chain and two parachains are connected to it, I was running some test cases and during that i encounter an error

thread 'test::collection_transfer_fails_for_nonexistent_collection' panicked at 'assertion failed: `(left == right)`
  left: `Err(Module(ModuleError { index: 7, error: [2, 0, 0, 0], message: Some("NoSuchCollectionId") }))`,
 right: `Err(Module(ModuleError { index: 6, error: [2, 0, 0, 0], message: Some("NoSuchCollectionId") }))`',

Here message is same on left and right side but the test fails due to difference in index.Could anyone help me in solving this issue.

1
  • I think the indices are different at index: 7, Aug 20 at 18:04

1 Answer 1

2

The index number is the index of the pallet in the runtime from which the error originated. So it looks like you are expecting the error NoSuchCollectionId from the pallet with index 7 and you are getting the NoSuchCollectionId from the pallet with index 6.

If you go to your Runtime file you can see which pallets have this index, for example in the substrate-pallet-template the pallet_balances has the index 10 and the pallet sudo the 15, see the code.

In your test you can check if you are receiving an error from another pallet, an example is in the Bounty pallet See the code:

type TreasuryError = pallet_treasury::Error<Test>;

assert_noop!(
            {
                #[allow(deprecated)]
                Treasury::propose_spend(RuntimeOrigin::signed(2), 100, 3)
            },
            TreasuryError::InsufficientProposersBalance,
);

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.