Skip to content

Commit

Permalink
update fuel-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Nov 13, 2023
1 parent 7fabd6d commit caec719
Show file tree
Hide file tree
Showing 46 changed files with 584 additions and 351 deletions.
193 changes: 101 additions & 92 deletions test/src/sdk-harness/Cargo.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions test/src/sdk-harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ publish = false
assert_matches = "1.5.0"

# Dependencies from the `fuel-core` repository:
fuel-core = { version = "0.20", default-features = false }
fuel-core-client = { version = "0.20", default-features = false }
fuel-core = { version = "0.20.8", default-features = false }
fuel-core-client = { version = "0.20.8", default-features = false }

# Dependencies from the `fuel-vm` repository:
fuel-vm = "0.35"

# Dependencies from the `fuels-rs` repository:
fuels = { git = "https://github.com/FuelLabs/fuels-rs.git", features = ["fuel-core-lib"] }
fuels = { git = "https://github.com/FuelLabs/fuels-rs.git", branch = "xunilrj/downgrade-sha2-version", features = [
"fuel-core-lib",
]}

hex = "0.4.3"
pretty_assertions = "1.4.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abigen!(Contract(
));

async fn get_abi_impl_methods_callable_instance() -> AbiImplMethodsCallable<WalletUnlocked> {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let id = Contract::load_from(
"test_projects/abi_impl_methods_callable/out/debug/abi_impl_methods_callable.bin",
LoadConfiguration::default(),
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async fn get_contracts() -> (
ContractId,
Wallet,
) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();

let id_1 = Contract::load_from(
"test_artifacts/auth_testing_contract/out/debug/auth_testing_contract.bin",
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/block/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abigen!(Contract(
));

async fn get_block_instance() -> (BlockTestContract<WalletUnlocked>, ContractId, Provider) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let provider = wallet.provider().unwrap();
let id = Contract::load_from(
"test_projects/block/out/debug/block.bin",
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/call_frames/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ abigen!(Contract(
));

async fn get_call_frames_instance() -> (CallFramesTestContract<WalletUnlocked>, ContractId) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let id = Contract::load_from(
"test_projects/call_frames/out/debug/call_frames.bin",
LoadConfiguration::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async fn contract_uses_default_configurables() -> Result<()> {
"test_projects/configurables_in_contract/out/debug/configurables_in_contract-abi.json"
));

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

let contract_id = Contract::load_from(
"test_projects/configurables_in_contract/out/debug/configurables_in_contract.bin",
Expand Down Expand Up @@ -51,7 +51,7 @@ async fn contract_configurables() -> Result<()> {
"test_projects/configurables_in_contract/out/debug/configurables_in_contract-abi.json"
));

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

let new_str: SizedAsciiString<4> = "FUEL".try_into()?;
let new_struct = StructWithGeneric {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async fn script_uses_default_configurables() -> Result<()> {
abi = "test_projects/configurables_in_script/out/debug/configurables_in_script-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let bin_path = "test_projects/configurables_in_script/out/debug/configurables_in_script.bin";
let instance = MyScript::new(wallet, bin_path);

Expand Down Expand Up @@ -37,7 +37,7 @@ async fn script_configurables() -> Result<()> {
abi = "test_projects/configurables_in_script/out/debug/configurables_in_script-abi.json"
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let bin_path = "test_projects/configurables_in_script/out/debug/configurables_in_script.bin";
let instance = MyScript::new(wallet, bin_path);

Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn get_contracts() -> (
TestContextCallerContract<WalletUnlocked>,
ContractId,
) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let id_1 = Contract::load_from(
"test_projects/context/out/debug/context.bin",
LoadConfiguration::default(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abigen!(Contract(

#[tokio::test]
async fn can_get_bytecode_root() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();

let (contract_instance, id) = get_test_contract_instance(wallet).await;

Expand Down
4 changes: 3 additions & 1 deletion test/src/sdk-harness/test_projects/ec_recover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ async fn setup_env() -> Result<(
coins_per_asset,
amount_per_coin,
);
let provider = setup_test_provider(coins.clone(), vec![], None, None).await;
let provider = setup_test_provider(coins.clone(), vec![], None, None)
.await
.unwrap();
wallet.set_provider(provider);

let contract_id = Contract::load_from(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ async fn ec_recover_and_match_predicate_test() -> Result<()> {
}),
None,
)
.await;
.await
.unwrap();

[&mut wallet, &mut wallet2, &mut wallet3, &mut receiver]
.iter_mut()
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/evm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abigen!(Contract(
));

async fn get_evm_test_instance() -> (EvmTestContract<WalletUnlocked>, ContractId) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let id = Contract::load_from(
"test_projects/evm/out/debug/evm.bin",
LoadConfiguration::default(),
Expand Down
4 changes: 3 additions & 1 deletion test/src/sdk-harness/test_projects/evm_ec_recover/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ async fn setup_env() -> Result<(
coins_per_asset,
amount_per_coin,
);
let provider = setup_test_provider(coins.clone(), vec![], None, None).await;
let provider = setup_test_provider(coins.clone(), vec![], None, None)
.await
.unwrap();
wallet.set_provider(provider);

let contract_id = Contract::load_from(
Expand Down
21 changes: 13 additions & 8 deletions test/src/sdk-harness/test_projects/exponentiation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abigen!(Contract(
#[tokio::test]
#[should_panic(expected = "ArithmeticOverflow")]
async fn overflowing_pow_u64_panics() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let (pow_instance, _) = get_pow_test_instance(wallet).await;
pow_instance
.methods()
Expand All @@ -24,7 +24,7 @@ async fn overflowing_pow_u64_panics() {
// TODO won't overflow until https://github.com/FuelLabs/fuel-specs/issues/90 lands
// #[should_panic(expected = "ArithmeticOverflow")]
async fn overflowing_pow_u32_panics() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let (pow_instance, _) = get_pow_test_instance(wallet).await;
pow_instance
.methods()
Expand All @@ -37,7 +37,7 @@ async fn overflowing_pow_u32_panics() {
#[tokio::test]
#[should_panic(expected = "ArithmeticOverflow")]
async fn overflowing_pow_u32_panics_max() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let (pow_instance, _) = get_pow_test_instance(wallet).await;
pow_instance
.methods()
Expand All @@ -51,7 +51,7 @@ async fn overflowing_pow_u32_panics_max() {
// TODO won't overflow until https://github.com/FuelLabs/fuel-specs/issues/90 lands
// #[should_panic(expected = "ArithmeticOverflow")]
async fn overflowing_pow_u16_panics() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let (pow_instance, _) = get_pow_test_instance(wallet).await;
pow_instance
.methods()
Expand All @@ -64,7 +64,7 @@ async fn overflowing_pow_u16_panics() {
#[tokio::test]
#[should_panic(expected = "ArithmeticOverflow")]
async fn overflowing_pow_u16_panics_max() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let (pow_instance, _) = get_pow_test_instance(wallet).await;
pow_instance
.methods()
Expand All @@ -78,15 +78,20 @@ async fn overflowing_pow_u16_panics_max() {
// TODO won't overflow until https://github.com/FuelLabs/fuel-specs/issues/90 lands
// #[should_panic(expected = "ArithmeticOverflow")]
async fn overflowing_pow_u8_panics() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let (pow_instance, _) = get_pow_test_instance(wallet).await;
pow_instance.methods().u8_overflow(10u8, 3u32).call().await.unwrap();
pow_instance
.methods()
.u8_overflow(10u8, 3u32)
.call()
.await
.unwrap();
}

#[tokio::test]
#[should_panic(expected = "ArithmeticOverflow")]
async fn overflowing_pow_u8_panics_max() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let (pow_instance, _) = get_pow_test_instance(wallet).await;
pow_instance
.methods()
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/generics_in_abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ abigen!(Contract(
));

async fn get_generics_in_abi_instance() -> (GenericsInAbiTestContract<WalletUnlocked>, ContractId) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let id = Contract::load_from(
"test_projects/generics_in_abi/out/debug/generics_in_abi.bin",
LoadConfiguration::default(),
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/hashing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn hash_struct(arr: [u8; 55], algorithm: Hash) -> [u8; 32] {
}

async fn get_hashing_instance() -> (HashingTestContract<WalletUnlocked>, ContractId) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();

let id = Contract::load_from(
"test_projects/hashing/out/debug/hashing.bin",
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/logging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async fn run_valid() -> Result<()> {
abi = "test_projects/logging/out/debug/logging-abi.json",
));

let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let bin_path = "test_projects/logging/out/debug/logging.bin";
let instance = Logging::new(wallet.clone(), bin_path);

Expand Down
3 changes: 2 additions & 1 deletion test/src/sdk-harness/test_projects/low_level_call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ async fn get_contract_instance() -> (TestContract<WalletUnlocked>, ContractId, W
None,
None,
)
.await;
.await
.unwrap();
let wallet = wallets.pop().unwrap();

let id = Contract::load_from(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ async fn get_contract_instance() -> (TestContract<WalletUnlocked>, ContractId, W
None,
None,
)
.await;
.await
.unwrap();
let wallet = wallets.pop().unwrap();

let id = Contract::load_from(
Expand Down
5 changes: 3 additions & 2 deletions test/src/sdk-harness/test_projects/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ async fn get_messages_contract_instance() -> (
Some(amount_per_coin),
);

let wallets = launch_custom_provider_and_get_wallets(config, None, None).await;

let wallets = launch_custom_provider_and_get_wallets(config, None, None)
.await
.unwrap();
let messages_contract_id = Contract::load_from(
"test_projects/messages/out/debug/messages.bin",
LoadConfiguration::default(),
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/methods/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abigen!(Contract(

#[tokio::test]
async fn run_methods_test() {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let instance = get_methods_instance(wallet).await;

let result = instance.methods().test_function().call().await.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async fn default_is_none() {
}

async fn setup() -> MyContract<WalletUnlocked> {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();

let id = Contract::load_from(
"test_projects/option_field_order/out/debug/option_field_order.bin",
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/option_in_abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ abigen!(Contract(
));

async fn get_option_in_abi_instance() -> (OptionInAbiTestContract<WalletUnlocked>, ContractId) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let id = Contract::load_from(
"test_projects/option_in_abi/out/debug/option_in_abi.bin",
LoadConfiguration::default(),
Expand Down
2 changes: 1 addition & 1 deletion test/src/sdk-harness/test_projects/parsing_logs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abigen!(Contract(
));

async fn get_parsing_logs_instance() -> (ParsingLogsTestContract<WalletUnlocked>, ContractId) {
let wallet = launch_provider_and_get_wallet().await;
let wallet = launch_provider_and_get_wallet().await.unwrap();
let id = Contract::load_from(
"test_projects/parsing_logs/out/debug/parsing_logs.bin",
LoadConfiguration::default(),
Expand Down
25 changes: 5 additions & 20 deletions test/src/sdk-harness/test_projects/predicate_data_simple/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use fuel_vm::checked_transaction::EstimatePredicates;
use fuel_vm::fuel_asm::{op, RegId};
use fuel_vm::fuel_tx;
use fuel_vm::fuel_tx::{Address, AssetId, Output};
Expand Down Expand Up @@ -30,8 +29,9 @@ async fn setup() -> (Vec<u8>, Address, WalletUnlocked, u64, AssetId) {
);

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

launch_custom_provider_and_get_wallets(WalletsConfig::default(), Some(config), None)
.await
.unwrap();
(
predicate_code,
predicate_address,
Expand Down Expand Up @@ -67,7 +67,7 @@ async fn create_predicate(

wallet.sign_transaction(&mut tx);

let mut tx = tx.build().unwrap();
let tx = tx.build().unwrap();

wallet
.provider()
Expand Down Expand Up @@ -115,9 +115,7 @@ async fn submit_to_predicate(
let output_coin = Output::coin(receiver_address, total_amount_in_predicate - 1, asset_id);
let output_change = Output::change(predicate_address, 0, asset_id);

let params = wallet.provider().unwrap().consensus_parameters();

let mut new_tx = ScriptTransactionBuilder::prepare_transfer(
let new_tx = ScriptTransactionBuilder::prepare_transfer(
inputs,
vec![output_coin, output_change],
TxParameters::default()
Expand All @@ -127,19 +125,6 @@ async fn submit_to_predicate(
)
.build()
.unwrap();
new_tx
.tx
.estimate_predicates(
&params,
&wallet
.provider()
.unwrap()
.network_info()
.await
.unwrap()
.gas_costs,
)
.unwrap();

wallet
.provider()
Expand Down
Loading

0 comments on commit caec719

Please sign in to comment.