tests: compare the wallet reserve proof with the balance deterministically
What changed, and why it matters
This commit only changes a test file. It makes a wallet reserve-proof test more deterministic by waiting for pending transactions to clear and comparing the wallet balance against the proof's total minus unconfirmed spent amount. There is no change to production code, no fix for a security flaw, and no disclosed security relevance.
No security action required. This is a test-only refinement. Reviewers may optionally verify that the new assertion correctly captures the intended reserve-proof semantics, but it does not affect the library's security posture.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies TestMoneroWalletCommon.java. It adds a wait for wallet transactions to clear before generating a reserve proof, and replaces a conditional balance assertion with a direct assertion: wallet balance equals reserve proof total minus unconfirmed spent amount. The change is framed as tolerating outputs spent at an unknown height and working around unconfirmed/failed transaction behavior in monero-wallet-rpc. No library/runtime code is altered.
Changed components
src/test/java/TestMoneroWalletCommon.javaInspect captured patch +6 / −8
### src/test/java/TestMoneroWalletCommon.java
@@ -2238,20 +2238,18 @@ public void testCheckSpendProof() {
@Test
public void testGetReserveProofWallet() {
assumeTrue(TEST_NON_RELAYS);
-
+ TestUtils.WALLET_TX_TRACKER.waitForTxsToClearWallets(wallet); // proof excludes unconfirmed change and incoming funds
+
// get proof of entire wallet
String signature = wallet.getReserveProofWallet("Test message");
-
+
// check proof of entire wallet
MoneroCheckReserve check = wallet.checkReserveProof(wallet.getPrimaryAddress(), "Test message", signature);
assertTrue(check.isGood());
testCheckReserve(check);
- BigInteger balance = wallet.getBalance();
- if (!balance.equals(check.getTotalAmount())) { // TODO monero-wallet-rpc: this check fails with unconfirmed txs
- List<MoneroTxWallet> unconfirmedTxs = wallet.getTxs(new MoneroTxQuery().setInTxPool(true));
- assertTrue(unconfirmedTxs.size() > 0, "Reserve amount must equal balance unless wallet has unconfirmed txs");
- }
-
+ BigInteger reserve = check.getTotalAmount().subtract(check.getUnconfirmedSpentAmount()); // TODO monero-project: compare total directly once failed txs stop unspending confirmed inputs
+ assertEquals(wallet.getBalance(), reserve);
+
// test different wallet address
String differentAddress = TestUtils.getExternalWalletAddress();
try {Why this scored 13/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.