Add support for spending keys to the basic key store

This commit is contained in:
Jack Grigg
2016-08-09 13:34:58 +12:00
parent a8270035c0
commit 7c929cf5bc
7 changed files with 96 additions and 5 deletions

View File

@@ -0,0 +1,26 @@
#include <gtest/gtest.h>
#include "keystore.h"
#include "zcash/Address.hpp"
TEST(keystore_tests, store_and_retrieve_spending_key) {
CBasicKeyStore keyStore;
std::set<libzcash::PaymentAddress> addrs;
keyStore.GetPaymentAddresses(addrs);
ASSERT_EQ(0, addrs.size());
auto sk = libzcash::SpendingKey::random();
keyStore.AddSpendingKey(sk);
auto addr = sk.address();
ASSERT_TRUE(keyStore.HaveSpendingKey(addr));
libzcash::SpendingKey keyOut;
keyStore.GetSpendingKey(addr, keyOut);
ASSERT_EQ(sk, keyOut);
keyStore.GetPaymentAddresses(addrs);
ASSERT_EQ(1, addrs.size());
ASSERT_EQ(1, addrs.count(addr));
}