diff --git a/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs b/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs index 66311ab731..57b3ef2dd7 100644 --- a/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs +++ b/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_blackbox_test.rs @@ -1,246 +1,263 @@ -use crowdfunding_esdt::*; -use multiversx_sc::types::EgldOrEsdtTokenIdentifier; -use multiversx_sc_scenario::{api::StaticApi, scenario_model::*, *}; +use crowdfunding_esdt::{ProxyTrait as _, Status}; +use multiversx_sc::{ + storage::mappers::SingleValue, + types::{Address, EgldOrEsdtTokenIdentifier}, +}; +use multiversx_sc_scenario::{ + api::StaticApi, + scenario_model::{ + Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep, + SetStateStep, TxExpect, + }, + ContractInfo, ScenarioWorld, +}; +use num_bigint::BigUint; -const CF_PATH_EXPR: &str = "file:output/crowdfunding-esdt.wasm"; +const CF_DEADLINE: u64 = 7 * 24 * 60 * 60; // 1 week in seconds +const CF_TOKEN_ID: &[u8] = b"CROWD-123456"; +const CF_TOKEN_ID_EXPR: &str = "str:CROWD-123456"; +const CROWDFUNDING_ESDT_ADDRESS_EXPR: &str = "sc:crowdfunding-esdt"; +const CROWDFUNDING_ESDT_PATH_EXPR: &str = "file:output/crowdfunding-esdt.wasm"; +const FIRST_USER_ADDRESS_EXPR: &str = "address:first-user"; +const OWNER_ADDRESS_EXPR: &str = "address:owner"; +const SECOND_USER_ADDRESS_EXPR: &str = "address:second-user"; + +type CrowdfundingESDTContract = ContractInfo>; fn world() -> ScenarioWorld { let mut blockchain = ScenarioWorld::new(); blockchain.set_current_dir_from_workspace("contracts/examples/crowdfunding-esdt"); - blockchain.register_contract(CF_PATH_EXPR, crowdfunding_esdt::ContractBuilder); + blockchain.register_contract( + CROWDFUNDING_ESDT_PATH_EXPR, + crowdfunding_esdt::ContractBuilder, + ); blockchain } -#[test] -fn crowdfunding_scenario_rust_test() { - let mut world = world(); - let cf_code = world.code_expression(CF_PATH_EXPR); - - let owner_addr = "address:owner"; - let first_user_addr = "address:user1"; - let second_user_addr = "address:user2"; - - let deadline: u64 = 7 * 24 * 60 * 60; // 1 week in seconds - let cf_token_id_value = "CROWD-123456"; // when passing as argument - let cf_token_id = "str:CROWD-123456"; // when specifying the token transfer - let mut cf_sc = ContractInfo::>::new("sc:crowdfunding"); - - // setup owner and crowdfunding SC - world.start_trace().set_state_step( - SetStateStep::new() - .put_account(owner_addr, Account::new()) - .new_address(owner_addr, 0, &cf_sc), - ); +struct CrowdfundingESDTTestState { + world: ScenarioWorld, + crowdfunding_esdt_contract: CrowdfundingESDTContract, + first_user_address: Address, + second_user_address: Address, +} - world.sc_deploy( - ScDeployStep::new() - .from(owner_addr) - .code(cf_code) - .call(cf_sc.init( - 2_000u32, - deadline, - EgldOrEsdtTokenIdentifier::esdt(cf_token_id_value), - )), - ); +impl CrowdfundingESDTTestState { + fn new() -> Self { + let mut world = world(); - // setup user accounts - world - .set_state_step(SetStateStep::new().put_account( - first_user_addr, - Account::new().esdt_balance(cf_token_id, 1_000u64), - )) - .set_state_step(SetStateStep::new().put_account( - second_user_addr, - Account::new().esdt_balance(cf_token_id, 1_000u64), - )); - - // first user deposit - world - .sc_call( - ScCallStep::new() - .from(first_user_addr) - .to(&cf_sc) - .esdt_transfer(cf_token_id, 0u64, 1_000u64) - .call(cf_sc.fund()), - ) - .check_state_step( - CheckStateStep::new() + world.set_state_step( + SetStateStep::new() + .put_account(OWNER_ADDRESS_EXPR, Account::new().nonce(1)) + .new_address(OWNER_ADDRESS_EXPR, 1, CROWDFUNDING_ESDT_ADDRESS_EXPR) .put_account( - first_user_addr, - CheckAccount::new().esdt_balance(cf_token_id, 0u64), + FIRST_USER_ADDRESS_EXPR, + Account::new() + .nonce(1) + .balance("1_000") + .esdt_balance(CF_TOKEN_ID_EXPR, "1_000"), ) .put_account( - &cf_sc, - CheckAccount::new().esdt_balance(cf_token_id, 1_000u64), + SECOND_USER_ADDRESS_EXPR, + Account::new() + .nonce(1) + .esdt_balance(CF_TOKEN_ID_EXPR, "1_000"), ), ); - // second user deposit - world - .sc_call( - ScCallStep::new() - .from(second_user_addr) - .to(&cf_sc) - .esdt_transfer(cf_token_id, 0u64, 500u64) - .call(cf_sc.fund()), - ) - .check_state_step( - CheckStateStep::new() - .put_account( - second_user_addr, - CheckAccount::new().esdt_balance(cf_token_id, 500u64), - ) - .put_account( - &cf_sc, - CheckAccount::new().esdt_balance(cf_token_id, 1_500u64), - ), + let crowdfunding_esdt_contract = + CrowdfundingESDTContract::new(CROWDFUNDING_ESDT_ADDRESS_EXPR); + + let first_user_address = AddressValue::from(FIRST_USER_ADDRESS_EXPR).to_address(); + let second_user_address = AddressValue::from(SECOND_USER_ADDRESS_EXPR).to_address(); + + Self { + world, + crowdfunding_esdt_contract, + first_user_address, + second_user_address, + } + } + + fn deploy(&mut self) -> &mut Self { + let crowdfunding_esdt_code = self.world.code_expression(CROWDFUNDING_ESDT_PATH_EXPR); + + self.world.sc_deploy( + ScDeployStep::new() + .from(OWNER_ADDRESS_EXPR) + .code(crowdfunding_esdt_code) + .call(self.crowdfunding_esdt_contract.init( + 2_000u32, + CF_DEADLINE, + EgldOrEsdtTokenIdentifier::esdt(CF_TOKEN_ID), + )), ); - // get status before - let status: Status = cf_sc - .status() - .into_vm_query() - .expect(TxExpect::ok().result("")) - .execute(&mut world); - assert_eq!(status, Status::FundingPeriod); - - // deadline passed - world.set_state_step(SetStateStep::new().block_timestamp(deadline)); - - // get status after deadline - let status: Status = cf_sc - .status() - .into_vm_query() - .expect(TxExpect::ok().result("2")) - .execute(&mut world); - assert_eq!(status, Status::Failed); - - // test failed campaign - - // owner claim - failed campaign - nothing is transferred - world - .sc_call( + self + } + + fn fund(&mut self, address: &str, amount: &str) -> &mut Self { + self.world.sc_call( ScCallStep::new() - .from(owner_addr) - .to(&cf_sc) - .call(cf_sc.claim()), - ) - .check_state_step( - CheckStateStep::new() - .put_account( - owner_addr, - CheckAccount::new().esdt_balance(cf_token_id, 0u64), - ) - .put_account( - &cf_sc, - CheckAccount::new().esdt_balance(cf_token_id, 1_500u64), - ), + .from(address) + .esdt_transfer(CF_TOKEN_ID_EXPR, 0, amount) + .call(self.crowdfunding_esdt_contract.fund()), ); - // first user claim - failed campaign - world - .sc_call( - ScCallStep::new() - .from(first_user_addr) - .to(&cf_sc) - .call(cf_sc.claim()), - ) - .check_state_step( - CheckStateStep::new() - .put_account( - first_user_addr, - CheckAccount::new().esdt_balance(cf_token_id, 1_000u64), - ) - .put_account( - &cf_sc, - CheckAccount::new().esdt_balance(cf_token_id, 500u64), - ), + self + } + + fn check_deposit(&mut self, donor: Address, amount: u64) -> &mut Self { + self.world.sc_query( + ScQueryStep::new() + .call(self.crowdfunding_esdt_contract.deposit(&donor)) + .expect_value(SingleValue::from(BigUint::from(amount))), + ); + + self + } + + fn check_status(&mut self, expected_value: Status) -> &mut Self { + self.world.sc_query( + ScQueryStep::new() + .call(self.crowdfunding_esdt_contract.status()) + .expect_value(expected_value), ); - // second user claim - failed campaign - world - .sc_call( + self + } + + fn claim(&mut self, address: &str) -> &mut Self { + self.world.sc_call( ScCallStep::new() - .from(second_user_addr) - .to(&cf_sc) - .call(cf_sc.claim()), - ) - .check_state_step( - CheckStateStep::new() - .put_account( - second_user_addr, - CheckAccount::new().esdt_balance(cf_token_id, 1_000u64), - ) - .put_account(&cf_sc, CheckAccount::new().esdt_balance(cf_token_id, 0u64)), + .from(address) + .call(self.crowdfunding_esdt_contract.claim()), ); - // test successful campaign + self + } - world.set_state_step(SetStateStep::new().block_timestamp(deadline / 2)); + fn check_esdt_balance(&mut self, address_expr: &str, balance_expr: &str) -> &mut Self { + self.world + .check_state_step(CheckStateStep::new().put_account( + address_expr, + CheckAccount::new().esdt_balance(CF_TOKEN_ID_EXPR, balance_expr), + )); - // first user deposit - world.sc_call( - ScCallStep::new() - .from(first_user_addr) - .to(&cf_sc) - .esdt_transfer(cf_token_id, 0u64, 1_000u64) - .call(cf_sc.fund()), - ); + self + } + + fn set_block_timestamp(&mut self, block_timestamp_expr: u64) -> &mut Self { + self.world + .set_state_step(SetStateStep::new().block_timestamp(block_timestamp_expr)); + + self + } +} + +#[test] +fn test_fund() { + let mut state = CrowdfundingESDTTestState::new(); + state.deploy(); + + state.fund(FIRST_USER_ADDRESS_EXPR, "1000"); + state.check_deposit(state.first_user_address.clone(), 1_000); +} - // second user deposit - world.sc_call( +#[test] +fn test_status() { + let mut state = CrowdfundingESDTTestState::new(); + state.deploy(); + + state.check_status(Status::FundingPeriod); +} + +#[test] +fn test_sc_error() { + let mut state = CrowdfundingESDTTestState::new(); + state.deploy(); + + state.world.sc_call( ScCallStep::new() - .from(second_user_addr) - .to(&cf_sc) - .esdt_transfer(cf_token_id, 0u64, 1_000u64) - .call(cf_sc.fund()), + .from(FIRST_USER_ADDRESS_EXPR) + .egld_value("1_000") + .call(state.crowdfunding_esdt_contract.fund()) + .expect(TxExpect::user_error("str:wrong token")), ); + state.world.sc_query( + ScQueryStep::new() + .call( + state + .crowdfunding_esdt_contract + .deposit(&state.first_user_address), + ) + .expect(TxExpect::ok().result("0x")), + ); +} - let status: Status = cf_sc - .status() - .into_vm_query() - .expect(TxExpect::ok().result("")) - .execute(&mut world); - assert_eq!(status, Status::FundingPeriod); +#[test] +fn test_successful_cf() { + let mut state = CrowdfundingESDTTestState::new(); + state.deploy(); + + // first user fund + state.fund(FIRST_USER_ADDRESS_EXPR, "1_000"); + state.check_deposit(state.first_user_address.clone(), 1_000); + + // second user fund + state.fund(SECOND_USER_ADDRESS_EXPR, "1_000"); + state.check_deposit(state.second_user_address.clone(), 1_000); - world.set_state_step(SetStateStep::new().block_timestamp(deadline)); + // set block timestamp after deadline + state.set_block_timestamp(CF_DEADLINE + 1); - let status: Status = cf_sc - .status() - .into_vm_query() - .expect(TxExpect::ok().result("1")) - .execute(&mut world); - assert_eq!(status, Status::Successful); + // check status successful + state.check_status(Status::Successful); - // first user try claim - successful campaign - world.sc_call( + // user try claim + state.world.sc_call( ScCallStep::new() - .from(first_user_addr) - .to(&cf_sc) - .call(cf_sc.claim()) - .expect(TxExpect::err( - 4, + .from(FIRST_USER_ADDRESS_EXPR) + .call(state.crowdfunding_esdt_contract.claim()) + .expect(TxExpect::user_error( "str:only owner can claim successful funding", )), ); - // owner claim successful campaign - world - .sc_call( - ScCallStep::new() - .from(owner_addr) - .to(&cf_sc) - .call(cf_sc.claim()), - ) - .check_state_step( - CheckStateStep::new() - .put_account( - owner_addr, - CheckAccount::new().esdt_balance(cf_token_id, 2_000u64), - ) - .put_account(cf_sc, CheckAccount::new().esdt_balance(cf_token_id, 0u64)), - ); + // owner claim + state.claim(OWNER_ADDRESS_EXPR); + + state.check_esdt_balance(OWNER_ADDRESS_EXPR, "2_000"); + state.check_esdt_balance(FIRST_USER_ADDRESS_EXPR, "0"); + state.check_esdt_balance(SECOND_USER_ADDRESS_EXPR, "0"); +} + +#[test] +fn test_failed_cf() { + let mut state = CrowdfundingESDTTestState::new(); + state.deploy(); + + // first user fund + state.fund(FIRST_USER_ADDRESS_EXPR, "300"); + state.check_deposit(state.first_user_address.clone(), 300u64); + + // second user fund + state.fund(SECOND_USER_ADDRESS_EXPR, "600"); + state.check_deposit(state.second_user_address.clone(), 600u64); + + // set block timestamp after deadline + state.set_block_timestamp(CF_DEADLINE + 1); + + // check status failed + state.check_status(Status::Failed); + + // first user claim + state.claim(FIRST_USER_ADDRESS_EXPR); + + // second user claim + state.claim(SECOND_USER_ADDRESS_EXPR); - world.write_scenario_trace("scenarios-gen/crowdfunding_rust.scen.json"); + state.check_esdt_balance(OWNER_ADDRESS_EXPR, "0"); + state.check_esdt_balance(FIRST_USER_ADDRESS_EXPR, "1_000"); + state.check_esdt_balance(SECOND_USER_ADDRESS_EXPR, "1_000"); } diff --git a/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_whitebox_legacy_test.rs b/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_whitebox_legacy_test.rs deleted file mode 100644 index 87289e7a40..0000000000 --- a/contracts/examples/crowdfunding-esdt/tests/crowdfunding_esdt_whitebox_legacy_test.rs +++ /dev/null @@ -1,322 +0,0 @@ -#![allow(deprecated)] // TODO: migrate tests - -use crowdfunding_esdt::*; -use multiversx_sc::types::{Address, EgldOrEsdtTokenIdentifier}; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_token_id, rust_biguint, testing_framework::*, - DebugApi, -}; - -const CF_TOKEN_ID: &[u8] = b"CROWD-123456"; -const CF_DEADLINE: u64 = 7 * 24 * 60 * 60; // 1 week in seconds -const WASM_PATH: &str = "output/crowdfunding-esdt.wasm"; - -struct CrowdfundingSetup -where - CrowdfundingObjBuilder: 'static + Copy + Fn() -> crowdfunding_esdt::ContractObj, -{ - pub blockchain_wrapper: BlockchainStateWrapper, - pub owner_address: Address, - pub first_user_address: Address, - pub second_user_address: Address, - pub cf_wrapper: - ContractObjWrapper, CrowdfundingObjBuilder>, -} - -fn setup_crowdfunding( - cf_builder: CrowdfundingObjBuilder, -) -> CrowdfundingSetup -where - CrowdfundingObjBuilder: 'static + Copy + Fn() -> crowdfunding_esdt::ContractObj, -{ - let rust_zero = rust_biguint!(0u64); - let mut blockchain_wrapper = BlockchainStateWrapper::new(); - let owner_address = blockchain_wrapper.create_user_account(&rust_zero); - let first_user_address = blockchain_wrapper.create_user_account(&rust_zero); - let second_user_address = blockchain_wrapper.create_user_account(&rust_zero); - let cf_wrapper = blockchain_wrapper.create_sc_account( - &rust_zero, - Some(&owner_address), - cf_builder, - WASM_PATH, - ); - - blockchain_wrapper.set_esdt_balance(&first_user_address, CF_TOKEN_ID, &rust_biguint!(1_000)); - blockchain_wrapper.set_esdt_balance(&second_user_address, CF_TOKEN_ID, &rust_biguint!(1_000)); - - blockchain_wrapper - .execute_tx(&owner_address, &cf_wrapper, &rust_zero, |sc| { - let target = managed_biguint!(2_000); - let token_id = managed_token_id!(CF_TOKEN_ID); - - sc.init( - target, - CF_DEADLINE, - EgldOrEsdtTokenIdentifier::esdt(token_id), - ); - }) - .assert_ok(); - - blockchain_wrapper.add_mandos_set_account(cf_wrapper.address_ref()); - - CrowdfundingSetup { - blockchain_wrapper, - owner_address, - first_user_address, - second_user_address, - cf_wrapper, - } -} - -#[test] -fn init_test() { - let cf_setup = setup_crowdfunding(crowdfunding_esdt::contract_obj); - cf_setup - .blockchain_wrapper - .write_mandos_output("_generated_init.scen.json"); -} - -#[test] -fn fund_test() { - let mut cf_setup = setup_crowdfunding(crowdfunding_esdt::contract_obj); - let b_wrapper = &mut cf_setup.blockchain_wrapper; - let user_addr = &cf_setup.first_user_address; - - b_wrapper - .execute_esdt_transfer( - user_addr, - &cf_setup.cf_wrapper, - CF_TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - sc.fund(); - - let user_deposit = sc.deposit(&managed_address!(user_addr)).get(); - let expected_deposit = managed_biguint!(1_000); - assert_eq!(user_deposit, expected_deposit); - }, - ) - .assert_ok(); - - let mut sc_call = ScCallMandos::new(user_addr, cf_setup.cf_wrapper.address_ref(), "fund"); - sc_call.add_esdt_transfer(CF_TOKEN_ID, 0, &rust_biguint!(1_000)); - - let expect = TxExpectMandos::new(0); - b_wrapper.add_mandos_sc_call(sc_call, Some(expect)); - - cf_setup - .blockchain_wrapper - .write_mandos_output("_generated_fund.scen.json"); -} - -#[test] -fn status_test() { - let mut cf_setup = setup_crowdfunding(crowdfunding_esdt::contract_obj); - let b_wrapper = &mut cf_setup.blockchain_wrapper; - - b_wrapper - .execute_query(&cf_setup.cf_wrapper, |sc| { - let status = sc.status(); - assert_eq!(status, Status::FundingPeriod); - }) - .assert_ok(); - - let sc_query = ScQueryMandos::new(cf_setup.cf_wrapper.address_ref(), "status"); - let mut expect = TxExpectMandos::new(0); - expect.add_out_value(&Status::FundingPeriod); - - b_wrapper.add_mandos_sc_query(sc_query, Some(expect)); - - cf_setup - .blockchain_wrapper - .write_mandos_output("_generated_query_status.scen.json"); -} - -#[test] -fn test_sc_error() { - let mut cf_setup = setup_crowdfunding(crowdfunding_esdt::contract_obj); - let b_wrapper = &mut cf_setup.blockchain_wrapper; - let user_addr = &cf_setup.first_user_address; - - b_wrapper.set_egld_balance(user_addr, &rust_biguint!(1_000)); - - b_wrapper - .execute_tx( - user_addr, - &cf_setup.cf_wrapper, - &rust_biguint!(1_000), - |sc| { - sc.fund(); - }, - ) - .assert_user_error("wrong token"); - - b_wrapper - .execute_tx(user_addr, &cf_setup.cf_wrapper, &rust_biguint!(0), |sc| { - let user_deposit = sc.deposit(&managed_address!(user_addr)).get(); - let expected_deposit = managed_biguint!(0); - assert_eq!(user_deposit, expected_deposit); - }) - .assert_ok(); - - let mut sc_call = ScCallMandos::new(user_addr, cf_setup.cf_wrapper.address_ref(), "fund"); - sc_call.add_egld_value(&rust_biguint!(1_000)); - - let mut expect = TxExpectMandos::new(4); - expect.set_message("wrong token"); - - b_wrapper.add_mandos_sc_call(sc_call, Some(expect)); - - cf_setup - .blockchain_wrapper - .write_mandos_output("_generated_sc_err.scen.json"); -} - -#[test] -fn test_successful_cf() { - let mut cf_setup = setup_crowdfunding(crowdfunding_esdt::contract_obj); - let b_wrapper = &mut cf_setup.blockchain_wrapper; - let owner = &cf_setup.owner_address; - let first_user = &cf_setup.first_user_address; - let second_user = &cf_setup.second_user_address; - - // first user fund - b_wrapper - .execute_esdt_transfer( - first_user, - &cf_setup.cf_wrapper, - CF_TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - sc.fund(); - - let user_deposit = sc.deposit(&managed_address!(first_user)).get(); - let expected_deposit = managed_biguint!(1_000); - assert_eq!(user_deposit, expected_deposit); - }, - ) - .assert_ok(); - - // second user fund - b_wrapper - .execute_esdt_transfer( - second_user, - &cf_setup.cf_wrapper, - CF_TOKEN_ID, - 0, - &rust_biguint!(1_000), - |sc| { - sc.fund(); - - let user_deposit = sc.deposit(&managed_address!(second_user)).get(); - let expected_deposit = managed_biguint!(1_000); - assert_eq!(user_deposit, expected_deposit); - }, - ) - .assert_ok(); - - // set block timestamp after deadline - b_wrapper.set_block_timestamp(CF_DEADLINE + 1); - - // check status - b_wrapper - .execute_query(&cf_setup.cf_wrapper, |sc| { - let status = sc.status(); - assert_eq!(status, Status::Successful); - }) - .assert_ok(); - - // user try claim - b_wrapper - .execute_tx(first_user, &cf_setup.cf_wrapper, &rust_biguint!(0), |sc| { - sc.claim(); - }) - .assert_user_error("only owner can claim successful funding"); - - // owner claim - b_wrapper - .execute_tx(owner, &cf_setup.cf_wrapper, &rust_biguint!(0), |sc| { - sc.claim(); - }) - .assert_ok(); - - b_wrapper.check_esdt_balance(owner, CF_TOKEN_ID, &rust_biguint!(2_000)); - b_wrapper.check_esdt_balance(first_user, CF_TOKEN_ID, &rust_biguint!(0)); - b_wrapper.check_esdt_balance(second_user, CF_TOKEN_ID, &rust_biguint!(0)); -} - -#[test] -fn test_failed_cf() { - let mut cf_setup = setup_crowdfunding(crowdfunding_esdt::contract_obj); - let b_wrapper = &mut cf_setup.blockchain_wrapper; - let owner = &cf_setup.owner_address; - let first_user = &cf_setup.first_user_address; - let second_user = &cf_setup.second_user_address; - - // first user fund - b_wrapper - .execute_esdt_transfer( - first_user, - &cf_setup.cf_wrapper, - CF_TOKEN_ID, - 0, - &rust_biguint!(300), - |sc| { - sc.fund(); - - let user_deposit = sc.deposit(&managed_address!(first_user)).get(); - let expected_deposit = managed_biguint!(300); - assert_eq!(user_deposit, expected_deposit); - }, - ) - .assert_ok(); - - // second user fund - b_wrapper - .execute_esdt_transfer( - second_user, - &cf_setup.cf_wrapper, - CF_TOKEN_ID, - 0, - &rust_biguint!(600), - |sc| { - sc.fund(); - - let user_deposit = sc.deposit(&managed_address!(second_user)).get(); - let expected_deposit = managed_biguint!(600); - assert_eq!(user_deposit, expected_deposit); - }, - ) - .assert_ok(); - - // set block timestamp after deadline - b_wrapper.set_block_timestamp(CF_DEADLINE + 1); - - // check status - b_wrapper - .execute_query(&cf_setup.cf_wrapper, |sc| { - let status = sc.status(); - assert_eq!(status, Status::Failed); - }) - .assert_ok(); - - // first user claim - b_wrapper - .execute_tx(first_user, &cf_setup.cf_wrapper, &rust_biguint!(0), |sc| { - sc.claim(); - }) - .assert_ok(); - - // second user claim - b_wrapper - .execute_tx(second_user, &cf_setup.cf_wrapper, &rust_biguint!(0), |sc| { - sc.claim(); - }) - .assert_ok(); - - b_wrapper.check_esdt_balance(owner, CF_TOKEN_ID, &rust_biguint!(0)); - b_wrapper.check_esdt_balance(first_user, CF_TOKEN_ID, &rust_biguint!(1_000)); - b_wrapper.check_esdt_balance(second_user, CF_TOKEN_ID, &rust_biguint!(1_000)); -}