diff --git a/contracts/examples/adder/interact/src/basic_interact.rs b/contracts/examples/adder/interact/src/basic_interact.rs index 7042df9781..27a3bbb166 100644 --- a/contracts/examples/adder/interact/src/basic_interact.rs +++ b/contracts/examples/adder/interact/src/basic_interact.rs @@ -83,7 +83,12 @@ impl AdderInteract { ) .await; - interactor.proxy.generate_blocks(1).await.unwrap(); + // generate blocks until ESDTSystemSCAddress is enabled + interactor + .proxy + .generate_blocks_until_epoch(1) + .await + .unwrap(); Self { interactor, diff --git a/sdk/core/src/gateway/gateway_chain_simulator.rs b/sdk/core/src/gateway/gateway_chain_simulator.rs index 9c9e75b819..c6670f9703 100644 --- a/sdk/core/src/gateway/gateway_chain_simulator.rs +++ b/sdk/core/src/gateway/gateway_chain_simulator.rs @@ -5,9 +5,11 @@ use anyhow::{anyhow, Error}; use serde::{Deserialize, Serialize}; const SEND_USER_FUNDS_ENDPOINT: &str = "transaction/send-user-funds"; -const GENERATE_BLOCKS_FUNDS_ENDPOINT: &str = "simulator/generate-blocks"; +const GENERATE_BLOCKS_ENDPOINT: &str = "simulator/generate-blocks"; const GENERATE_BLOCKS_UNTIL_TX_PROCESSED_ENDPOINT: &str = "simulator/generate-blocks-until-transaction-processed"; +const GENERATE_BLOCKS_UNTIL_EPOCH_REACHED_ENDPOINT: &str = + "simulator/generate-blocks-until-epoch-reached"; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GenerateBlocksResponse { @@ -45,9 +47,32 @@ impl GatewayProxy { return Ok(String::from("no-simulator")); } - let url_gen_blocks: String = - format!("{}/{}", GENERATE_BLOCKS_FUNDS_ENDPOINT, number_blocks); - let endpoint_blocks = self.get_endpoint(&url_gen_blocks); + let uri_gen_blocks: String = format!("{}/{}", GENERATE_BLOCKS_ENDPOINT, number_blocks); + let endpoint_blocks = self.get_endpoint(&uri_gen_blocks); + let resp = self + .client + .post(endpoint_blocks) + .send() + .await? + .json::() + .await?; + + match resp.code.as_str() { + "successful" => Ok(resp.code), + _ => Err(anyhow!("{}", resp.error)), + } + } + + pub async fn generate_blocks_until_epoch(&self, epoch_number: u64) -> Result { + if !self.chain_simulator { + return Ok(String::from("no-simulator")); + } + + let uri_gen_blocks_until_reached_epoch: String = format!( + "{}/{}", + GENERATE_BLOCKS_UNTIL_EPOCH_REACHED_ENDPOINT, epoch_number + ); + let endpoint_blocks = self.get_endpoint(&uri_gen_blocks_until_reached_epoch); let resp = self .client .post(endpoint_blocks) diff --git a/tools/interactor-system-func-calls/config.toml b/tools/interactor-system-func-calls/config.toml index dfc1ba62a6..c6f9a97a1d 100644 --- a/tools/interactor-system-func-calls/config.toml +++ b/tools/interactor-system-func-calls/config.toml @@ -1,2 +1,5 @@ +# chain_type = 'simulator' +# gateway_uri = 'http://localhost:8085' + chain_type = 'real' gateway_uri = 'https://devnet-gateway.multiversx.com' diff --git a/tools/interactor-system-func-calls/src/system_sc_interact.rs b/tools/interactor-system-func-calls/src/system_sc_interact.rs index dbfa11a14e..e3ba495a2c 100644 --- a/tools/interactor-system-func-calls/src/system_sc_interact.rs +++ b/tools/interactor-system-func-calls/src/system_sc_interact.rs @@ -232,6 +232,13 @@ impl SysFuncCallsInteract { let wallet_address = interactor.register_wallet(test_wallets::alice()).await; + // generate blocks until ESDTSystemSCAddress is enabled + interactor + .proxy + .generate_blocks_until_epoch(1) + .await + .unwrap(); + Self { interactor, wallet_address: wallet_address.into(),