From 8e66f509b0df8d0120c5e3b2413eaf3580a1866d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Bald=C3=A9?= Date: Tue, 17 Dec 2024 18:00:28 +0000 Subject: [PATCH] Fix tests in `exec::tests` In particular, this commit removes the usage of `0` as unlimited metering in the following tests: - `nonce` - `last_frame_output_works_on_instantiate` - `instantiation_from_contract` - `immutable_data_set_works_only_once` - `immutable_data_set_errors_with_empty_data` - `immutable_data_access_checks_work` --- substrate/frame/revive/src/exec.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/substrate/frame/revive/src/exec.rs b/substrate/frame/revive/src/exec.rs index 5e1474859d8d..efd9e8e41462 100644 --- a/substrate/frame/revive/src/exec.rs +++ b/substrate/frame/revive/src/exec.rs @@ -3098,8 +3098,8 @@ mod tests { let (address, output) = ctx .ext .instantiate( - Weight::zero(), - U256::zero(), + Weight::MAX, + U256::from(u64::MAX), dummy_ch, ::Currency::minimum_balance().into(), vec![], @@ -3802,8 +3802,8 @@ mod tests { let succ_fail_code = MockLoader::insert(Constructor, move |ctx, _| { ctx.ext .instantiate( - Weight::zero(), - U256::zero(), + Weight::MAX, + U256::from(u64::MAX), fail_code, ctx.ext.minimum_balance() * 100, vec![], @@ -3819,8 +3819,8 @@ mod tests { let addr = ctx .ext .instantiate( - Weight::zero(), - U256::zero(), + Weight::MAX, + U256::from(u64::MAX), success_code, ctx.ext.minimum_balance() * 100, vec![], @@ -4597,7 +4597,7 @@ mod tests { // Successful instantiation should set the output let address = ctx .ext - .instantiate(Weight::zero(), U256::zero(), ok_ch, value, vec![], None) + .instantiate(Weight::MAX, U256::from(u64::MAX), ok_ch, value, vec![], None) .unwrap(); assert_eq!( ctx.ext.last_frame_output(), @@ -4607,8 +4607,8 @@ mod tests { // Balance transfers should reset the output ctx.ext .call( - Weight::zero(), - U256::zero(), + Weight::MAX, + U256::from(u64::MAX), &address, U256::from(1), vec![], @@ -4827,7 +4827,7 @@ mod tests { // Constructors can not access the immutable data ctx.ext - .instantiate(Weight::zero(), U256::zero(), dummy_ch, value, vec![], None) + .instantiate(Weight::MAX, U256::from(u64::MAX), dummy_ch, value, vec![], None) .unwrap(); exec_success() @@ -4944,7 +4944,7 @@ mod tests { move |ctx, _| { let value = ::Currency::minimum_balance().into(); ctx.ext - .instantiate(Weight::zero(), U256::zero(), dummy_ch, value, vec![], None) + .instantiate(Weight::MAX, U256::from(u64::MAX), dummy_ch, value, vec![], None) .unwrap(); exec_success() @@ -4989,7 +4989,7 @@ mod tests { move |ctx, _| { let value = ::Currency::minimum_balance().into(); ctx.ext - .instantiate(Weight::zero(), U256::zero(), dummy_ch, value, vec![], None) + .instantiate(Weight::MAX, U256::from(u64::MAX), dummy_ch, value, vec![], None) .unwrap(); exec_success()