-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1732 from multiversx/test-managed-option-gen-proxy
Test for ManagedOption type name
- Loading branch information
Showing
5 changed files
with
72 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
contracts/feature-tests/basic-features/tests/basic_features_managed_option_test.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use imports::{MxscPath, ReturnsResult, TestAddress, TestSCAddress}; | ||
use multiversx_sc::types::{BigUint, ManagedOption}; | ||
use multiversx_sc_scenario::{api::StaticApi, imports, ScenarioTxRun, ScenarioWorld}; | ||
|
||
const OWNER_ADDRESS: TestAddress = TestAddress::new("owner"); | ||
const BASIC_FEATURES_ADDRESS: TestSCAddress = TestSCAddress::new("basic-features"); | ||
const BASIC_FEATURES_PATH: MxscPath = MxscPath::new("output/basic-features.mxsc.json"); | ||
|
||
fn world() -> ScenarioWorld { | ||
let mut blockchain = ScenarioWorld::new(); | ||
|
||
blockchain.register_contract(BASIC_FEATURES_PATH, basic_features::ContractBuilder); | ||
|
||
blockchain.account(OWNER_ADDRESS).nonce(1); | ||
blockchain | ||
.account(BASIC_FEATURES_ADDRESS) | ||
.nonce(1) | ||
.code(BASIC_FEATURES_PATH); | ||
|
||
blockchain | ||
} | ||
|
||
#[test] | ||
fn managed_option_test() { | ||
let mut world = world(); | ||
|
||
let type_number: BigUint<StaticApi> = BigUint::zero(); | ||
let expected_type_managed_option: ManagedOption<StaticApi, BigUint<StaticApi>> = | ||
ManagedOption::some(type_number); | ||
|
||
let output = world | ||
.tx() | ||
.from(OWNER_ADDRESS) | ||
.to(BASIC_FEATURES_ADDRESS) | ||
.typed(basic_features::basic_features_proxy::BasicFeaturesProxy) | ||
.echo_managed_option(expected_type_managed_option.clone()) | ||
.returns(ReturnsResult) | ||
.run(); | ||
|
||
assert_eq!(output, expected_type_managed_option); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters