Skip to content

Commit

Permalink
check state refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Apr 17, 2024
1 parent 02556f8 commit 9549b7e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
8 changes: 3 additions & 5 deletions contracts/examples/adder/tests/adder_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ fn adder_blackbox() {
.returns(ExpectValue(6u32))
.run();

world.check_state_step(
CheckStateStep::new()
.put_account(OWNER, CheckAccount::new())
.put_account(SC_ADDER, CheckAccount::new().check_storage("str:sum", "6")),
);
world.check_account(OWNER);

world.check_account(SC_ADDER).check_storage("str:sum", "6");

world.write_scenario_trace("trace1.scen.json");
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl CrowdfundingESDTTestState {

fn check_esdt_balance(&mut self, address: AddressExpr, balance_expr: &str) {
self.world
.check_state_account(address)
.check_account(address)
.esdt_balance(CF_TOKEN_ID_EXPR, balance_expr);
}

Expand Down
20 changes: 10 additions & 10 deletions contracts/feature-tests/scenario-tester/tests/st_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ fn st_blackbox() {
.commit();

world
.check_state_account(owner_address)
.check_account(owner_address)
.nonce("1")
.balance("100")
.check_state_account(other_address)
.check_account(other_address)
.nonce("2")
.balance("300")
.esdt_balance("str:TOKEN-123456", "500")
Expand Down Expand Up @@ -81,10 +81,10 @@ fn st_blackbox() {
.run();

world
.check_state_account(owner_address)
.check_account(owner_address)
.nonce("3")
.balance("100")
.check_state_account(st_contract)
.check_account(st_contract)
.check_storage("str:sum", "6")
.commit();

Expand Down Expand Up @@ -122,10 +122,10 @@ fn set_state_test() {
.commit();

world
.check_state_account(first)
.check_account(first)
.nonce(1)
.balance("100")
.check_state_account(second)
.check_account(second)
.nonce(2)
.balance("300")
.esdt_balance("str:TOKEN-123456", "500")
Expand All @@ -139,7 +139,7 @@ fn set_state_test() {
.commit();

world
.check_state_account(third)
.check_account(third)
.nonce(3)
.balance("50")
.esdt_nft_balance_and_attributes("str:NFT-123456", "2", "1", Some(Vec::<u8>::new()))
Expand All @@ -156,10 +156,10 @@ fn set_state_test() {
.esdt_balance("str:TOKEN-123456", "2");

world
.check_state_account(fourth)
.check_account(fourth)
.nonce(4)
.balance("400")
.check_state_account(fifth)
.check_account(fifth)
.nonce(5)
.balance("250")
.esdt_balance("str:TOKEN-123456", "2");
Expand All @@ -171,7 +171,7 @@ fn set_state_test() {
.esdt_balance("str:TOKEN-123456", "60");

world
.check_state_account(sixth)
.check_account(sixth)
.nonce(6)
.balance("600")
.esdt_balance("str:TOKEN-123456", "60");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::{
};

impl ScenarioWorld {
pub fn check_state_account<A>(&mut self, address: A) -> CheckStateBuilder<'_>
pub fn check_account<A>(&mut self, address: A) -> CheckStateBuilder<'_>
where
AddressKey: From<A>,
{
Expand Down Expand Up @@ -42,7 +42,7 @@ impl<'w> CheckStateBuilder<'w> {
}

/// Starts building of a new account.
pub fn check_state_account<A>(mut self, address_expr: A) -> Self
pub fn check_account<A>(mut self, address_expr: A) -> Self
where
AddressKey: From<A>,
{
Expand Down

0 comments on commit 9549b7e

Please sign in to comment.