]> Git Repo - VerusCoin.git/blob - src/gtest/test_keystore.cpp
Auto merge of #1326 - str4d:1185-remove-mainnet-dns-seeds, r=ebfull
[VerusCoin.git] / src / gtest / test_keystore.cpp
1 #include <gtest/gtest.h>
2
3 #include "keystore.h"
4 #include "zcash/Address.hpp"
5
6 TEST(keystore_tests, store_and_retrieve_spending_key) {
7     CBasicKeyStore keyStore;
8     libzcash::SpendingKey skOut;
9
10     std::set<libzcash::PaymentAddress> addrs;
11     keyStore.GetPaymentAddresses(addrs);
12     EXPECT_EQ(0, addrs.size());
13
14     auto sk = libzcash::SpendingKey::random();
15     auto addr = sk.address();
16
17     // Sanity-check: we can't get a key we haven't added
18     EXPECT_FALSE(keyStore.HaveSpendingKey(addr));
19     EXPECT_FALSE(keyStore.GetSpendingKey(addr, skOut));
20
21     keyStore.AddSpendingKey(sk);
22     EXPECT_TRUE(keyStore.HaveSpendingKey(addr));
23     EXPECT_TRUE(keyStore.GetSpendingKey(addr, skOut));
24     EXPECT_EQ(sk, skOut);
25
26     keyStore.GetPaymentAddresses(addrs);
27     EXPECT_EQ(1, addrs.size());
28     EXPECT_EQ(1, addrs.count(addr));
29 }
30
31 TEST(keystore_tests, store_and_retrieve_note_decryptor) {
32     CBasicKeyStore keyStore;
33     ZCNoteDecryption decOut;
34
35     auto sk = libzcash::SpendingKey::random();
36     auto addr = sk.address();
37
38     EXPECT_FALSE(keyStore.GetNoteDecryptor(addr, decOut));
39
40     keyStore.AddSpendingKey(sk);
41     EXPECT_TRUE(keyStore.GetNoteDecryptor(addr, decOut));
42     EXPECT_EQ(ZCNoteDecryption(sk.viewing_key()), decOut);
43 }
This page took 0.027201 seconds and 4 git commands to generate.