Skip to content

Commit

Permalink
storage_mapper_from_addr - test
Browse files Browse the repository at this point in the history
  • Loading branch information
BiancaIalangi committed Jun 21, 2024
1 parent 4fee541 commit d5d9c64
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,29 @@
"refund": "*"
}
},
{
"step": "scCall",
"id": "len at address",
"tx": {
"from": "address:an_account",
"to": "sc:caller",
"function": "len_at_addresses",
"arguments": [
"sc:to-be-called"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
"expect": {
"out": [
"0"
],
"status": "",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "next at address",
Expand Down Expand Up @@ -332,7 +355,9 @@
"from": "address:an_account",
"to": "sc:caller",
"function": "contains_unordered_at_address",
"arguments": ["5"],
"arguments": [
"5"
],
"gasLimit": "50,000,000",
"gasPrice": "0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ pub trait StorageMapperGetAtAddress {
self.set_mapper_from_address(address).is_empty()
}

#[endpoint]
fn len_at_addresses(&self, address: ManagedAddress) -> usize {
let contract_address = self.contract_address().get();
self.set_mapper_from_address_with_keys(contract_address, address)
.len()
}

#[endpoint]
fn contains_at_address(&self, item: u32) -> bool {
let address = self.contract_address().get();
Expand Down Expand Up @@ -90,6 +97,13 @@ pub trait StorageMapperGetAtAddress {
#[storage_mapper_from_address("set_mapper")]
fn set_mapper_from_address(&self, address: ManagedAddress) -> SetMapper<u32, ManagedAddress>;

#[storage_mapper_from_address("set_mapper")]
fn set_mapper_from_address_with_keys(
&self,
address1: ManagedAddress,
address2: ManagedAddress,
) -> SetMapper<u32, ManagedAddress>;

#[storage_mapper("map_mapper")]
fn map_mapper(&self) -> MapMapper<u32, u32>;

Expand Down
5 changes: 3 additions & 2 deletions contracts/feature-tests/basic-features/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
////////////////////////////////////////////////////

// Init: 1
// Endpoints: 389
// Endpoints: 390
// Async Callback: 1
// Total number of exported functions: 391
// Total number of exported functions: 392

#![no_std]

Expand Down Expand Up @@ -394,6 +394,7 @@ multiversx_sc_wasm_adapter::endpoints! {
non_zero_usize_macro => non_zero_usize_macro
set_contract_address => set_contract_address
is_empty_at_address => is_empty_at_address
len_at_addresses => len_at_addresses
contains_at_address => contains_at_address
len_at_address => len_at_address
next_at_address => next_at_address
Expand Down

0 comments on commit d5d9c64

Please sign in to comment.