@Test public void serializeEncryptedEmpty() throws Exception { pocket.maybeInitializeAllKeys(); pocket.encrypt(crypter, aesKey); Protos.WalletPocket walletPocketProto = pocket.toProtobuf(); WalletPocketHD newPocket = new WalletPocketProtobufSerializer().readWallet(walletPocketProto, crypter); assertEquals(walletPocketProto.toString(), newPocket.toProtobuf().toString()); pocket.decrypt(aesKey); // One is encrypted, so they should not match assertNotEquals(pocket.toProtobuf().toString(), newPocket.toProtobuf().toString()); newPocket.decrypt(aesKey); assertEquals(pocket.toProtobuf().toString(), newPocket.toProtobuf().toString()); }
@Test public void serializeEncryptedNormal() throws Exception { pocket.maybeInitializeAllKeys(); pocket.encrypt(crypter, aesKey); pocket.onConnection(getBlockchainConnection(DOGE)); assertEquals(DOGE.value(11000000000l), pocket.getBalance()); assertAllKeysEncrypted(pocket); WalletPocketHD newPocket = new WalletPocketProtobufSerializer().readWallet(pocket.toProtobuf(), crypter); assertEquals(DOGE.value(11000000000l), newPocket.getBalance()); Map<TrimmedOutPoint, OutPointOutput> expectedUtxoSet = getDummyUtxoSet(); checkUnspentOutputs(expectedUtxoSet, pocket); checkUnspentOutputs(expectedUtxoSet, newPocket); assertAllKeysEncrypted(newPocket); pocket.decrypt(aesKey); newPocket.decrypt(aesKey); assertAllKeysDecrypted(pocket); assertAllKeysDecrypted(newPocket); }