-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce
index()
and index_assign()
to StorageMap
and showcase…
… nested maps using both `get/insert` and the `[]` operator
- Loading branch information
1 parent
be85a10
commit 893905a
Showing
7 changed files
with
414 additions
and
55 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
13 changes: 13 additions & 0 deletions
13
test/src/sdk-harness/test_projects/experimental_storage_nested_maps/Forc.lock
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,13 @@ | ||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-2064A4F50B965AB3' | ||
|
||
[[package]] | ||
name = 'experimental_storage_nested_maps' | ||
source = 'member' | ||
dependencies = ['std'] | ||
|
||
[[package]] | ||
name = 'std' | ||
source = 'path+from-root-2064A4F50B965AB3' | ||
dependencies = ['core'] |
8 changes: 8 additions & 0 deletions
8
test/src/sdk-harness/test_projects/experimental_storage_nested_maps/Forc.toml
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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "experimental_storage_nested_maps" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../sway-lib-std" } |
51 changes: 51 additions & 0 deletions
51
test/src/sdk-harness/test_projects/experimental_storage_nested_maps/mod.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,51 @@ | ||
use fuels::prelude::*; | ||
|
||
abigen!(Contract( | ||
name = "TestExperimentalStorageNestedMapsContract", | ||
abi = "test_projects/experimental_storage_nested_maps/out/debug/experimental_storage_nested_maps-abi.json", | ||
)); | ||
|
||
async fn test_experimental_storage_nested_maps_instance( | ||
) -> TestExperimentalStorageNestedMapsContract { | ||
let wallet = launch_provider_and_get_wallet().await; | ||
let id = Contract::deploy( | ||
"test_projects/experimental_storage_nested_maps/out/debug/experimental_storage_nested_maps.bin", | ||
&wallet, | ||
TxParameters::default(), | ||
StorageConfiguration::with_storage_path(Some( | ||
"test_projects/experimental_storage_nested_maps/out/debug/experimental_storage_nested_maps-storage_slots.json" | ||
.to_string(), | ||
)), | ||
) | ||
.await | ||
.unwrap(); | ||
|
||
TestExperimentalStorageNestedMapsContract::new(id.clone(), wallet) | ||
} | ||
|
||
#[tokio::test] | ||
async fn nested_map_1_access() { | ||
let methods = test_experimental_storage_nested_maps_instance() | ||
.await | ||
.methods(); | ||
|
||
methods.nested_map_1_access().call().await.unwrap(); | ||
} | ||
|
||
#[tokio::test] | ||
async fn nested_map_2_access() { | ||
let methods = test_experimental_storage_nested_maps_instance() | ||
.await | ||
.methods(); | ||
|
||
methods.nested_map_2_access().call().await.unwrap(); | ||
} | ||
|
||
#[tokio::test] | ||
async fn nested_map_3_access() { | ||
let methods = test_experimental_storage_nested_maps_instance() | ||
.await | ||
.methods(); | ||
|
||
methods.nested_map_3_access().call().await.unwrap(); | ||
} |
Oops, something went wrong.