mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 23:57:56 +00:00
contracts: Get rid of the dreaded Other error (#10595)
* Print more detailed error when instrumentation fails * Apply suggestions from code review Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * Check contents of debug buffer * Fix test Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8aefbb9f2f
commit
89194f0e70
@@ -1386,7 +1386,7 @@ fn disabled_chain_extension_wont_deploy() {
|
||||
vec![],
|
||||
vec![],
|
||||
),
|
||||
"module uses chain extensions but chain extensions are disabled",
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -2903,3 +2903,32 @@ fn contract_reverted() {
|
||||
assert_eq!(result.data.0, buffer);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn code_rejected_error_works() {
|
||||
let (wasm, _) = compile_module::<Test>("invalid_import").unwrap();
|
||||
ExtBuilder::default().existential_deposit(200).build().execute_with(|| {
|
||||
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
|
||||
|
||||
assert_noop!(
|
||||
Contracts::upload_code(Origin::signed(ALICE), wasm.clone(), None),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
|
||||
let result = Contracts::bare_instantiate(
|
||||
ALICE,
|
||||
0,
|
||||
GAS_LIMIT,
|
||||
None,
|
||||
Code::Upload(Bytes(wasm)),
|
||||
vec![],
|
||||
vec![],
|
||||
true,
|
||||
);
|
||||
assert_err!(result.result, <Error<Test>>::CodeRejected);
|
||||
assert_eq!(
|
||||
std::str::from_utf8(&result.debug_message).unwrap(),
|
||||
"module imports a non-existent function"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user