test: fix flaky reserve proof over-request (#6595)
What changed, and why it matters
This commit only changes a test file to fix a flaky test. The test was requesting a reserve proof for an amount slightly above a single account's balance, but the underlying Monero wallet validates against a stricter 'whole-wallet' balance that includes pending-spent outputs. Because unconfirmed transactions can make the strict balance higher than the reported account balance, the old test sometimes failed to trigger the expected error. The fix requests an amount above the whole-wallet balance instead. There is no change to production code, no security vulnerability, and no user-facing behavior change.
No security action required. This is a test-only reliability fix. Reviewers may optionally verify that the new test assertion still exercises the intended error path for reserve proof over-requests.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies src/test/java/TestMoneroWalletCommon.java. It removes a convoluted block that sometimes printed debug info and re-requested a reserve proof, and replaces it with a single call to wallet.getReserveProofAccount(0, wallet.getBalance().add(TestUtils.MAX_FEE), ‘Test message’). The comment explains that get_reserve_proof validates against the account’s strict balance, which counts pending-spent outputs and can exceed a single account’s reported balance when unconfirmed transactions exist. The test now reliably expects a MoneroError with code -1. No library/runtime code is changed.
Changed components
src/test/java/TestMoneroWalletCommon.javaInspect captured patch +3 / −11
diff --git a/src/test/java/TestMoneroWalletCommon.java b/src/test/java/TestMoneroWalletCommon.java
index b55421f..78fd1dd 100644
--- a/src/test/java/TestMoneroWalletCommon.java
+++ b/src/test/java/TestMoneroWalletCommon.java
@@ -2319,18 +2319,10 @@ public abstract class TestMoneroWalletCommon {
assertTrue(numNonZeroTests > 1, "Must have more than one account with non-zero balance; run send-to-multiple tests");
// test error when not enough balance for requested minimum reserve amount
+ // use the whole-wallet balance: get_reserve_proof validates against the account's strict balance, which counts
+ // pending-spent outputs and can exceed a single account's reported balance when unconfirmed txs exist (see #6595)
try {
- String proof = wallet.getReserveProofAccount(0, accounts.get(0).getBalance().add(TestUtils.MAX_FEE), "Test message");
- System.out.println("Account balance: " + wallet.getBalance(0));
- System.out.println("accounts.get(0) balance: " + accounts.get(0).getBalance());
- MoneroCheckReserve reserve = wallet.checkReserveProof(wallet.getPrimaryAddress(), "Test message", proof);
- try {
- wallet.getReserveProofAccount(0, accounts.get(0).getBalance().add(TestUtils.MAX_FEE), "Test message");
- throw new RuntimeException("expecting this to succeed");
- } catch (Exception e) {
- assertEquals("expecting this to succeed", e.getMessage());
- }
- System.out.println("Check reserve proof: " + JsonUtils.serialize(reserve));
+ wallet.getReserveProofAccount(0, wallet.getBalance().add(TestUtils.MAX_FEE), "Test message");
fail("Should have thrown exception but got reserve proof: https://github.com/monero-project/monero/issues/6595");
} catch (MoneroError e) {
assertEquals(-1, (int) e.getCode());
Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.