Quickstart sway contract test failed ---- can_get_contract_id stdout ---- thread 'can_get_contract_id' panicked at 'called `Result::unwrap()

Ii am getting this error when running the tests:

running 1 test
test can_get_contract_id ... FAILED

failures:

---- can_get_contract_id stdout ----
thread 'can_get_contract_id' panicked at 'called `Result::unwrap()` on an `Err` value: RevertTransactionError { reason: "Revert(0)", revert_id: 0, receipts: [Call { id: 0000000000000000000000000000000000000000000000000000000000000000, to: c193c4a7e19cbd4a29179f7e589d8dde6069186385ebf418f6decfd9e7107e26, amount: 0, asset_id: 0000000000000000000000000000000000000000000000000000000000000000, gas: 1000000, param1: 1480782270, param2: 1, pc: 11624, is: 11624 }, Revert { id: c193c4a7e19cbd4a29179f7e589d8dde6069186385ebf418f6decfd9e7107e26, ra: 0, pc: 12172, is: 11624 }, ScriptResult { result: Revert, gas_used: 355 }] }', tests/harness.rs:40:49
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    can_get_contract_id

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



in this link there is a discussion for the same problem, but that doesn't work for me:
https://forum.fuel.network/t/mismatched-types-storagekey-u64/2498/13


my contract:

contract;

storage{
counter: u64 = 0,
}

abi Counter {
#[storage(read, write)]
fn increment();

#[storage(read)]
fn count() -> u64;

}

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

#[storage(read, write)]
fn increment() {
    storage.counter.write(storage.counter.try_read().unwrap_or(0) + 1)
}

}


my test:

#[tokio::test]
async fn can_get_contract_id() {
let (instance, _id) = get_contract_instance().await;
// Increment the counter
instance.methods().increment().call().await.unwrap();

// Get the current value of the counter
let result = instance.methods().count().call().await.unwrap();

// Check that the current value of the counter is 1.
// Recall that the initial value of the counter was 0.
assert_eq!(result.value, 1);
// Now you have an instance of your contract you can use to test each function

}

Hi @guimroque , thanks for posting this!

It looks like you are using the latest fuelup toolchain which has some breaking changes that don’t seem to be updated in the Rust SDK quite yet. Can you try running the commands below and then using the contract code in the quickstart guide?

fuelup toolchain install beta-3
fuelup default beta-3

1 Like

Thanks,

after updating the packages and rerunning the tutorial it worked

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.