As far as I could understand so far there is no a "normal" way to test extrinsics submitted by an Offchain Worker, rather a substitute transaction pool is involved. However it is possible to inspect a state of this fake tx pool that contains entities encoded to raw bytes. My question concerns submission of an unsigned extrinsic with a signed payload. In my case there is only one kind of extrinsic that the worker can submit. The following code verifies that the tx is submitted (the assertion of transaction collection length passes), however it fails to SCALE-decode the call.

    ext.execute_with(|| {
        assert_eq!(pool_state.read().transactions.len(), 1);

        let mut tx = &pool_state.read().transactions[0];
        let call = Call::<Test>::decode(&mut &tx[..]).unwrap();
        // snip

My guess is that the transaction is padded with additional data before encoded. My question is how I could decode such an entity ? And if one more question is permitted, is there a canonical procedure of unit-testing things (like events, dispatch errors etc ) in Offchain Worker execution context ?


Your Answer

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