Skip to content

Commit da2724f

Browse files
committed
[Test] Coverage for loadSaplingKey and metadata.
1 parent 3e5f653 commit da2724f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/test/librust/wallet_zkeys_tests.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ BOOST_FIXTURE_TEST_SUITE(wallet_zkeys_tests, WalletTestingSetup)
2525
/**
2626
* This test covers Sapling methods on CWallet
2727
* GenerateNewSaplingZKey()
28+
* AddSaplingZKey()
29+
* LoadSaplingZKey()
30+
* LoadSaplingZKeyMetadata()
2831
*/
2932
BOOST_AUTO_TEST_CASE(StoreAndLoadSaplingZkeys) {
3033
SelectParams(CBaseChainParams::MAIN);
@@ -73,6 +76,19 @@ BOOST_AUTO_TEST_CASE(StoreAndLoadSaplingZkeys) {
7376
BOOST_CHECK_EQUAL(2, addrs.size());
7477
BOOST_CHECK_EQUAL(1, addrs.count(address));
7578
BOOST_CHECK_EQUAL(1, addrs.count(sk.DefaultAddress()));
79+
80+
// Load a third key into the wallet
81+
auto sk2 = m.Derive(1);
82+
BOOST_CHECK(wallet.LoadSaplingZKey(sk2));
83+
84+
// attach metadata to this third key
85+
auto ivk2 = sk2.expsk.full_viewing_key().in_viewing_key();
86+
int64_t now = GetTime();
87+
CKeyMetadata meta(now);
88+
BOOST_CHECK(wallet.LoadSaplingZKeyMetadata(ivk2, meta));
89+
90+
// check metadata is the same
91+
BOOST_CHECK_EQUAL(wallet.GetSaplingScriptPubKeyMan()->mapSaplingZKeyMetadata[ivk2].nCreateTime, now);
7692
}
7793

7894
/**

0 commit comments

Comments
 (0)