tests: compare the wallet reserve proof with the balance deterministically
What changed, and why it matters
This is a test-only change that makes a wallet reserve proof test more deterministic. It waits for pending transactions to clear and adjusts the balance comparison to account for spent outputs. There is no change to production code or any security fix.
No security action needed. This is a test reliability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies TestMoneroWalletCommon.java. It adds a wait for wallet transactions to clear before generating a reserve proof, and replaces a conditional balance check with a deterministic comparison: wallet balance equals reserve proof total minus unconfirmed spent amount. The change is purely in test code and does not alter library behavior.
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 15/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.