Browse Source

Add test for GetNoteDecryptor()

metaverse
Jack Grigg 8 years ago
parent
commit
be86b6c332
  1. 12
      src/gtest/test_keystore.cpp
  2. 1
      src/zcash/NoteEncryption.hpp

12
src/gtest/test_keystore.cpp

@ -27,3 +27,15 @@ TEST(keystore_tests, store_and_retrieve_spending_key) {
EXPECT_EQ(1, addrs.size());
EXPECT_EQ(1, addrs.count(addr));
}
TEST(keystore_tests, store_and_retrieve_note_decryptor) {
CBasicKeyStore keyStore;
ZCNoteDecryption decOut;
auto sk = libzcash::SpendingKey::random();
auto addr = sk.address();
keyStore.AddSpendingKey(sk);
keyStore.GetNoteDecryptor(addr, decOut);
EXPECT_EQ(ZCNoteDecryption(sk.viewing_key()), decOut);
}

1
src/zcash/NoteEncryption.hpp

@ -71,6 +71,7 @@ public:
unsigned char nonce
) const;
friend inline bool operator==(const NoteDecryption& a, const NoteDecryption& b) { return a.sk_enc == b.sk_enc && a.pk_enc == b.pk_enc; }
friend inline bool operator<(const NoteDecryption& a, const NoteDecryption& b) { return a.pk_enc < b.pk_enc; }
};

Loading…
Cancel
Save