Skip to content

Commit

Permalink
Merge pull request #1855 from multiversx/interactor-use-cs
Browse files Browse the repository at this point in the history
Interactor - use_chain_simulator builder method
  • Loading branch information
andrei-marinica authored Nov 13, 2024
2 parents 5f93fc1 + 1a4fb4e commit 5d47571
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion contracts/examples/adder/interact/src/basic_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ pub struct AdderInteract {

impl AdderInteract {
pub async fn init(config: Config) -> Self {
let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator())
let mut interactor = Interactor::new(config.gateway_uri())
.await
.use_chain_simulator(config.use_chain_simulator())
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ struct MultisigInteract {
impl MultisigInteract {
async fn init() -> Self {
let config = Config::load_config();
let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator())
let mut interactor = Interactor::new(config.gateway_uri())
.await
.use_chain_simulator(config.use_chain_simulator())
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;
interactor.set_current_dir_from_workspace("contracts/examples/multisig/interact");
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/ping-pong-egld/dapp/src/interactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct ContractInteract {
impl ContractInteract {
pub async fn new() -> Self {
let config = Config::new();
let mut interactor = DappInteractor::new(&config.gateway, false).await;
let mut interactor = DappInteractor::new(&config.gateway).await;
interactor.set_current_dir_from_workspace("contracts/examples/ping-pong-egld/dapp");
let wallet_address = interactor.register_wallet(test_wallets::mike()).await;

Expand Down
3 changes: 2 additions & 1 deletion contracts/examples/ping-pong-egld/interactor/src/interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ pub struct PingPongEgldInteract {

impl PingPongEgldInteract {
pub async fn init(config: Config) -> Self {
let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator())
let mut interactor = Interactor::new(config.gateway_uri())
.await
.use_chain_simulator(config.use_chain_simulator())
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ pub struct BasicFeaturesInteract {

impl BasicFeaturesInteract {
pub async fn init(config: Config) -> Self {
let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator())
let mut interactor = Interactor::new(config.gateway_uri())
.await
.use_chain_simulator(config.use_chain_simulator())
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;
interactor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ pub struct ComposabilityInteract {
impl ComposabilityInteract {
pub async fn init() -> Self {
let config = Config::load_config();
let mut interactor = Interactor::new(config.gateway_uri(), config.use_chain_simulator())
let mut interactor = Interactor::new(config.gateway_uri())
.await
.use_chain_simulator(config.use_chain_simulator())
.with_tracer(INTERACTOR_SCENARIO_TRACE_PATH)
.await;
interactor.set_current_dir_from_workspace("contracts/feature-tests/composability/interact");
Expand Down
9 changes: 7 additions & 2 deletions framework/snippets/src/interactor/interactor_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ where
GatewayProxy: GatewayAsyncService,
{
/// Not yet changed for backwards compatibility.
pub async fn new(gateway_uri: &str, use_chain_simulator: bool) -> Self {
pub async fn new(gateway_uri: &str) -> Self {
let proxy = GatewayProxy::from_uri(gateway_uri);
let network_config = proxy.request(NetworkConfigRequest).await.unwrap();
Self {
proxy,
use_chain_simulator,
use_chain_simulator: false,
network_config,
sender_map: HashMap::new(),
waiting_time_ms: 0,
Expand All @@ -52,6 +52,11 @@ where
}
}

pub fn use_chain_simulator(mut self, use_chain_simulator: bool) -> Self {
self.use_chain_simulator = use_chain_simulator;
self
}

pub async fn register_wallet(&mut self, wallet: Wallet) -> Address {
let address = wallet.to_address();

Expand Down
5 changes: 3 additions & 2 deletions tools/interactor-system-func-calls/src/system_sc_interact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ struct SysFuncCallsInteract {
impl SysFuncCallsInteract {
async fn init() -> Self {
let config = Config::load_config();
let mut interactor =
Interactor::new(config.gateway_uri(), config.use_chain_simulator()).await;
let mut interactor = Interactor::new(config.gateway_uri())
.await
.use_chain_simulator(config.use_chain_simulator());

interactor.set_current_dir_from_workspace("tools/interactor-system-func-calls");
let wallet_address = interactor.register_wallet(test_wallets::alice()).await;
Expand Down

0 comments on commit 5d47571

Please sign in to comment.