Skip to content

Commit

Permalink
testing framework - renamed step methods
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Jul 14, 2023
1 parent 0a16a73 commit 6a75d87
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions contracts/examples/multisig/tests/multisig_rust_test_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand Down
1 change: 1 addition & 0 deletions framework/scenario/src/facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
51 changes: 3 additions & 48 deletions framework/scenario/src/facade/scenario_world_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl ScenarioWorld {
}

/// Adds a SC call step, then executes it.
pub fn sc_call_step<S>(&mut self, mut step: S) -> &mut Self
pub fn sc_call<S>(&mut self, mut step: S) -> &mut Self
where
S: AsMut<ScCallStep>,
{
Expand Down Expand Up @@ -71,7 +71,7 @@ impl ScenarioWorld {
}

/// Adds a SC query step, then executes it.
pub fn sc_query_step<S>(&mut self, mut step: S) -> &mut Self
pub fn sc_query<S>(&mut self, mut step: S) -> &mut Self
where
S: AsMut<ScQueryStep>,
{
Expand Down Expand Up @@ -135,7 +135,7 @@ impl ScenarioWorld {
}

/// Adds a SC deploy step, then executes it.
pub fn sc_deploy_step<S>(&mut self, mut step: S) -> &mut Self
pub fn sc_deploy<S>(&mut self, mut step: S) -> &mut Self
where
S: AsMut<ScDeployStep>,
{
Expand Down Expand Up @@ -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>) -> &TxResponse {
opt_response.as_ref().expect("response not processed")
}
Expand Down
70 changes: 70 additions & 0 deletions framework/scenario/src/facade/scenario_world_steps_deprecated.rs
Original file line number Diff line number Diff line change
@@ -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<S>(&mut self, step: S) -> &mut Self
where
S: AsMut<ScCallStep>,
{
self.sc_call(step)
}

#[deprecated(since = "0.42.0", note = "Renamed to `sc_query`.")]
pub fn sc_query_step<S>(&mut self, step: S) -> &mut Self
where
S: AsMut<ScQueryStep>,
{
self.sc_query(step)
}

#[deprecated(since = "0.42.0", note = "Renamed to `sc_deploy`.")]
pub fn sc_deploy_step<S>(&mut self, step: S) -> &mut Self
where
S: AsMut<ScDeployStep>,
{
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()
}
}

0 comments on commit 6a75d87

Please sign in to comment.