Skip to content

Commit

Permalink
WalletTest: Clean up some assert messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Jan 1, 2016
1 parent 720f7d2 commit 73467ea
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions core/src/test/java/org/bitcoinj/core/WalletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ private Transaction cleanupCommon(Address destination) throws Exception {
Transaction t = sendMoneyToWallet(wallet, v1, myAddress, null);
Threading.waitForUserCode();
sendMoneyToWallet(wallet, t, null);
assertEquals("Wrong number of PENDING.4", 2, wallet.getPoolSize(Pool.PENDING));
assertEquals("Wrong number of UNSPENT.4", 0, wallet.getPoolSize(Pool.UNSPENT));
assertEquals("Wrong number of ALL.4", 3, wallet.getTransactions(true).size());
assertEquals("Wrong number of PENDING", 2, wallet.getPoolSize(Pool.PENDING));
assertEquals("Wrong number of UNSPENT", 0, wallet.getPoolSize(Pool.UNSPENT));
assertEquals("Wrong number of ALL", 3, wallet.getTransactions(true).size());
assertEquals(valueOf(0, 59), wallet.getBalance(Wallet.BalanceType.ESTIMATED));

// Now we have another incoming pending
Expand All @@ -241,9 +241,9 @@ public void cleanup() throws Exception {

wallet.cleanup();
assertTrue(wallet.isConsistent());
assertEquals("Wrong number of PENDING.5", 1, wallet.getPoolSize(WalletTransaction.Pool.PENDING));
assertEquals("Wrong number of UNSPENT.5", 0, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL.5", 2, wallet.getTransactions(true).size());
assertEquals("Wrong number of PENDING", 1, wallet.getPoolSize(WalletTransaction.Pool.PENDING));
assertEquals("Wrong number of UNSPENT", 0, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL", 2, wallet.getTransactions(true).size());
assertEquals(valueOf(0, 49), wallet.getBalance(Wallet.BalanceType.ESTIMATED));
}

Expand All @@ -263,9 +263,9 @@ public void cleanupFailsDueToSpend() throws Exception {
wallet.completeTx(req);
wallet.commitTx(req.tx);

assertEquals("Wrong number of PENDING.5", 3, wallet.getPoolSize(WalletTransaction.Pool.PENDING));
assertEquals("Wrong number of UNSPENT.5", 0, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL.5", 4, wallet.getTransactions(true).size());
assertEquals("Wrong number of PENDING", 3, wallet.getPoolSize(WalletTransaction.Pool.PENDING));
assertEquals("Wrong number of UNSPENT", 0, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL", 4, wallet.getTransactions(true).size());

// Consider the new pending as risky and try to remove it from the wallet
wallet.setRiskAnalyzer(new TestRiskAnalysis.Analyzer(t));
Expand All @@ -274,9 +274,9 @@ public void cleanupFailsDueToSpend() throws Exception {
assertTrue(wallet.isConsistent());

// The removal should have failed
assertEquals("Wrong number of PENDING.5", 3, wallet.getPoolSize(WalletTransaction.Pool.PENDING));
assertEquals("Wrong number of UNSPENT.5", 0, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL.5", 4, wallet.getTransactions(true).size());
assertEquals("Wrong number of PENDING", 3, wallet.getPoolSize(WalletTransaction.Pool.PENDING));
assertEquals("Wrong number of UNSPENT", 0, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL", 4, wallet.getTransactions(true).size());
assertEquals(ZERO, wallet.getBalance(Wallet.BalanceType.ESTIMATED));
}

Expand Down Expand Up @@ -315,8 +315,8 @@ private void basicSpendingCommon(Wallet wallet, Address toAddress, Address desti
fail();
} catch (ECKey.MissingPrivateKeyException kce) {
}
assertEquals("Wrong number of UNSPENT.1", 1, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL.1", 1, wallet.getTransactions(true).size());
assertEquals("Wrong number of UNSPENT", 1, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL", 1, wallet.getTransactions(true).size());

// Try to create a send with a fee but the wrong password (this should fail).
req = Wallet.SendRequest.to(destination, v2);
Expand All @@ -331,8 +331,8 @@ private void basicSpendingCommon(Wallet wallet, Address toAddress, Address desti
assertEquals("Could not decrypt bytes", kce.getMessage());
}

assertEquals("Wrong number of UNSPENT.2", 1, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL.2", 1, wallet.getTransactions(true).size());
assertEquals("Wrong number of UNSPENT", 1, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL", 1, wallet.getTransactions(true).size());

// Create a send with a fee with the correct password (this should succeed).
req = Wallet.SendRequest.to(destination, v2);
Expand All @@ -346,8 +346,8 @@ private void basicSpendingCommon(Wallet wallet, Address toAddress, Address desti
wallet.completeTx(req);

Transaction t2 = req.tx;
assertEquals("Wrong number of UNSPENT.3", 1, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL.3", 1, wallet.getTransactions(true).size());
assertEquals("Wrong number of UNSPENT", 1, wallet.getPoolSize(WalletTransaction.Pool.UNSPENT));
assertEquals("Wrong number of ALL", 1, wallet.getTransactions(true).size());
assertEquals(TransactionConfidence.Source.SELF, t2.getConfidence().getSource());
assertEquals(Transaction.Purpose.USER_PAYMENT, t2.getPurpose());

Expand Down Expand Up @@ -2043,23 +2043,23 @@ public void encryptionDecryptionCheckExceptions() throws Exception {
assertTrue("Wallet is not an encrypted wallet", encryptedWallet.getEncryptionType() == EncryptionType.ENCRYPTED_SCRYPT_AES);

// Decrypt wallet.
assertTrue("The keyCrypter is missing but should not be.1", keyCrypter != null);
assertTrue("The keyCrypter is missing but should not be", keyCrypter != null);
encryptedWallet.decrypt(aesKey);

// Try decrypting it again
try {
assertTrue("The keyCrypter is missing but should not be.2", keyCrypter != null);
assertTrue("The keyCrypter is missing but should not be", keyCrypter != null);
encryptedWallet.decrypt(aesKey);
fail("Should not be able to decrypt a decrypted wallet");
} catch (IllegalStateException e) {
assertTrue("Expected behaviour", true);
}
assertTrue("Wallet is not an unencrypted wallet.2", encryptedWallet.getKeyCrypter() == null);
assertTrue("Wallet is not an unencrypted wallet", encryptedWallet.getKeyCrypter() == null);

// Encrypt wallet.
encryptedWallet.encrypt(keyCrypter, aesKey);

assertTrue("Wallet is not an encrypted wallet.2", encryptedWallet.getEncryptionType() == EncryptionType.ENCRYPTED_SCRYPT_AES);
assertTrue("Wallet is not an encrypted wallet", encryptedWallet.getEncryptionType() == EncryptionType.ENCRYPTED_SCRYPT_AES);

// Try encrypting it again
try {
Expand All @@ -2068,7 +2068,7 @@ public void encryptionDecryptionCheckExceptions() throws Exception {
} catch (IllegalStateException e) {
assertTrue("Expected behaviour", true);
}
assertTrue("Wallet is not an encrypted wallet.3", encryptedWallet.getEncryptionType() == EncryptionType.ENCRYPTED_SCRYPT_AES);
assertTrue("Wallet is not an encrypted wallet", encryptedWallet.getEncryptionType() == EncryptionType.ENCRYPTED_SCRYPT_AES);
}

@Test(expected = KeyCrypterException.class)
Expand Down

0 comments on commit 73467ea

Please sign in to comment.