From 6a75d8796109ce57cbd2663099327c8c664086a7 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Fri, 14 Jul 2023 16:16:48 +0300 Subject: [PATCH] testing framework - renamed step methods --- .../adder_mandos_constructed_raw_test.rs | 6 +- ...dder_mandos_constructed_with_calls_test.rs | 4 +- .../crowdfunding_esdt_mandos_rust_test.rs | 20 +++--- .../multisig/tests/multisig_rust_test_v2.rs | 6 +- framework/scenario/src/facade.rs | 1 + .../src/facade/scenario_world_steps.rs | 51 +------------- .../facade/scenario_world_steps_deprecated.rs | 70 +++++++++++++++++++ 7 files changed, 92 insertions(+), 66 deletions(-) create mode 100644 framework/scenario/src/facade/scenario_world_steps_deprecated.rs diff --git a/contracts/examples/adder/tests/adder_mandos_constructed_raw_test.rs b/contracts/examples/adder/tests/adder_mandos_constructed_raw_test.rs index 169a8fd0ae..d647602355 100644 --- a/contracts/examples/adder/tests/adder_mandos_constructed_raw_test.rs +++ b/contracts/examples/adder/tests/adder_mandos_constructed_raw_test.rs @@ -21,20 +21,20 @@ fn adder_mandos_constructed_raw() { .put_account("address:owner", Account::new().nonce(1)) .new_address("address:owner", 1, "sc:adder"), ) - .sc_deploy_step( + .sc_deploy( ScDeployStep::new() .from("address:owner") .code(adder_code) .argument("5") .expect(TxExpect::ok().no_result()), ) - .sc_query_step( + .sc_query( ScQueryStep::new() .to("sc:adder") .function("getSum") .expect(TxExpect::ok().result("5")), ) - .sc_call_step( + .sc_call( ScCallStep::new() .from("address:owner") .to("sc:adder") diff --git a/contracts/examples/adder/tests/adder_mandos_constructed_with_calls_test.rs b/contracts/examples/adder/tests/adder_mandos_constructed_with_calls_test.rs index d214aeb994..0b6536aa32 100644 --- a/contracts/examples/adder/tests/adder_mandos_constructed_with_calls_test.rs +++ b/contracts/examples/adder/tests/adder_mandos_constructed_with_calls_test.rs @@ -36,13 +36,13 @@ fn adder_scenario_constructed_raw() { assert_eq!(new_address, adder_contract.to_address()); }, ) - .sc_query_step( + .sc_query( ScQueryStep::new() .to(&adder_contract) .call(adder_contract.sum()) .expect_value(SingleValue::from(BigUint::from(5u32))), ) - .sc_call_step( + .sc_call( ScCallStep::new() .from(owner_address) .to(&adder_contract) diff --git a/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_mandos_rust_test.rs b/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_mandos_rust_test.rs index 6c800a8159..d16f35a377 100644 --- a/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_mandos_rust_test.rs +++ b/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_mandos_rust_test.rs @@ -33,7 +33,7 @@ fn crowdfunding_scenario_rust_test() { .new_address(owner_addr, 0, &cf_sc), ); - world.sc_deploy_step( + world.sc_deploy( ScDeployStep::new() .from(owner_addr) .code(cf_code) @@ -58,7 +58,7 @@ fn crowdfunding_scenario_rust_test() { // first user deposit world - .sc_call_step( + .sc_call( ScCallStep::new() .from(first_user_addr) .to(&cf_sc) @@ -80,7 +80,7 @@ fn crowdfunding_scenario_rust_test() { // second user deposit world - .sc_call_step( + .sc_call( ScCallStep::new() .from(second_user_addr) .to(&cf_sc) @@ -123,7 +123,7 @@ fn crowdfunding_scenario_rust_test() { // owner claim - failed campaign - nothing is transferred world - .sc_call_step( + .sc_call( ScCallStep::new() .from(owner_addr) .to(&cf_sc) @@ -144,7 +144,7 @@ fn crowdfunding_scenario_rust_test() { // first user claim - failed campaign world - .sc_call_step( + .sc_call( ScCallStep::new() .from(first_user_addr) .to(&cf_sc) @@ -165,7 +165,7 @@ fn crowdfunding_scenario_rust_test() { // second user claim - failed campaign world - .sc_call_step( + .sc_call( ScCallStep::new() .from(second_user_addr) .to(&cf_sc) @@ -186,7 +186,7 @@ fn crowdfunding_scenario_rust_test() { world.set_state_step(SetStateStep::new().block_timestamp(deadline / 2)); // first user deposit - world.sc_call_step( + world.sc_call( ScCallStep::new() .from(first_user_addr) .to(&cf_sc) @@ -196,7 +196,7 @@ fn crowdfunding_scenario_rust_test() { ); // second user deposit - world.sc_call_step( + world.sc_call( ScCallStep::new() .from(second_user_addr) .to(&cf_sc) @@ -222,7 +222,7 @@ fn crowdfunding_scenario_rust_test() { assert_eq!(status, Status::Successful); // first user try claim - successful campaign - world.sc_call_step( + world.sc_call( ScCallStep::new() .from(first_user_addr) .to(&cf_sc) @@ -235,7 +235,7 @@ fn crowdfunding_scenario_rust_test() { // owner claim successful campaign world - .sc_call_step( + .sc_call( ScCallStep::new() .from(owner_addr) .to(&cf_sc) diff --git a/contracts/examples/multisig/tests/multisig_rust_test_v2.rs b/contracts/examples/multisig/tests/multisig_rust_test_v2.rs index ae0bc3b93a..aebb972417 100644 --- a/contracts/examples/multisig/tests/multisig_rust_test_v2.rs +++ b/contracts/examples/multisig/tests/multisig_rust_test_v2.rs @@ -134,7 +134,7 @@ impl MultisigTestState { .into(); let ic = &self.world.interpreter_context(); - self.world.sc_deploy_step( + self.world.sc_deploy( ScDeployStep::new() .from(self.owner.clone()) .code(self.world.code_expression(MULTISIG_PATH_EXPR)) @@ -152,7 +152,7 @@ impl MultisigTestState { .put_account(&self.owner, Account::new().nonce(1)) .new_address(&self.owner, 1, &self.adder), ); - self.world.sc_deploy_step( + self.world.sc_deploy( ScDeployStep::new() .from(self.owner.clone()) .code(self.world.code_expression(ADDER_PATH_EXPR)) @@ -164,7 +164,7 @@ impl MultisigTestState { } fn multisig_sign(&mut self, action_id: usize, signer: &Address) { - self.world.sc_call_step( + self.world.sc_call( ScCallStep::new() .from(signer) .call(self.multisig.sign(action_id)) diff --git a/framework/scenario/src/facade.rs b/framework/scenario/src/facade.rs index ba8e1722cb..f53625895e 100644 --- a/framework/scenario/src/facade.rs +++ b/framework/scenario/src/facade.rs @@ -3,6 +3,7 @@ mod debugger_backend; mod scenario_world; mod scenario_world_runner; mod scenario_world_steps; +mod scenario_world_steps_deprecated; mod scenario_world_whitebox; mod whitebox_contract; diff --git a/framework/scenario/src/facade/scenario_world_steps.rs b/framework/scenario/src/facade/scenario_world_steps.rs index 721dd9a572..37bc5e88c3 100644 --- a/framework/scenario/src/facade/scenario_world_steps.rs +++ b/framework/scenario/src/facade/scenario_world_steps.rs @@ -21,7 +21,7 @@ impl ScenarioWorld { } /// Adds a SC call step, then executes it. - pub fn sc_call_step(&mut self, mut step: S) -> &mut Self + pub fn sc_call(&mut self, mut step: S) -> &mut Self where S: AsMut, { @@ -71,7 +71,7 @@ impl ScenarioWorld { } /// Adds a SC query step, then executes it. - pub fn sc_query_step(&mut self, mut step: S) -> &mut Self + pub fn sc_query(&mut self, mut step: S) -> &mut Self where S: AsMut, { @@ -135,7 +135,7 @@ impl ScenarioWorld { } /// Adds a SC deploy step, then executes it. - pub fn sc_deploy_step(&mut self, mut step: S) -> &mut Self + pub fn sc_deploy(&mut self, mut step: S) -> &mut Self where S: AsMut, { @@ -260,51 +260,6 @@ impl TypedScQueryExecutor for ScenarioWorld { } } -impl ScenarioWorld { - #[deprecated(since = "0.39.0", note = "Renamed, use `set_state_step` instead.")] - pub fn mandos_set_state(&mut self, step: SetStateStep) -> &mut Self { - self.set_state_step(step) - } - - #[deprecated(since = "0.39.0", note = "Renamed, use `sc_call_step` instead.")] - pub fn mandos_sc_call(&mut self, step: ScCallStep) -> &mut Self { - self.sc_call_step(step) - } - - #[deprecated(since = "0.39.0", note = "Renamed, use `sc_query_step` instead.")] - pub fn mandos_sc_query(&mut self, step: ScQueryStep) -> &mut Self { - self.sc_query_step(step) - } - - #[deprecated(since = "0.39.0", note = "Renamed, use `sc_deploy_step` instead.")] - pub fn mandos_sc_deploy(&mut self, step: ScDeployStep) -> &mut Self { - self.sc_deploy_step(step) - } - - #[deprecated(since = "0.39.0", note = "Renamed, use `transfer_step` instead.")] - pub fn mandos_transfer(&mut self, step: TransferStep) -> &mut Self { - self.transfer_step(step) - } - - #[deprecated( - since = "0.39.0", - note = "Renamed, use `validator_reward_step` instead." - )] - pub fn mandos_validator_reward(&mut self, step: ValidatorRewardStep) -> &mut Self { - self.validator_reward_step(step) - } - - #[deprecated(since = "0.39.0", note = "Renamed, use `check_state_step` instead.")] - pub fn mandos_check_state(&mut self, step: CheckStateStep) -> &mut Self { - self.check_state_step(step) - } - - #[deprecated(since = "0.39.0", note = "Renamed, use `dump_state_step` instead.")] - pub fn mandos_dump_state(&mut self) -> &mut Self { - self.dump_state_step() - } -} - fn unwrap_response(opt_response: &Option) -> &TxResponse { opt_response.as_ref().expect("response not processed") } diff --git a/framework/scenario/src/facade/scenario_world_steps_deprecated.rs b/framework/scenario/src/facade/scenario_world_steps_deprecated.rs new file mode 100644 index 0000000000..0492faa7b0 --- /dev/null +++ b/framework/scenario/src/facade/scenario_world_steps_deprecated.rs @@ -0,0 +1,70 @@ +use crate::{facade::ScenarioWorld, scenario::model::*}; + +impl ScenarioWorld { + #[deprecated(since = "0.42.0", note = "Renamed to `sc_call`.")] + pub fn sc_call_step(&mut self, step: S) -> &mut Self + where + S: AsMut, + { + self.sc_call(step) + } + + #[deprecated(since = "0.42.0", note = "Renamed to `sc_query`.")] + pub fn sc_query_step(&mut self, step: S) -> &mut Self + where + S: AsMut, + { + self.sc_query(step) + } + + #[deprecated(since = "0.42.0", note = "Renamed to `sc_deploy`.")] + pub fn sc_deploy_step(&mut self, step: S) -> &mut Self + where + S: AsMut, + { + self.sc_deploy(step) + } + + #[deprecated(since = "0.39.0", note = "Renamed, use `set_state_step` instead.")] + pub fn mandos_set_state(&mut self, step: SetStateStep) -> &mut Self { + self.set_state_step(step) + } + + #[deprecated(since = "0.39.0", note = "Renamed, use `sc_call_step` instead.")] + pub fn mandos_sc_call(&mut self, step: ScCallStep) -> &mut Self { + self.sc_call(step) + } + + #[deprecated(since = "0.39.0", note = "Renamed, use `sc_query_step` instead.")] + pub fn mandos_sc_query(&mut self, step: ScQueryStep) -> &mut Self { + self.sc_query(step) + } + + #[deprecated(since = "0.39.0", note = "Renamed, use `sc_deploy_step` instead.")] + pub fn mandos_sc_deploy(&mut self, step: ScDeployStep) -> &mut Self { + self.sc_deploy(step) + } + + #[deprecated(since = "0.39.0", note = "Renamed, use `transfer_step` instead.")] + pub fn mandos_transfer(&mut self, step: TransferStep) -> &mut Self { + self.transfer_step(step) + } + + #[deprecated( + since = "0.39.0", + note = "Renamed, use `validator_reward_step` instead." + )] + pub fn mandos_validator_reward(&mut self, step: ValidatorRewardStep) -> &mut Self { + self.validator_reward_step(step) + } + + #[deprecated(since = "0.39.0", note = "Renamed, use `check_state_step` instead.")] + pub fn mandos_check_state(&mut self, step: CheckStateStep) -> &mut Self { + self.check_state_step(step) + } + + #[deprecated(since = "0.39.0", note = "Renamed, use `dump_state_step` instead.")] + pub fn mandos_dump_state(&mut self) -> &mut Self { + self.dump_state_step() + } +}