Skip to content

Commit

Permalink
Merge pull request #20
Browse files Browse the repository at this point in the history
Re-exported ScenarioWorld in novax_executor and use it instead of the one from mx-sdk-rs
  • Loading branch information
gfusee authored Nov 10, 2023
2 parents 4662bdc + 9005f62 commit 0f38ef6
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ pub use dummy::transaction::DummyTransactionExecutor;
pub use dummy::transaction::DummyDeployExecutor;

pub use utils::transaction::data::SendableTransaction;
pub use utils::transaction::data::SendableTransactionConvertible;
pub use utils::transaction::data::SendableTransactionConvertible;

pub use multiversx_sc_scenario::ScenarioWorld;
pub use multiversx_sc_scenario::scenario_model::{ScCallStep, ScDeployStep, ScQueryStep, SetStateStep, Account, TxQuery, TxResponse, TypedScCall, TypedScDeploy, TypedScQuery, TypedResponse};
4 changes: 2 additions & 2 deletions executor/src/mocking/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::ops::Deref;
use std::sync::Arc;
use async_trait::async_trait;
use multiversx_sc::codec::{TopDecodeMulti, TopEncodeMulti};
use multiversx_sc_scenario::scenario_model::{ScCallStep, ScDeployStep, ScQueryStep, TxQuery, TypedScCall, TypedScDeploy, TypedScQuery};
use multiversx_sc_scenario::ScenarioWorld;
use crate::{ScCallStep, ScDeployStep, ScQueryStep, TxQuery, TypedScCall, TypedScDeploy, TypedScQuery};
use crate::ScenarioWorld;
use tokio::sync::{Mutex, MutexGuard};
use novax_data::Address;
use novax_data::NativeConvertible;
Expand Down
2 changes: 1 addition & 1 deletion mocking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ async-trait = "0.1.72"
tokio = "1.30.0"
novax = { path = "../core", version = "0.0.9" }
novax-token = { path = "../token", version = "0.0.9" }
novax-executor = { path = "../executor", version = "0.0.9" }
multiversx-sc = "0.43.2"
multiversx-sc-snippets = "0.43.2"
multiversx-sdk = "0.2.0"
multiversx-sc-scenario = "0.43.2"
reqwest = "0.11.18"
serde = "1.0.180"
serde_json = "1.0.104"
Expand Down
16 changes: 8 additions & 8 deletions mocking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ pub mod errors;

pub use multiversx_sc::codec::TopEncodeMulti;
pub use multiversx_sc::codec::CodecFrom;
pub use multiversx_sc_scenario::scenario_model::TypedResponse;
pub use multiversx_sc_scenario::ScenarioWorld;
pub use multiversx_sc_scenario::scenario_model::TypedScDeploy;
pub use multiversx_sc_scenario::scenario_model::TxResponse;
pub use multiversx_sc_scenario::scenario_model::ScCallStep;
pub use multiversx_sc_scenario::scenario_model::ScDeployStep;
pub use multiversx_sc_scenario::scenario_model::SetStateStep;
pub use multiversx_sc_scenario::scenario_model::Account;
pub use novax_executor::TypedResponse;
pub use novax_executor::ScenarioWorld;
pub use novax_executor::TypedScDeploy;
pub use novax_executor::TxResponse;
pub use novax_executor::ScCallStep;
pub use novax_executor::ScDeployStep;
pub use novax_executor::SetStateStep;
pub use novax_executor::Account;
6 changes: 3 additions & 3 deletions mocking/src/world/infos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ use std::fs::OpenOptions;
use std::future::join;
use std::hash::Hash;
use std::path::Path;
use multiversx_sc_scenario::scenario_model::{Account, BytesKey, BytesValue, SetStateStep};
use multiversx_sc_scenario::ScenarioWorld;
use num_bigint::BigUint;
use futures::future::join_all;
use multiversx_sc_scenario::scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext};
use multiversx_sc_snippets::hex;
use multiversx_sc_snippets::multiversx_sc_scenario::scenario_format::interpret_trait::{InterpretableFrom, InterpreterContext};
use multiversx_sc_snippets::multiversx_sc_scenario::scenario_model::{BytesKey, BytesValue};
use novax::errors::NovaXError;
use serde::{Deserialize, Serialize};
use novax::account::AccountInfos;
Expand All @@ -17,6 +16,7 @@ use novax_token::account::balance::{FetchAllTokens, TokenInfos};
use novax_token::error::token::TokenError;
use crate::errors::mocking::NovaXMockingError;
use crate::gateway::keys::AddressKeys;
use crate::{Account, ScenarioWorld, SetStateStep};
use crate::world::serde::ScenarioWorldInfosJson;

type BalanceAsyncResults = Vec<Result<([u8;32], Vec<TokenInfos>), TokenError>>;
Expand Down
13 changes: 13 additions & 0 deletions tester/core/tests/mock_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use novax_mocking::world::infos::ScenarioWorldInfos;
use num_bigint::BigUint;
use novax::tester::tester::{CustomEnum, CustomEnumWithFields, CustomEnumWithValues, CustomStruct, CustomStructWithStructAndVec, TesterContract};
use novax::executor::StandardMockExecutor;
use novax_mocking::ScenarioWorld;

const CALLER: &str = "bech32:erd1h4uhy73dev6qrfj7wxsguapzs8632mfwqjswjpsj6kzm2jfrnslqsuduqu";
const TESTER_CONTRACT_ADDRESS: &str = "bech32:erd1qqqqqqqqqqqqqpgq9wmk04e90fkhcuzns0pgwm33sdtxze346vpsq0ka9p";
Expand Down Expand Up @@ -39,6 +40,18 @@ fn get_executor_without_caller() -> Arc<Mutex<StandardMockExecutor>> {
Arc::new(Mutex::new(executor))
}

// useless, should compile only
// allow to test ScenarioWorld re-export
#[allow(dead_code)]
fn get_useless_executor() -> StandardMockExecutor {
let world = ScenarioWorld::new();

StandardMockExecutor::new(
Arc::new(Mutex::new(world)),
None
)
}

#[tokio::test]
async fn test_call_return_caller() -> Result<(), NovaXError> {
let executor = get_executor();
Expand Down

0 comments on commit 0f38ef6

Please sign in to comment.