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

feat!: make functions return Result and implement Node Killer #1067

Merged
merged 94 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
2d2c9ec
refactor: make functions return Result
Salka1988 Jul 28, 2023
0ec0e06
fix
Salka1988 Jul 28, 2023
1cb599e
fix
Salka1988 Jul 28, 2023
91823c3
fix
Salka1988 Aug 2, 2023
df15979
fix
Salka1988 Aug 2, 2023
fce368a
Merge branch 'master' into Salka1988/return_result
Salka1988 Aug 2, 2023
b4c68a2
Merge branch 'master' into Salka1988/return_result
segfault-magnet Aug 2, 2023
7bda628
refactor
Salka1988 Aug 2, 2023
72bdfab
Merge branch 'Salka1988/return_result' of github.com:FuelLabs/fuels-r…
Salka1988 Aug 2, 2023
b6458ed
Merge branch 'master' into Salka1988/return_result
segfault-magnet Aug 3, 2023
a919195
put error! under flag
Salka1988 Aug 4, 2023
156e0e7
Merge branch 'Salka1988/return_result' of github.com:FuelLabs/fuels-r…
Salka1988 Aug 4, 2023
1f5e93c
fix test
Salka1988 Aug 4, 2023
5498930
Merge branch 'master' into Salka1988/return_result
Salka1988 Aug 7, 2023
8afa546
add Service trait
Salka1988 Aug 7, 2023
e13b115
Merge branch 'master' into Salka1988/return_result
Salka1988 Aug 8, 2023
214eebb
Merge branch 'master' into Salka1988/return_result
Salka1988 Aug 14, 2023
d53361c
return join handler
Salka1988 Aug 16, 2023
599075d
Merge branch 'master' into Salka1988/return_result
Salka1988 Sep 1, 2023
5f8d1cd
Merge branch 'master' into Salka1988/return_result
Salka1988 Sep 4, 2023
e252cd7
fix
Salka1988 Sep 4, 2023
89d5456
add Task
Salka1988 Sep 4, 2023
76b5549
test
Salka1988 Sep 5, 2023
5100e98
Merge branch 'master' into Salka1988/return_result
Salka1988 Sep 12, 2023
3e813e3
testing
Salka1988 Sep 12, 2023
0730f15
something
Salka1988 Sep 22, 2023
ad84106
add traits
Salka1988 Sep 23, 2023
de3feb1
add new_node
Salka1988 Sep 24, 2023
e4b8f43
reverte
Salka1988 Sep 24, 2023
226274e
add Task
Salka1988 Sep 25, 2023
d8901cf
handle JoinHandler
Salka1988 Sep 25, 2023
a844b97
implement FuelService::new
Salka1988 Sep 25, 2023
788a4f3
implement stop:and_awaitw
Salka1988 Sep 25, 2023
643da1d
clean
Salka1988 Sep 25, 2023
f11f035
clean up
Salka1988 Sep 26, 2023
42bc05b
clean up
Salka1988 Sep 26, 2023
8a7770c
clean up
Salka1988 Sep 26, 2023
375a595
Merge branch 'master' into Salka1988/return_result
Salka1988 Sep 26, 2023
171dd6f
merge master
Salka1988 Sep 26, 2023
75a55e4
Merge branch 'Salka1988/return_result' of github.com:FuelLabs/fuels-r…
Salka1988 Sep 26, 2023
135f658
fmt
Salka1988 Sep 26, 2023
908c23a
clippy
Salka1988 Sep 26, 2023
32b94c8
fix
Salka1988 Sep 26, 2023
a374f4f
delete test
Salka1988 Sep 26, 2023
e63499c
Merge branch 'master' into Salka1988/return_result
Salka1988 Sep 27, 2023
c6e52f8
fix
Salka1988 Sep 27, 2023
5f552e5
fix
Salka1988 Sep 27, 2023
136e947
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 4, 2023
41c6a9b
fix
Salka1988 Oct 4, 2023
f5d7e3e
Merge branch 'Salka1988/return_result' of github.com:FuelLabs/fuels-r…
Salka1988 Oct 4, 2023
fa06ff2
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 4, 2023
847fd0d
refactoring
Salka1988 Oct 7, 2023
dab55f3
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 7, 2023
d7fd598
Merge branch 'Salka1988/return_result' of github.com:FuelLabs/fuels-r…
Salka1988 Oct 7, 2023
5ab803e
refactoring
Salka1988 Oct 8, 2023
d7b21ab
refactoring
Salka1988 Oct 8, 2023
cafd3dc
refactoring
Salka1988 Oct 8, 2023
4e409c5
fix
Salka1988 Oct 9, 2023
f98e293
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 9, 2023
6efb18f
fix
Salka1988 Oct 9, 2023
bb0727d
fmt
Salka1988 Oct 9, 2023
94fcc0c
refactoring
Salka1988 Oct 10, 2023
e1e548e
refactoring
Salka1988 Oct 10, 2023
e8a28db
refactoring
Salka1988 Oct 10, 2023
849796b
refactoring
Salka1988 Oct 10, 2023
42fbffa
remove traits
Salka1988 Oct 10, 2023
3092028
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 10, 2023
fbc656b
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 10, 2023
0e21a68
fix
Salka1988 Oct 10, 2023
60d4e57
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 11, 2023
8aa3d55
refactoring
Salka1988 Oct 12, 2023
206a01e
Merge branch 'Salka1988/return_result' of github.com:FuelLabs/fuels-r…
Salka1988 Oct 12, 2023
f80d42e
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 12, 2023
a0a9e38
remove Service trait
Salka1988 Oct 12, 2023
8867376
Merge branch 'master' into Salka1988/return_result
Salka1988 Oct 12, 2023
83e2dc8
remove bla_bla test
Salka1988 Oct 12, 2023
08ac778
Merge branch 'Salka1988/return_result' of github.com:FuelLabs/fuels-r…
Salka1988 Oct 12, 2023
68e9338
machete
Salka1988 Oct 12, 2023
b3b95f8
remove enums
Salka1988 Oct 12, 2023
b912fd4
Update packages/fuels-test-helpers/src/lib.rs
Salka1988 Oct 13, 2023
5ba2e1f
Update packages/fuels-test-helpers/src/fuel_bin_service.rs
Salka1988 Oct 13, 2023
7d15496
Update packages/fuels-test-helpers/src/fuel_bin_service.rs
Salka1988 Oct 13, 2023
ccf9e76
Update packages/fuels-test-helpers/src/lib.rs
Salka1988 Oct 13, 2023
6f3f447
Update packages/fuels-test-helpers/src/fuel_bin_service.rs
Salka1988 Oct 13, 2023
940f9a7
Update packages/fuels-test-helpers/src/service.rs
Salka1988 Oct 13, 2023
c6f4a27
Update packages/fuels-test-helpers/src/fuel_bin_service.rs
Salka1988 Oct 13, 2023
9d86449
Update packages/fuels-test-helpers/src/fuel_bin_service.rs
Salka1988 Oct 13, 2023
f27c865
Update packages/fuels-test-helpers/src/fuel_bin_service.rs
Salka1988 Oct 13, 2023
c39efef
Update packages/fuels-test-helpers/src/fuel_bin_service.rs
Salka1988 Oct 13, 2023
7cd8a8f
Update packages/fuels-test-helpers/src/lib.rs
Salka1988 Oct 13, 2023
37d2a2e
Update packages/fuels-test-helpers/src/fuel_bin_service.rs
Salka1988 Oct 13, 2023
d97953f
Update packages/fuels-test-helpers/src/lib.rs
Salka1988 Oct 13, 2023
12f71af
add suggestions
Salka1988 Oct 13, 2023
4c625ce
clippy
Salka1988 Oct 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 18 additions & 26 deletions examples/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,20 @@
mod tests {
use fuels::{
core::codec::DecoderConfig,
prelude::{LoadConfiguration, StorageConfiguration},
types::{
errors::{error, Error, Result},
Bits256,
},
prelude::{Config, LoadConfiguration, StorageConfiguration},
types::{errors::Result, Bits256},
};

#[tokio::test]
async fn instantiate_client() -> Result<()> {
// ANCHOR: instantiate_client
use fuels::{
fuel_node::{Config, FuelService},
prelude::Provider,
};
use fuels::prelude::{FuelService, Provider};

// Run the fuel node.
let server = FuelService::new_node(Config::local_node())
.await
.map_err(|err| error!(InfrastructureError, "{err}"))?;
let server = FuelService::start(Config::local_node()).await?;

// Create a client that will talk to the node created above.
let client = Provider::from(server.bound_address).await?;
let client = Provider::from(server.bound_address()).await?;
assert!(client.healthy().await?);
// ANCHOR_END: instantiate_client
Ok(())
Expand All @@ -35,7 +27,7 @@ mod tests {

// ANCHOR: deploy_contract
// This helper will launch a local node and provide a test wallet linked to it
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

// This will load and deploy your contract binary to the chain so that its ID can
// be used to initialize the instance
Expand Down Expand Up @@ -91,7 +83,7 @@ mod tests {
abi = "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let contract_id = Contract::load_from(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
Expand Down Expand Up @@ -124,7 +116,7 @@ mod tests {
};
use rand::prelude::{Rng, SeedableRng, StdRng};

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let contract_id_1 = Contract::load_from(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
Expand Down Expand Up @@ -224,7 +216,7 @@ mod tests {
));

let wallets =
launch_custom_provider_and_get_wallets(WalletsConfig::default(), None, None).await;
launch_custom_provider_and_get_wallets(WalletsConfig::default(), None, None).await?;

let contract_id_1 = Contract::load_from(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
Expand Down Expand Up @@ -275,7 +267,7 @@ mod tests {
abi = "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let contract_id = Contract::load_from(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
Expand Down Expand Up @@ -345,7 +337,7 @@ mod tests {
abi = "packages/fuels/tests/contracts/token_ops/out/debug/token_ops-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let contract_id = Contract::load_from(
"../../packages/fuels/tests/contracts/token_ops/out/debug/token_ops\
Expand Down Expand Up @@ -385,7 +377,7 @@ mod tests {
abi="packages/fuels/tests/contracts/lib_contract_caller/out/debug/lib_contract_caller-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let called_contract_id: ContractId = Contract::load_from(
"../../packages/fuels/tests/contracts/lib_contract/out/debug/lib_contract.bin",
Expand Down Expand Up @@ -456,7 +448,7 @@ mod tests {
abi =
"packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json"
));
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let contract_id = Contract::load_from(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
Expand Down Expand Up @@ -501,7 +493,7 @@ mod tests {
abi =
"packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json"
));
let wallet_original = launch_provider_and_get_wallet().await;
let wallet_original = launch_provider_and_get_wallet().await?;

let wallet = wallet_original.clone();
// Your bech32m encoded contract ID.
Expand Down Expand Up @@ -536,7 +528,7 @@ mod tests {
abi = "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let contract_id = Contract::load_from(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
Expand Down Expand Up @@ -574,7 +566,7 @@ mod tests {
abi = "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let contract_id = Contract::load_from(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
Expand Down Expand Up @@ -630,7 +622,7 @@ mod tests {
abi = "packages/fuels/tests/contracts/contract_test/out/debug/contract_test-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;

let contract_id = Contract::load_from(
"../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
Expand Down Expand Up @@ -672,7 +664,7 @@ mod tests {
));

let config = WalletsConfig::new(Some(2), Some(1), Some(DEFAULT_COIN_AMOUNT));
let mut wallets = launch_custom_provider_and_get_wallets(config, None, None).await;
let mut wallets = launch_custom_provider_and_get_wallets(config, None, None).await?;
let wallet_1 = wallets.pop().unwrap();
let wallet_2 = wallets.pop().unwrap();

Expand Down
14 changes: 6 additions & 8 deletions examples/cookbook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mod tests {
.into();

let wallet_config = WalletsConfig::new_multiple_assets(1, asset_configs);
let wallets = launch_custom_provider_and_get_wallets(wallet_config, None, None).await;
let wallets = launch_custom_provider_and_get_wallets(wallet_config, None, None).await?;
let wallet = &wallets[0];
// ANCHOR_END: liquidity_wallet

Expand Down Expand Up @@ -91,7 +91,7 @@ mod tests {
#[tokio::test]
async fn custom_chain() -> Result<()> {
// ANCHOR: custom_chain_import
use fuels::{fuel_node::ChainConfig, prelude::*, tx::ConsensusParameters};
use fuels::{prelude::node_types::ChainConfig, prelude::*, tx::ConsensusParameters};
// ANCHOR_END: custom_chain_import

// ANCHOR: custom_chain_consensus
Expand All @@ -118,7 +118,7 @@ mod tests {
// ANCHOR: custom_chain_provider
let node_config = Config::local_node();
let _provider =
setup_test_provider(coins, vec![], Some(node_config), Some(chain_config)).await;
setup_test_provider(coins, vec![], Some(node_config), Some(chain_config)).await?;
// ANCHOR_END: custom_chain_provider
Ok(())
}
Expand All @@ -138,7 +138,7 @@ mod tests {
let (coins, _) =
setup_multiple_assets_coins(wallet_1.address(), NUM_ASSETS, NUM_COINS, AMOUNT);

let provider = setup_test_provider(coins, vec![], None, None).await;
let provider = setup_test_provider(coins, vec![], None, None).await?;

wallet_1.set_provider(provider.clone());
wallet_2.set_provider(provider.clone());
Expand Down Expand Up @@ -195,17 +195,15 @@ mod tests {
use std::path::PathBuf;

use fuels::prelude::*;

// ANCHOR: create_or_use_rocksdb
let provider_config = Config {
database_path: PathBuf::from("/tmp/.spider/db"),
database_type: DbType::RocksDb,
database_type: DbType::RocksDb(Some(PathBuf::from("/tmp/.spider/db"))),
..Config::local_node()
};
// ANCHOR_END: create_or_use_rocksdb

launch_custom_provider_and_get_wallets(Default::default(), Some(provider_config), None)
.await;
.await?;

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions examples/predicates/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ mod tests {
})
.collect::<Vec<_>>();

let provider = setup_test_provider(all_coins, vec![], None, None).await;
let provider = setup_test_provider(all_coins, vec![], None, None).await?;

[&mut wallet, &mut wallet2, &mut wallet3, &mut receiver]
.iter_mut()
Expand Down Expand Up @@ -138,7 +138,7 @@ mod tests {
}],
);

let wallets = &launch_custom_provider_and_get_wallets(wallets_config, None, None).await;
let wallets = &launch_custom_provider_and_get_wallets(wallets_config, None, None).await?;

let first_wallet = &wallets[0];
let second_wallet = &wallets[1];
Expand Down
7 changes: 4 additions & 3 deletions examples/providers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod tests {
use fuels::prelude::Result;

#[tokio::test]
async fn connect_to_fuel_node() {
async fn connect_to_fuel_node() -> Result<()> {
// ANCHOR: connect_to_testnet
use std::str::FromStr;

Expand All @@ -28,14 +28,15 @@ mod tests {
dbg!(wallet.address().to_string());
// ANCHOR_END: connect_to_testnet

let provider = setup_test_provider(vec![], vec![], None, None).await;
let provider = setup_test_provider(vec![], vec![], None, None).await?;
let port = provider.url().split(':').last().unwrap();

// ANCHOR: local_node_address
let _provider = Provider::connect(format!("127.0.0.1:{port}"))
.await
.unwrap();
// ANCHOR_END: local_node_address
Ok(())
}

#[tokio::test]
Expand Down Expand Up @@ -66,7 +67,7 @@ mod tests {
// ANCHOR: configure_retry
let retry_config = RetryConfig::new(3, Backoff::Fixed(Duration::from_secs(2)))?;
let provider = setup_test_provider(coins.clone(), vec![], None, None)
.await
.await?
.with_retry_config(retry_config);
// ANCHOR_END: configure_retry
// ANCHOR_END: setup_test_blockchain
Expand Down
2 changes: 1 addition & 1 deletion examples/rust_bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod tests {
#[allow(unused_variables)]
async fn transform_json_to_bindings() -> Result<()> {
use fuels::test_helpers::launch_provider_and_get_wallet;
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await?;
{
// ANCHOR: use_abigen
use fuels::prelude::*;
Expand Down
Loading
Loading