Skip to content

Commit

Permalink
imports - scenario & snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Apr 9, 2024
1 parent 4feff9a commit 4ffca0e
Show file tree
Hide file tree
Showing 55 changed files with 125 additions and 372 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use benchmark_common::ExampleStruct;
use linked_list_repeat::ProxyTrait;
use multiversx_sc::types::{MultiValueEncoded, TokenIdentifier};
use multiversx_sc_scenario::{api::StaticApi, scenario_model::*, *};
use multiversx_sc_scenario::imports::*;

const WASM_PATH_EXPR: &str = "mxsc:output/linked-list-repeat.mxsc.json";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@ use multiversx_price_aggregator_sc::{
price_aggregator_data::{OracleStatus, TimestampedPrice, TokenPair},
ContractObj, PriceAggregator, ProxyTrait as _, MAX_ROUND_DURATION_SECONDS,
};
use multiversx_sc::{
codec::multi_types::MultiValueVec,
types::{Address, EgldOrEsdtTokenIdentifier},
};
use multiversx_sc_modules::{pause::ProxyTrait, staking::ProxyTrait as _};
use multiversx_sc_scenario::{
api::StaticApi,
managed_address, managed_biguint, managed_buffer,
scenario_model::{Account, AddressValue, ScCallStep, ScDeployStep, SetStateStep, TxExpect},
ContractInfo, DebugApi, ScenarioWorld, WhiteboxContract,
};

use multiversx_sc_scenario::imports::*;

const DECIMALS: u8 = 0;
const EGLD_TICKER: &[u8] = b"EGLD";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@ use multiversx_price_aggregator_sc::{
price_aggregator_data::{OracleStatus, TokenPair},
ContractObj, PriceAggregator, ProxyTrait as _,
};
use multiversx_sc::{
codec::multi_types::MultiValueVec, contract_base::ContractBase,
types::EgldOrEsdtTokenIdentifier,
};
use multiversx_sc_modules::{pause::ProxyTrait, staking::ProxyTrait as _};
use multiversx_sc_scenario::{
api::StaticApi,
managed_address, managed_buffer,
scenario_model::{Account, AddressValue, ScCallStep, ScDeployStep, SetStateStep},
ContractInfo, DebugApi, ScenarioWorld, WhiteboxContract,
};

use multiversx_sc_scenario::imports::*;

const DECIMALS: u8 = 0;
const EGLD_TICKER: &[u8] = b"EGLD";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ use multiversx_price_aggregator_sc::{
price_aggregator_data::{OracleStatus, TimestampedPrice, TokenPair},
PriceAggregator, MAX_ROUND_DURATION_SECONDS,
};
use multiversx_sc::types::{EgldOrEsdtTokenIdentifier, MultiValueEncoded};
use multiversx_sc_modules::{
pause::EndpointWrappers as PauseEndpointWrappers,
staking::EndpointWrappers as StakingEndpointWrappers,
};
use multiversx_sc_scenario::{
managed_address, managed_biguint, managed_buffer, scenario_model::*, WhiteboxContract, *,
};
use multiversx_sc_scenario::imports::*;

pub const DECIMALS: u8 = 0;
pub const EGLD_TICKER: &[u8] = b"EGLD";
Expand Down
19 changes: 3 additions & 16 deletions contracts/examples/adder/interact/src/basic_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,8 @@ use adder::adder_proxy;
use basic_interact_config::Config;
use basic_interact_state::State;
use clap::Parser;
use multiversx_sc_snippets::{
env_logger,
multiversx_sc::types::{Address, ReturnsNewAddress, ReturnsResultConv},
multiversx_sc_scenario::{
api::StaticApi,
bech32,
mandos_system::ScenarioRunner,
num_bigint::BigUint,
scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext},
scenario_model::{BytesValue, Scenario},
standalone::retrieve_account_as_scenario_set_state,
test_wallets, ContractInfo, NumExpr, WithRawTxResponse,
},
tokio, Interactor, InteractorPrepareAsync,
};

use multiversx_sc_snippets::imports::*;

const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json";

Expand Down Expand Up @@ -189,7 +176,7 @@ impl AdderInteract {
.to(self.state.adder().to_address())
.typed(adder_proxy::AdderProxy)
.sum()
.returns(ReturnsResultConv::<BigUint>::new())
.returns(ReturnsResultConv::<RustBigUint>::new())
.prepare_async()
.run()
.await;
Expand Down
5 changes: 3 additions & 2 deletions contracts/examples/adder/tests/adder_blackbox_chained_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use multiversx_sc_scenario::imports::*;
use num_bigint::BigUint;

use adder::*;
use multiversx_sc::types::{AddressExpr, ScExpr, WithNewAddress, WithResultConv};
use multiversx_sc_scenario::{api::StaticApi, num_bigint::BigUint, scenario_model::*, *};

const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use multiversx_sc_scenario::imports::*;
use num_bigint::BigUint;

use adder::*;
use multiversx_sc::{
storage::mappers::SingleValue,
types::{AddressExpr, ReturnsResultConv, WithNewAddress},
};
use multiversx_sc_scenario::{api::StaticApi, num_bigint::BigUint, scenario_model::*, *};

const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiversx_sc_scenario::{scenario_model::*, *};
use multiversx_sc_scenario::imports::*;

const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json";

Expand Down
5 changes: 3 additions & 2 deletions contracts/examples/adder/tests/adder_blackbox_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use multiversx_sc_scenario::imports::*;
use num_bigint::BigUint;

use adder::*;
use multiversx_sc::types::{AddressExpr, ReturnsResultConv, ScExpr, WithNewAddress};
use multiversx_sc_scenario::{api::StaticApi, num_bigint::BigUint, scenario_model::*, *};

const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use multiversx_sc_scenario::{scenario_model::*, *};
use multiversx_sc_scenario::imports::*;

const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json";

Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/adder/tests/adder_whitebox_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use adder::*;
use multiversx_sc_scenario::{scenario_model::*, *};
use multiversx_sc_scenario::imports::*;

const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
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 multiversx_sc_scenario::imports::*;
use num_bigint::BigUint;

const CF_DEADLINE: u64 = 7 * 24 * 60 * 60; // 1 week in seconds
Expand Down
18 changes: 2 additions & 16 deletions contracts/examples/multisig/interact/src/multisig_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,8 @@ use clap::Parser;
use multisig::multisig_proxy;
use multisig_interact_config::Config;
use multisig_interact_state::State;
use multiversx_sc_scenario::{
mandos_system::ScenarioRunner,
multiversx_sc::types::{BigUint, ReturnsNewAddress, ReturnsResult},
scenario_format::interpret_trait::InterpretableFrom,
standalone::retrieve_account_as_scenario_set_state,
test_wallets, NumExpr,
};
use multiversx_sc_snippets::{
dns_address_for_name, env_logger,
multiversx_sc::{codec::multi_types::MultiValueVec, types::Address},
multiversx_sc_scenario::{
api::StaticApi, bech32, scenario_format::interpret_trait::InterpreterContext,
scenario_model::*, ContractInfo,
},
tokio, Interactor, InteractorPrepareAsync,
};

use multiversx_sc_snippets::imports::*;

const SYSTEM_SC_BECH32: &str = "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u";
const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
use std::time::Duration;

use multiversx_sc_scenario::{
multiversx_sc::{
codec::Empty,
types::{FunctionCall, ReturnsResult},
},
NumExpr, ReturnsNewTokenIdentifier,
};
use multiversx_sc_snippets::imports::*;

use super::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
use std::time::Duration;

use multiversx_sc_scenario::{
multiversx_sc::types::{FunctionCall, ManagedAddress, ReturnsResult},
NumExpr,
};
#[allow(unused_imports)]
use multiversx_sc_snippets::multiversx_sc::types::{
EsdtTokenPayment, MultiValueEncoded, TokenIdentifier,
};
use multiversx_sc_snippets::multiversx_sc_scenario::{
mandos_system::ScenarioRunner, scenario_format::interpret_trait::InterpretableFrom,
standalone::retrieve_account_as_scenario_set_state,
};
use multiversx_sc_snippets::imports::*;

use super::*;

Expand Down
19 changes: 3 additions & 16 deletions contracts/examples/multisig/tests/multisig_blackbox_test.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
use multiversx_sc::codec::top_encode_to_vec_u8_or_panic;
use multiversx_sc_scenario::imports::*;

use adder::ProxyTrait as _;
use multisig::{
multisig_perform::ProxyTrait as _, multisig_propose::ProxyTrait as _, user_role::UserRole,
ProxyTrait as _,
};
use multiversx_sc::{
codec::{
multi_types::{MultiValueVec, OptionalValue},
test_util::top_encode_to_vec_u8_or_panic,
},
storage::mappers::SingleValue,
types::{Address, AddressExpr, CodeMetadata, FunctionCall, ReturnsResult},
};
use multiversx_sc_scenario::{
api::StaticApi,
scenario_model::{
Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep,
SetStateStep, TxExpect,
},
ContractInfo, ScenarioTxRun, ScenarioWorld,
};
use num_bigint::BigUint;

const ADDER_ADDRESS_EXPR: &str = "sc:adder";
Expand Down
21 changes: 1 addition & 20 deletions contracts/examples/multisig/tests/multisig_whitebox_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(unused)]

use multiversx_sc_scenario::imports::*;
use std::borrow::Borrow;

use adder::Adder;
Expand All @@ -8,26 +9,6 @@ use multisig::{
multisig_perform::MultisigPerformModule, multisig_propose::MultisigProposeModule,
user_role::UserRole, Multisig,
};
use multiversx_sc::{
api::ManagedTypeApi,
codec::multi_types::OptionalValue,
storage::mappers::SingleValue,
types::{
Address, BigUint, BoxedBytes, CodeMetadata, FunctionCall, ManagedAddress, ManagedBuffer,
ManagedVec,
},
};
use multiversx_sc_scenario::{
managed_address, managed_biguint,
multiversx_chain_vm::types::VMAddress,
rust_biguint,
scenario_model::{
Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep,
SetStateStep, TxExpect, TypedScQuery,
},
testing_framework::TxResult,
DebugApi, ScenarioWorld, WhiteboxContract,
};

const OWNER_ADDRESS_EXPR: &str = "address:owner";
const PROPOSER_ADDRESS_EXPR: &str = "address:proposer";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
mod mock_seed_nft_minter;
mod utils;

use multiversx_sc_scenario::imports::*;
use std::iter::zip;

use multiversx_sc::{
codec::multi_types::MultiValue2,
storage::mappers::SingleValue,
types::{
Address, BigUint, EgldOrEsdtTokenIdentifier, ManagedVec, MultiValueEncoded,
OperationCompletionStatus, TokenIdentifier,
},
};
use multiversx_sc_scenario::{
api::StaticApi,
scenario_model::{
Account, AddressValue, CheckAccount, CheckStateStep, ScCallStep, ScDeployStep, ScQueryStep,
SetStateStep, TxESDT, TypedResponse,
},
ContractInfo, DebugApi, ScenarioWorld, WhiteboxContract,
};

use crate::mock_seed_nft_minter::ProxyTrait as _;
use rewards_distribution::{
Bracket, ContractObj, ProxyTrait as _, RewardsDistribution, DIVISION_SAFETY_CONSTANT,
Expand Down
10 changes: 2 additions & 8 deletions contracts/feature-tests/abi-tester/src/abi_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,7 @@ pub enum AbiEnum {
Nothing,
Something(i32),
SomethingMore(u8, OnlyShowsUpAsNested08),
SomeStruct {
a: u16,
b: OnlyShowsUpAsNested09,
},
SomeStruct { a: u16, b: OnlyShowsUpAsNested09 },
}

#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
Expand Down Expand Up @@ -509,8 +506,5 @@ pub enum ExplicitDiscriminantMixed {
Unit,
Tuple(u16),
Five,
Struct {
a: u8,
b: u16,
},
Struct { a: u8, b: u16 },
}
16 changes: 2 additions & 14 deletions contracts/feature-tests/basic-features/interact/src/bf_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,8 @@ use basic_features::{
use bf_interact_config::Config;
use bf_interact_state::State;
use clap::Parser;
use multiversx_sc_snippets::{
env_logger,
multiversx_sc::{codec::multi_types::IgnoreValue, types::Address},
multiversx_sc_scenario::{
api::StaticApi,
bech32,
mandos_system::ScenarioRunner,
scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext},
scenario_model::{BytesValue, ScCallStep, ScDeployStep, Scenario, TxExpect},
standalone::retrieve_account_as_scenario_set_state,
test_wallets, ContractInfo,
},
tokio, Interactor,
};

use multiversx_sc_snippets::imports::*;

const INTERACTOR_SCENARIO_TRACE_PATH: &str = "interactor_trace.scen.json";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use multiversx_sc::types::{ManagedAddress, ManagedBuffer};
use multiversx_sc_scenario::{api::StaticApi, *};
use multiversx_sc_scenario::imports::*;

use basic_features::managed_buffer_features::ManagedBufferFeatures;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use multiversx_sc::types::{BigUint, ManagedVec};
use multiversx_sc_scenario::{api::StaticApi, *};
use multiversx_sc_scenario::imports::*;

use basic_features::managed_vec_features::ManagedVecFeatures;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#![allow(deprecated)]

use basic_features::BasicFeatures;
use multiversx_sc::imports::{OrderedBinaryTreeNode, NULL_NODE_ID};
use multiversx_sc_scenario::{
managed_biguint, rust_biguint, testing_framework::BlockchainStateWrapper,
};

use multiversx_sc_scenario::imports::*;

#[test]
fn ordered_binary_tree_test() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use multiversx_sc::types::{EgldOrEsdtTokenIdentifier, ManagedBuffer, TokenIdentifier};
use multiversx_sc_scenario::{api::StaticApi, *};
use multiversx_sc_scenario::imports::*;

use basic_features::token_identifier_features::TokenIdentifierFeatures;

Expand Down
Loading

0 comments on commit 4ffca0e

Please sign in to comment.