contracts: Run start function (#1367)

Fixes #116 

Start function wasn't allowed in a contract. Now it is allowed and is
being run.

It was disallowed because it is not used by Rust and supporting it made
the code more complex. However, not running the start function violates
the wasm standard. This makes life harder for some languages (see linked
ticket).
This commit is contained in:
Alexander Theißen
2023-09-11 22:45:18 +02:00
committed by GitHub
parent 44dbb73945
commit c879d1d582
6 changed files with 197 additions and 171 deletions
+21
View File
@@ -862,6 +862,27 @@ fn deposit_event_max_value_limit() {
});
}
// Fail out of fuel (ref_time weight) inside the start function.
#[test]
fn run_out_of_fuel_start_fun() {
let (wasm, _code_hash) = compile_module::<Test>("run_out_of_gas_start_fn").unwrap();
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
let _ = <Test as Config>::Currency::set_balance(&ALICE, 1_000_000);
assert_err_ignore_postinfo!(
Contracts::instantiate_with_code(
RuntimeOrigin::signed(ALICE),
0,
Weight::from_parts(1_000_000_000_000, u64::MAX),
None,
wasm,
vec![],
vec![],
),
Error::<Test>::OutOfGas,
);
});
}
// Fail out of fuel (ref_time weight) in the engine.
#[test]
fn run_out_of_fuel_engine() {