Tried to use the test example mentioned here
Updated the path to load ABI as well
I did forc build
and then cargo test
here’s the sway contract -
contract;
abi TestContract {
#[storage(write)]
fn initialize_counter(value: u64) -> u64;
#[storage(read, write)]
fn increment_counter(amount: u64) -> u64;
}
storage {
counter: u64 = 0,
}
impl TestContract for Contract {
#[storage(write)]
fn initialize_counter(value: u64) -> u64 {
storage.counter.write(value);
value
}
#[storage(read, write)]
fn increment_counter(amount: u64) -> u64 {
let incremented = storage.counter.read() + amount;
storage.counter.write(incremented);
incremented
}
}
Here’s the error i am getting
chesterking@Madhurs-MacBook-Pro-2 test-one % cargo test
Compiling test-one v0.1.0 (/Users/chesterking/Desktop/FuelOps/Fuel-investigation/native-currency-transfer/test-one)
error: expected identifier
--> tests/harness.rs:4:23
|
4 | abigen!(TestContract, "out/debug/test-one-abi.json");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0412]: cannot find type `TestContract` in this scope
--> tests/harness.rs:6:38
|
6 | async fn get_contract_instance() -> (TestContract, ContractId) {
| ^^^^^^^^^^^^ help: a struct with a similar name exists: `Contract`
|
::: /Users/chesterking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fuels-programs-0.62.0/src/contract.rs:243:1
|
243 | pub struct Contract {
| ------------------- similarly named struct `Contract` defined here
error[E0433]: failed to resolve: use of undeclared type `TxParameters`
--> tests/harness.rs:29:22
|
29 | .deploy(&wallet, TxParameters::default())
| ^^^^^^^^^^^^ use of undeclared type `TxParameters`
|
help: a struct with a similar name exists
|
29 | .deploy(&wallet, CallParameters::default())
| ~~~~~~~~~~~~~~
help: consider importing this enum
|
1 + use fuels::tx::TxParameters;
|
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
--> tests/harness.rs:8:23
|
8 | let mut wallets = launch_custom_provider_and_get_wallets(
| _______________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
9 | | WalletsConfig::new(
10 | | Some(1), /* Single wallet */
11 | | Some(1), /* Single coin (UTXO) */
... |
14 | | None,
15 | | )
| |_____- an argument of type `Option<ChainConfig>` is missing
|
note: function defined here
--> /Users/chesterking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fuels-test-helpers-0.62.0/src/accounts.rs:53:14
|
53 | pub async fn launch_custom_provider_and_get_wallets(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: provide the argument
|
8 ~ let mut wallets = launch_custom_provider_and_get_wallets(WalletsConfig::new(
9 + Some(1), /* Single wallet */
10 + Some(1), /* Single coin (UTXO) */
11 + Some(1_000_000_000), /* Amount per coin */
12 + ), None, /* Option<ChainConfig> */)
|
error[E0599]: no method named `pop` found for enum `Result` in the current scope
--> tests/harness.rs:17:26
|
17 | let wallet = wallets.pop().unwrap();
| ^^^ method not found in `Result<Vec<WalletUnlocked>, Error>`
|
note: the method `pop` exists on the type `Vec<WalletUnlocked>`
--> /Users/chesterking/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/alloc/src/vec/mod.rs:2078:5
|
2078 | pub fn pop(&mut self) -> Option<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider using `Result::expect` to unwrap the `Vec<WalletUnlocked>` value, panicking if the value is a `Result::Err`
|
17 | let wallet = wallets.expect("REASON").pop().unwrap();
| +++++++++++++++++
error[E0599]: no method named `set_storage_configuration` found for struct `fuels::programs::contract::LoadConfiguration` in the current scope
--> tests/harness.rs:21:38
|
21 | LoadConfiguration::default().set_storage_configuration(
| -----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: there is a method `with_storage_configuration` with a similar name
|
21 | LoadConfiguration::default().with_storage_configuration(
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
error[E0599]: no function or associated item named `load_from` found for struct `fuels::programs::contract::StorageConfiguration` in the current scope
--> tests/harness.rs:22:35
|
22 | StorageConfiguration::load_from(
| ^^^^^^^^^ function or associated item not found in `StorageConfiguration`
|
note: if you're trying to build a new `fuels::programs::contract::StorageConfiguration`, consider using `fuels::programs::contract::StorageConfiguration::new` which returns `fuels::programs::contract::StorageConfiguration`
--> /Users/chesterking/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fuels-programs-0.62.0/src/contract.rs:118:5
|
118 | pub fn new(autoload_enabled: bool, slots: impl IntoIterator<Item = StorageSlot>) -> Self {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: there is a method `clone_from` with a similar name
|
22 | StorageConfiguration::clone_from(
| ~~~~~~~~~~
error[E0433]: failed to resolve: use of undeclared type `TestContract`
--> tests/harness.rs:33:20
|
33 | let instance = TestContract::new(id.to_string(), wallet);
| ^^^^^^^^^^^^
| |
| use of undeclared type `TestContract`
| help: a struct with a similar name exists: `Contract`
Some errors have detailed explanations: E0061, E0412, E0433, E0599.
For more information about an error, try `rustc --explain E0061`.
error: could not compile `test-one` (test "integration_tests") due to 8 previous errors