From ba0f47d8a57d744838b9f35f6f1deba6a2a611fd Mon Sep 17 00:00:00 2001 From: Samuel Moelius <35515885+smoelius@users.noreply.github.com> Date: Fri, 2 Feb 2024 08:43:14 -0500 Subject: [PATCH 1/2] Fix "Testing with Rust / Writing Tests" example --- docs/book/src/testing/testing-with-rust.md | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/book/src/testing/testing-with-rust.md b/docs/book/src/testing/testing-with-rust.md index ff1befdd8f4..70baff49313 100644 --- a/docs/book/src/testing/testing-with-rust.md +++ b/docs/book/src/testing/testing-with-rust.md @@ -173,10 +173,13 @@ following: ```rust,ignore use fuels::{prelude::*, types::ContractId}; -// Load ABI from JSON -abigen!(TestContract, "out/debug/my-fuel-project-abi.json"); +// Load abi from json +abigen!(Contract( + name = "MyContract", + abi = "out/debug/my-fuel-project-abi.json" +)); -async fn get_contract_instance() -> (TestContract, ContractId) { +async fn get_contract_instance() -> (MyContract, ContractId) { // Launch a local network and deploy the contract let mut wallets = launch_custom_provider_and_get_wallets( WalletsConfig::new( @@ -185,25 +188,22 @@ async fn get_contract_instance() -> (TestContract, ContractId) { Some(1_000_000_000), /* Amount per coin */ ), None, + None, ) - .await; + .await + .unwrap(); let wallet = wallets.pop().unwrap(); let id = Contract::load_from( "./out/debug/my-fuel-project.bin", - LoadConfiguration::default().set_storage_configuration( - StorageConfiguration::load_from( - "./out/debug/my-fuel-project-storage_slots.json", - ) - .unwrap(), - ), + LoadConfiguration::default(), ) .unwrap() - .deploy(&wallet, TxParameters::default()) + .deploy(&wallet, TxPolicies::default()) .await .unwrap(); - let instance = TestContract::new(id.to_string(), wallet); + let instance = MyContract::new(id.clone(), wallet); (instance, id.into()) } From d8c5d85aac9e63232a2c298eafb84cd56d289296 Mon Sep 17 00:00:00 2001 From: Sophie Dankel <47993817+sdankel@users.noreply.github.com> Date: Mon, 9 Sep 2024 13:55:21 -0700 Subject: [PATCH 2/2] Apply suggestions from code review --- docs/book/src/testing/testing-with-rust.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/book/src/testing/testing-with-rust.md b/docs/book/src/testing/testing-with-rust.md index 886e96605be..d87402f9c7d 100644 --- a/docs/book/src/testing/testing-with-rust.md +++ b/docs/book/src/testing/testing-with-rust.md @@ -203,7 +203,12 @@ async fn get_contract_instance() -> (MyContract, ContractId) { let id = Contract::load_from( "./out/debug/my-fuel-project.bin", - LoadConfiguration::default(), + LoadConfiguration::default().set_storage_configuration( + StorageConfiguration::load_from( + "./out/debug/my-fuel-project-storage_slots.json", + ) + .unwrap(), + ), ) .unwrap() .deploy(&wallet, TxPolicies::default())