Dev-dependency "Fuels" (version= "0.62.0") interferes while running an integration test using rust

I was carrying out an integration test for the conter contract I wrote and I realized it kept failing and this was due to the fuels dev-dependency version in my cargo.toml file that the fuel’s documentation advised I use. I was using
[dev-dependencies]
fuels = { version = “0.62.0”, features = [“fuel-core-lib”] }
tokio = { version = “1.12”, features = [“rt”, “macros”] }

and it kept giving me errors like below
---- test_increment stdout ----
thread ‘test_increment’ panicked at tests/harness.rs:50:49: …

However, when I switched it to an older version such as below it worked fine.
[dev-dependencies]
fuels = { version = “0.54.0”, features = [“fuel-core-lib”] }
tokio = { version = “1.12”, features = [“rt”, “macros”] }

I don’t know if anyone has experienced anything similar to what I faced ?

1 Like

Can you share the output for the fuelup show from your terminal?

Can you please provide a repo with the sway contract and the rust files needed to reproduce the issue you’re having.

Also please provide the full output of cargo, and fuelup show as @Nazeeh21 said.

1 Like

Default host: aarch64-apple-darwin
fuelup home: /Users/tophar/.fuelup

Installed toolchains

beta-4-aarch64-apple-darwin
latest-aarch64-apple-darwin (default)

active toolchain

latest-aarch64-apple-darwin (default)
forc : 0.61.2
- forc-client
- forc-deploy : 0.61.2
- forc-run : 0.61.2
- forc-crypto : 0.61.2
- forc-debug : 0.61.2
- forc-doc : 0.61.2
- forc-fmt : 0.61.2
- forc-lsp : 0.61.2
- forc-tx : 0.61.2
- forc-wallet : 0.8.1
fuel-core : 0.31.0
fuel-core-keygen : 0.31.0

fuels versions

forc : 0.64.0
forc-wallet : 0.64.0

Here is the full uput of my cargo test below
Finished test profile [unoptimized + debuginfo] target(s) in 0.89s
Running tests/harness.rs (target/debug/deps/integration_tests-fdef73c8bcc3b76c)

running 2 tests
[00:00:00] ████████████████████ 1/1 Coins → Coins 0s
[00:00:00] ████████████████████ 1/1 Coins → OwnedCoins 0s
test can_get_contract_id … ok
test test_increment … FAILED

failures:

---- test_increment stdout ----
thread ‘test_increment’ panicked at tests/harness.rs:50:49:
called Result::unwrap() on an Err value: Transaction(Reverted { reason: “Revert(123)”, revert_id: 123, receipts: [Call { id: 0000000000000000000000000000000000000000000000000000000000000000, to: e42f9a7ea17132e6eac77e7c50328e4856a1662149046667bfacd74f19f16711, amount: 0, asset_id: 0000000000000000000000000000000000000000000000000000000000000000, gas: 24, param1: 10480, param2: 10497, pc: 11680, is: 11680 }, Revert { id: e42f9a7ea17132e6eac77e7c50328e4856a1662149046667bfacd74f19f16711, ra: 123, pc: 11736, is: 11680 }, ScriptResult { result: Revert, gas_used: 219 }] })
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

failures:
test_increment

test result: FAILED. 1 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.25s

error: test failed, to rerun pass --test integration_tests

contract;
mod interface;
use interface::Counter;

storage {
counter: u64 = 0,
}

impl Counter for Contract {
#[storage(read)]
fn count() → u64 {
storage.counter.read()
}

#[storage(read, write)]
fn increment() {
   let incremented = storage.counter.read() + 1;
    storage.counter.write(incremented);
}

}

This my sway contract above.

This is my harness.rs below
use fuels::{prelude::*, types::ContractId};

// Load abi from json
abigen!(Contract(
name = “MyContract”,
abi = “out/debug/count-contract-abi.json”
));

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(
Some(1), /* Single wallet /
Some(1), /
Single coin (UTXO) /
Some(1_000_000_000), /
Amount per coin */
),
None,
None,
)
.await
.unwrap();
let wallet = wallets.pop().unwrap();

let id = Contract::load_from(
    "./out/debug/count-contract.bin",
    LoadConfiguration::default(),
)
.unwrap()
.deploy(&wallet, TxPolicies::default())
.await
.unwrap();

let instance = MyContract::new(id.clone(), wallet);

(instance, id.into())

}

#[tokio::test]
async fn can_get_contract_id() {
let (_instance, _id) = get_contract_instance().await;
}

#[tokio::test]
async fn test_increment() {
let (instance, _id) = get_contract_instance().await;

instance.methods().increment().call().await.unwrap();

let result = instance.methods().count().call().await.unwrap();

assert_eq!(result.value, 1);

}

Hi!
I built the test from the data you provided and tested it against the latest release of fuels, and it works perfectly. I recommend switching to the latest release if possible to resolve the issue. If you encounter any further problems, please provide a GitHub repository with an example. This will help us diagnose and address any remaining issues more effectively.