Restore legacy HD seed storage & retrieval tests.
This commit is contained in:
parent
b67e62d977
commit
22fa6b22ea
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
const uint32_t SLIP44_TESTNET_TYPE = 1;
|
const uint32_t SLIP44_TESTNET_TYPE = 1;
|
||||||
|
|
||||||
TEST(KeystoreTests, StoreAndRetrieveHDSeed) {
|
TEST(KeystoreTests, StoreAndRetrieveMnemonicSeed) {
|
||||||
CBasicKeyStore keyStore;
|
CBasicKeyStore keyStore;
|
||||||
|
|
||||||
// When we haven't set a seed, we shouldn't get one
|
// When we haven't set a seed, we shouldn't get one
|
||||||
|
@ -45,6 +45,33 @@ TEST(KeystoreTests, StoreAndRetrieveHDSeed) {
|
||||||
EXPECT_EQ(seed, seedOut.value());
|
EXPECT_EQ(seed, seedOut.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(KeystoreTests, StoreAndRetrieveLegacyHDSeed) {
|
||||||
|
CBasicKeyStore keyStore;
|
||||||
|
|
||||||
|
// When we haven't set a seed, we shouldn't get one
|
||||||
|
std::optional<HDSeed> seedOut = keyStore.GetLegacyHDSeed();
|
||||||
|
EXPECT_FALSE(seedOut.has_value());
|
||||||
|
|
||||||
|
// Generate a random seed
|
||||||
|
HDSeed seed = MnemonicSeed::Random(SLIP44_TESTNET_TYPE);
|
||||||
|
|
||||||
|
// We should be able to set and retrieve the seed
|
||||||
|
ASSERT_TRUE(keyStore.SetLegacyHDSeed(seed));
|
||||||
|
seedOut = keyStore.GetLegacyHDSeed();
|
||||||
|
ASSERT_TRUE(seedOut.has_value());
|
||||||
|
EXPECT_EQ(seed, seedOut.value());
|
||||||
|
|
||||||
|
// Generate another random seed
|
||||||
|
HDSeed seed2 = MnemonicSeed::Random(SLIP44_TESTNET_TYPE);
|
||||||
|
EXPECT_NE(seed, seed2);
|
||||||
|
|
||||||
|
// We should not be able to set and retrieve a different seed
|
||||||
|
EXPECT_FALSE(keyStore.SetLegacyHDSeed(seed2));
|
||||||
|
seedOut = keyStore.GetLegacyHDSeed();
|
||||||
|
ASSERT_TRUE(seedOut.has_value());
|
||||||
|
EXPECT_EQ(seed, seedOut.value());
|
||||||
|
}
|
||||||
|
|
||||||
TEST(KeystoreTests, SaplingKeys) {
|
TEST(KeystoreTests, SaplingKeys) {
|
||||||
// ["sk, ask, nsk, ovk, ak, nk, ivk, default_d, default_pk_d, note_v, note_r, note_cm, note_pos, note_nf"],
|
// ["sk, ask, nsk, ovk, ak, nk, ivk, default_d, default_pk_d, note_v, note_r, note_cm, note_pos, note_nf"],
|
||||||
UniValue sapling_keys = read_json(MAKE_STRING(json_tests::sapling_key_components));
|
UniValue sapling_keys = read_json(MAKE_STRING(json_tests::sapling_key_components));
|
||||||
|
|
|
@ -48,6 +48,16 @@ public:
|
||||||
|
|
||||||
uint256 Fingerprint() const;
|
uint256 Fingerprint() const;
|
||||||
RawHDSeed RawSeed() const { return seed; }
|
RawHDSeed RawSeed() const { return seed; }
|
||||||
|
|
||||||
|
friend bool operator==(const HDSeed& a, const HDSeed& b)
|
||||||
|
{
|
||||||
|
return a.seed == b.seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator!=(const HDSeed& a, const HDSeed& b)
|
||||||
|
{
|
||||||
|
return !(a == b);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue