From f56d70dd171d9f375bc71183521b70a2fa684090 Mon Sep 17 00:00:00 2001 From: wiesche Date: Tue, 8 Sep 2026 11:41:09 +0200 Subject: [PATCH] test contract accounts --- controller/tests/contract_accounts.rs | 21 ++++++++++++++++++--- libwallet/src/contract/actions/README.md | 1 - 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/controller/tests/contract_accounts.rs b/controller/tests/contract_accounts.rs index 1dec6df..0010459 100644 --- a/controller/tests/contract_accounts.rs +++ b/controller/tests/contract_accounts.rs @@ -145,13 +145,28 @@ fn contract_accounts_impl(test_dir: &'static str) -> Result<(), libwallet::Error // check tx log as well let (_, txs) = api.retrieve_txs(m, true, None, None, None)?; assert_eq!(txs.len(), 0); + + // Do not fall back to another account when the active account has no funds + let progress = common::wallet_progress(api, m)?; + let err = api + .contract_new( + m, + &ContractNewArgsAPI { + setup_args: ContractSetupArgsAPI { + net_change: Some(-(reward as i64)), + selection_args: common::contract_selection_args(), + ..Default::default() + }, + ..Default::default() + }, + ) + .unwrap_err(); + assert!(matches!(err, libwallet::Error::NotEnoughFunds { .. })); + assert_eq!(common::wallet_progress(api, m)?, progress); Ok(()) }, )?; - // TODO: check what send_tx_slate_direct call does in accounts.rs test - // TODO: check that you can't call send on the default account because you have no funds - // Send a tx from wallet1::account1 -> wallet2::listener_account { wallet_inst!(wallet1, w); diff --git a/libwallet/src/contract/actions/README.md b/libwallet/src/contract/actions/README.md index b04474d..eb3c0b9 100644 --- a/libwallet/src/contract/actions/README.md +++ b/libwallet/src/contract/actions/README.md @@ -54,7 +54,6 @@ without a user confirmation step. - Infer `--receive` and `--send` from the slate state. - Revisit `remove_other_sigdata` before allowing more than two participants. - Stop relying on TxLog offsets in contract tests. - - Finish the account-switching tests in `contract_accounts.rs`. ### Side-effects