fix(#79): compare wallet key and full transaction content - #134
Conversation
equalWallets in Copies only checked id and ledger size, treating distinct wallets as identical whenever those two numbers agreed. It now also compares the RSA key and every transaction field-by-field across id, time, amount, prefix, beneficiary, details, and signature.
edmoffo
left a comment
There was a problem hiding this comment.
Implementation covers the puzzle: id, key, ledger size, then per-transaction comparison across the seven Transaction fields, split into helpers to stay inside Qulice's complexity bound. Two concerns worth raising. The key() call introduces a hard dependency on Wallet.File.key(), which still throws UnsupportedOperationException per @todo #54 in Wallet.java near line 280 (see inline comment). Separately, the new equality fan-out (id mismatch, key mismatch, ledger-size mismatch, per-field transaction mismatch) is not exercised by CopiesTest, and the existing @todo #56:30min at CopiesTest.java:17 for the missing scenarios is untouched. CI is green.
| final List<Transaction> head = new ListOf<>(first.ledger()); | ||
| final List<Transaction> tail = new ListOf<>(second.ledger()); | ||
| boolean equal = first.id() == second.id() | ||
| && first.key().equals(second.key()) |
There was a problem hiding this comment.
first.key().equals(second.key()) reaches Wallet.File.key(), which still throws UnsupportedOperationException (Wallet.java near line 280, @todo #54). Once two File wallets land here with the same id the short-circuit lets execution reach this expression and it throws instead of letting equalWallets return cleanly. Either gate this branch behind Wallet.File.key actually being implemented (#54 lands first), or have equalWallets treat an unsupported key() as equal-when-ids-match so the comparison degrades gracefully until #54.
The puzzle in
Copies.javaasked theequalWalletshelper to compare wallets by more than just id and ledger size; the RSA key and every transaction field were supposed to participate. Until now any two wallets sharing only id and transaction count were collapsed into a singleCopies.Copy, hiding genuinely divergent ledgers.equalWalletsnow checks id, key, and ledger size up front, then walks both ledgers in parallel and compares each transaction across id, time, amount, prefix, beneficiary, details, and signature. The field comparison is split betweenequalNumbersandequalTextso no single boolean expression breaches the Qulice complexity limit. The puzzle marker is removed from the source.Local checks:
mvn -B test(68 tests, 0 failures) andmvn -B -Pqulice -DskipTests verifyboth pass.Closes #79