mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-18 17:35:42 +00:00
Contracts upload with Determinism::Enforced when possible (#3540)
Co-authored-by: Cyrill Leutwiler <cyrill@parity.io> Co-authored-by: command-bot <> Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -5185,6 +5185,26 @@ fn deposit_limit_honors_min_leftover() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upload_should_enforce_deterministic_mode_when_possible() {
|
||||
let upload = |fixture, determinism| {
|
||||
let (wasm, code_hash) = compile_module::<Test>(fixture).unwrap();
|
||||
ExtBuilder::default()
|
||||
.build()
|
||||
.execute_with(|| -> Result<Determinism, DispatchError> {
|
||||
let _ = <Test as Config>::Currency::set_balance(&ALICE, 1_000_000);
|
||||
Contracts::bare_upload_code(ALICE, wasm, None, determinism)?;
|
||||
let info = CodeInfoOf::<Test>::get(code_hash).unwrap();
|
||||
Ok(info.determinism())
|
||||
})
|
||||
};
|
||||
|
||||
assert_eq!(upload("dummy", Determinism::Enforced), Ok(Determinism::Enforced));
|
||||
assert_eq!(upload("dummy", Determinism::Relaxed), Ok(Determinism::Enforced));
|
||||
assert_eq!(upload("float_instruction", Determinism::Relaxed), Ok(Determinism::Relaxed));
|
||||
assert!(upload("float_instruction", Determinism::Enforced).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cannot_instantiate_indeterministic_code() {
|
||||
let (wasm, code_hash) = compile_module::<Test>("float_instruction").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user