Skip to content

Commit

Permalink
adapt some tests for with_result
Browse files Browse the repository at this point in the history
  • Loading branch information
ovstinga committed Jul 13, 2023
1 parent 71c29be commit 81ae712
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ fn crowdfunding_scenario_rust_test() {
.put_account(owner_addr, Account::new())
.new_address(owner_addr, 0, &cf_sc),
);
let (_, ()) = cf_sc
.init(
2_000u32,
deadline,
EgldOrEsdtTokenIdentifier::esdt(cf_token_id_value),
)
.into_blockchain_call()
.from(owner_addr)
.contract_code("file:output/crowdfunding-esdt.wasm", &ctx)
.gas_limit("5,000,000")
.expect(TxExpect::ok().no_result())
.execute(&mut world);

world.sc_deploy_step(
ScDeployStep::new()
.from(owner_addr)
.contract_code("file:output/crowdfunding-esdt.wasm", &ctx)
.call(cf_sc.init(
2_000u32,
deadline,
EgldOrEsdtTokenIdentifier::esdt(cf_token_id_value),
))
.gas_limit("5,000,000")
.expect(TxExpect::ok().no_result()),
);

// setup user accounts
world
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,24 @@ fn tester_deploy_test() {
let mut adder_contract =
ContractInfo::<rust_testing_framework_tester::Proxy<StaticApi>>::new("sc:contract");

world.start_trace().set_state_step(
SetStateStep::new()
.put_account(owner_address, Account::new())
.new_address(owner_address, 0, &adder_contract),
);

// deploy
let (new_address, result): (_, String) = adder_contract
.init()
.into_blockchain_call()
.from(owner_address)
.contract_code(WASM_PATH_EXPR, &ic)
.gas_limit("5,000,000")
.execute(&mut world);
assert_eq!(new_address, adder_contract.to_address());
assert_eq!(result, "constructor-result");

world.write_scenario_trace("scenarios/trace-deploy.scen.json");
world
.start_trace()
.set_state_step(
SetStateStep::new()
.put_account(owner_address, Account::new())
.new_address(owner_address, 0, &adder_contract),
)
.sc_deploy_use_result(
ScDeployStep::new()
.from(owner_address)
.contract_code(WASM_PATH_EXPR, &ic)
.call(adder_contract.init())
.gas_limit("5,000,000")
.expect(TxExpect::ok()),
|address, tr: TypedResponse<String>| {
assert_eq!(address, adder_contract.to_address());
assert_eq!(tr.result.unwrap(), "constructor-result");
},
)
.write_scenario_trace("scenarios/trace-deploy.scen.json");
}
4 changes: 2 additions & 2 deletions framework/scenario/src/scenario/model/transaction/tx_call.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
api::DebugApi,
api::StaticApi,
multiversx_sc::types::{ContractCall, ContractCallWithEgld, EsdtTokenPayment},
scenario::model::{AddressValue, BigUintValue, BytesValue, U64Value},
scenario_format::{
Expand Down Expand Up @@ -70,7 +70,7 @@ impl IntoRaw<TxCallRaw> for TxCall {
}

impl TxCall {
pub fn to_contract_call(&self) -> ContractCallWithEgld<DebugApi, ()> {
pub fn to_contract_call(&self) -> ContractCallWithEgld<StaticApi, ()> {
let mut contract_call = ContractCallWithEgld::new(
(&self.to.value).into(),
self.function.as_bytes(),
Expand Down
4 changes: 2 additions & 2 deletions framework/snippets/src/interactor_sc_call.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{address_h256_to_erdrs, mandos_to_erdrs_address, Interactor};
use log::info;
use multiversx_sc_scenario::{
api::StaticApi,
multiversx_sc::types::ContractCallWithEgld,
scenario::ScenarioRunner,
scenario_model::{ScCallStep, SetStateStep, TxCall, TxResponse},
DebugApi,
};
use multiversx_sdk::data::transaction::Transaction;

Expand Down Expand Up @@ -73,7 +73,7 @@ impl Interactor {
}
}

fn contract_call_to_tx_data(contract_call: &ContractCallWithEgld<DebugApi, ()>) -> String {
fn contract_call_to_tx_data(contract_call: &ContractCallWithEgld<StaticApi, ()>) -> String {
let mut result = String::from_utf8(
contract_call
.basic
Expand Down

0 comments on commit 81ae712

Please sign in to comment.