Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Testing with Rust / Writing Tests" example #5539

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions docs/book/src/testing/testing-with-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<WalletUnlocked>, ContractId) {
// Launch a local network and deploy the contract
let mut wallets = launch_custom_provider_and_get_wallets(
WalletsConfig::new(
Expand All @@ -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(),
Copy link
Contributor

@IGI-111 IGI-111 Feb 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be missing an equivalent with_storage_configuration call.
Without that it won't have the same behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without that it won't have the same behavior.

The code currently in the book doesn't compile. So I'm not quite sure what you mean.

Could I impose on you to push to my branch?

)
.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())
}
Expand Down