I am trying Substrate official off-chain example. I am throwing a DispatchError in my extrinsic.
#[pallet::call_index(0)]
#[pallet::weight({0})]
pub fn submit_price(origin: OriginFor<T>, is_ocw: bool) -> DispatchResultWithPostInfo {
// Retrieve sender of the transaction.
let who = ensure_signed(origin)?;
ensure!(true == false, Error::<T>::NoneValue);
// Add the price to the on-chain list.
Self::add_price(Some(who), price);
Ok(().into())
}
Here is off-chain worker code:
fn offchain_worker(_block_number: BlockNumberFor<T>) {
log::info!("Hello from pallet-ocw.");
let signer = Signer::<T, T::AuthorityId>::all_accounts();
if !signer.can_sign() {
log::error!("No local accounts available");
return
}
let results = signer.send_signed_transaction(|_account| {
Call:: submit_price { is_ocw: true }
});
for (acc, res) in &results {
match res {
Ok(()) => log::info!("Executed Successfully: {:?}", acc.id),
Err(e) => log::error!("[{:?}] Failed to submit transaction: {:?}", acc.id, e),
}
}
}
It always prints Executed Successfully
. Ideally it should print error log. Please let me know if I am missing anything.