Skip to content

Commit

Permalink
Merge branch 'master' into sc-meta-compare
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca authored May 23, 2024
2 parents 8f3d791 + 27635af commit 71ca308
Show file tree
Hide file tree
Showing 71 changed files with 104 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/benchmarks/large-storage");
blockchain.register_contract(
"mxsc:output/large-storage.mxsc.json",
large_storage::ContractBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const WASM_PATH_EXPR: &str = "mxsc:output/linked-list-repeat.mxsc.json";

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/benchmarks/mappers/linked-list-repeat");

blockchain.register_contract(WASM_PATH_EXPR, linked_list_repeat::ContractBuilder);
blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/benchmarks/mappers/linked-list-repeat");

blockchain.register_contract(
"mxsc:output/linked-list-repeat.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/benchmarks/mappers/map-repeat");

blockchain.register_contract(
"mxsc:output/map-repeat.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/benchmarks/mappers/queue-repeat");

blockchain.register_contract(
"mxsc:output/queue-repeat.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/benchmarks/mappers/set-repeat");

blockchain.register_contract(
"mxsc:output/set-repeat.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/benchmarks/mappers/single-value-repeat");

blockchain.register_contract(
"mxsc:output/single-value-repeat.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/benchmarks/mappers/vec-repeat");

blockchain.register_contract(
"mxsc:output/vec-repeat.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const PRICE_AGGREGATOR_PATH: MxscPath =
fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();

blockchain.set_current_dir_from_workspace("contracts/core/price-aggregator");
blockchain.register_contract(
PRICE_AGGREGATOR_PATH,
multiversx_price_aggregator_sc::ContractBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const PRICE_AGGREGATOR_PATH_EXPR: &str = "mxsc:output/multiversx-price-aggregato
fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();

blockchain.set_current_dir_from_workspace("contracts/core/price-aggregator");
blockchain.register_contract(
PRICE_AGGREGATOR_PATH_EXPR,
multiversx_price_aggregator_sc::ContractBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/core/wegld-swap");

blockchain.register_contract(
"mxsc:output/multiversx-wegld-swap-sc.mxsc.json",
Expand Down
1 change: 0 additions & 1 deletion contracts/examples/adder/tests/adder_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const CODE_PATH: MxscPath = MxscPath::new("output/adder.mxsc.json");

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/adder");

blockchain.register_contract(CODE_PATH, adder::ContractBuilder);
blockchain
Expand Down
1 change: 0 additions & 1 deletion contracts/examples/adder/tests/adder_scenario_rs_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/adder");

blockchain.register_contract("mxsc:output/adder.mxsc.json", adder::ContractBuilder);
blockchain
Expand Down
1 change: 0 additions & 1 deletion contracts/examples/adder/tests/adder_whitebox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const ADDER_PATH_EXPR: &str = "mxsc:output/adder.mxsc.json";

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/adder");

blockchain.register_contract("mxsc:output/adder.mxsc.json", adder::ContractBuilder);
blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/crowdfunding-esdt");

blockchain.register_contract(
"mxsc:output/crowdfunding-esdt.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/crypto-bubbles");

blockchain.register_contract(
"mxsc:output/crypto-bubbles.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/digital-cash");

blockchain.register_contract(
"mxsc:output/digital-cash.mxsc.json",
Expand Down
1 change: 0 additions & 1 deletion contracts/examples/empty/tests/empty_scenario_rs_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/empty");

blockchain.register_contract("mxsc:output/empty.mxsc.json", empty::ContractBuilder);
blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/esdt-transfer-with-fee");

blockchain.register_contract(
"mxsc:output/esdt-transfer-with-fee.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/factorial");

blockchain.register_contract(
"mxsc:output/factorial.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/lottery-esdt");

blockchain.register_contract(
"mxsc:output/lottery-esdt.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const QUORUM_SIZE: usize = 1;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/multisig");

blockchain.register_contract(MULTISIG_CODE_PATH, multisig::ContractBuilder);
blockchain.register_contract(ADDER_CODE_PATH, adder::ContractBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const WEGLD_SWAP_EXPR: &str = "0x0061736d0100000001661160000060017f0060027f7f017

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/multisig");

blockchain.register_partial_contract::<multisig::AbiProvider, _>(
"mxsc:output/multisig.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ pub struct CallActionDataRaw {

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/multisig");

blockchain.register_contract(MULTISIG_PATH_EXPR, multisig::ContractBuilder);
blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/nft-minter");

blockchain.register_contract(
"mxsc:output/nft-minter.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/nft-subscription");

blockchain.register_contract(
"mxsc:output/nft-subscription.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/order-book/pair");

blockchain.register_contract(
"mxsc:output/order-book-pair.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/ping-pong-egld");

blockchain.register_contract(
"mxsc:output/ping-pong-egld.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/proxy-pause");

blockchain.register_contract(
"mxsc:output/proxy-pause.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/examples/token-release");

blockchain.register_contract(
"mxsc:output/token-release.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use multiversx_sc_scenario::ScenarioWorld;

#[test]
fn abi_tester_abi_generated_ok() {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/feature-tests/abi-tester");
let blockchain = ScenarioWorld::new();

// generate ABI
let multi_contract_config = multiversx_sc_meta::multi_contract_config::<abi_tester::AbiProvider>(
Expand Down Expand Up @@ -72,7 +71,6 @@ fn abi_tester_esdt_attr_abi_generated_ok() {
#[test]
fn check_multi_contract_config() {
let mut blockchain = ScenarioWorld::new();

Check warning on line 73 in contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs

View workflow job for this annotation

GitHub Actions / Contracts / Rust tests

variable does not need to be mutable

Check warning on line 73 in contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs

View workflow job for this annotation

GitHub Actions / Contracts (nightly) / Rust tests

variable does not need to be mutable

Check warning on line 73 in contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs

View workflow job for this annotation

GitHub Actions / Contracts / Test Coverage

variable does not need to be mutable

Check warning on line 73 in contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs

View workflow job for this annotation

GitHub Actions / Contracts (nightly) / Wasm tests

variable does not need to be mutable

Check warning on line 73 in contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs

View workflow job for this annotation

GitHub Actions / Contracts / Wasm tests

variable does not need to be mutable

Check warning on line 73 in contracts/feature-tests/abi-tester/tests/abi_tester_abi_test.rs

View workflow job for this annotation

GitHub Actions / Contracts (nightly) / Test Coverage

variable does not need to be mutable
blockchain.set_current_dir_from_workspace("contracts/feature-tests/abi-tester");

let multi_contract_config = multiversx_sc_meta::multi_contract_config::<abi_tester::AbiProvider>(
blockchain.current_dir().as_path(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/feature-tests/alloc-features");

blockchain.register_partial_contract::<alloc_features::AbiProvider, _>(
"mxsc:output/alloc-features.mxsc.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,71 @@
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "fill unordered set mapper",
"tx": {
"from": "address:an_account",
"to": "sc:to-be-called",
"function": "fill_unordered_set_mapper",
"arguments": [
"10"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "contains unordered at address",
"tx": {
"from": "address:an_account",
"to": "sc:caller",
"function": "contains_unordered_at_address",
"arguments": ["5"],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0x01"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "get by index at address",
"tx": {
"from": "address:an_account",
"to": "sc:caller",
"function": "get_by_index",
"arguments": [
"5"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"5"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ pub trait StorageMapperGetAtAddress {
mapper.values().collect()
}

#[endpoint]
fn contains_unordered_at_address(&self, item: u32) -> bool {
let address = self.contract_address().get();
let mapper: UnorderedSetMapper<u32, _> =
UnorderedSetMapper::new_from_address(address, StorageKey::from("unordered_set_mapper"));
mapper.contains(&item)
}

#[endpoint]
fn get_by_index(&self, index: usize) -> u32 {
let address = self.contract_address().get();
let mapper: UnorderedSetMapper<u32, _> =
UnorderedSetMapper::new_from_address(address, StorageKey::from("unordered_set_mapper"));
mapper.get_by_index(index)
}

/// Storage to be called. For testing, this contract is deployed twice,
/// and this module acts both as caller and receiver
#[storage_mapper("set_mapper")]
Expand All @@ -94,6 +110,9 @@ pub trait StorageMapperGetAtAddress {
#[storage_mapper("map_mapper")]
fn map_mapper(&self) -> MapMapper<u32, u32>;

#[storage_mapper("unordered_set_mapper")]
fn unordered_set_mapper(&self) -> UnorderedSetMapper<u32>;

#[endpoint]
fn fill_set_mapper(&self, value: u32) {
for item in 1u32..=value {
Expand All @@ -108,4 +127,11 @@ pub trait StorageMapperGetAtAddress {
self.map_mapper().insert(key, item);
}
}

#[endpoint]
fn fill_unordered_set_mapper(&self, value: u32) {
for item in 1u32..=value {
self.unordered_set_mapper().insert(item);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use multiversx_sc_scenario::*;

fn world() -> ScenarioWorld {
let mut blockchain = ScenarioWorld::new();
blockchain.set_current_dir_from_workspace("contracts/feature-tests/basic-features");

blockchain.register_contract(
"mxsc:output/basic-features.mxsc.json",
Expand Down
Loading

0 comments on commit 71ca308

Please sign in to comment.