FuelLabs/fuels-rs · error · syn::Error

Only one `Wallets` command allowed

Error message

Only one `Wallets` command allowed

What it means

Compile-time validation error from setup_program_test: validate_zero_or_one_wallet_command_present found more than one Wallets(...) command. The macro allows at most one wallet-initialization command; every extra occurrence gets an error on its span and all are combined into one report.

Source

Thrown at packages/fuels-macros/src/setup_program_test/parsing/validations.rs:86

                Error::new(
                    abigen_command.span,
                    format!(
                        "Consider adding: Script(name=\"{}\", project=...)",
                        unknown_contract.value()
                    ),
                ),
            ]
        })
        .validate_no_errors()
}

pub(crate) fn validate_zero_or_one_wallet_command_present(
    commands: &[InitializeWalletCommand],
) -> Result<()> {
    if commands.len() > 1 {
        commands
            .iter()
            .map(|command| Error::new(command.span, "Only one `Wallets` command allowed"))
            .combine_errors()
            .map(Err)
            .expect("Known to have at least one error")
    } else {
        Ok(())
    }
}

fn names_of_program_bindings(
    commands: &AbigenCommand,
    program_type: ProgramType,
) -> HashSet<&LitStr> {
    commands
        .targets
        .iter()
        .filter_map(|target| (target.program_type == program_type).then_some(&target.name))
        .collect()
}

View on GitHub (pinned to d9a250a518)

Solutions

  1. Keep a single Wallets(...) command and express all wallets you need inside it (e.g. Wallets([alice, bob])).
  2. Delete the duplicated block entirely rather than commenting it out (leftover copies keep triggering the check).
  3. Recompile to confirm validation passes.

Example fix

// before
setup_program_test!(
    Wallets([alice]),
    Wallets([bob]),
)
// after
setup_program_test!(
    Wallets([alice, bob]),
)
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Two or more Wallets(..) blocks in a single setup_program_test! invocation — commonly the original block plus a pasted one when merging tests, or a duplicated block after a bad merge conflict resolution.

Common situations: Combining two tests by pasting both bodies into one invocation; incremental edits appending a Wallets block instead of editing the existing one.

Related errors


AI-assisted analysis of FuelLabs/fuels-rs@d9a250a518 (2026-08-16). Data as JSON: /api/errors/2c7d7faec2c9c53c. Report an issue: GitHub.