From 28d3dc853235e484835756c7a1b27f28cf887ea8 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 2 Aug 2018 19:13:24 -0700 Subject: [PATCH] Add test for CWalletTx::SetSaplingNoteData() --- src/wallet/gtest/test_wallet.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 9ab62c0d4..63dd4d891 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -350,6 +350,19 @@ TEST(WalletTests, SetInvalidNoteAddrsInCWalletTx) { EXPECT_THROW(wtx.SetSproutNoteData(noteData), std::logic_error); } +// Cannot add note data for an index which does not exist in tx.vShieldedOutput +TEST(WalletTests, SetInvalidSaplingNoteDataInCWalletTx) { + CWalletTx wtx; + EXPECT_EQ(0, wtx.mapSaplingNoteData.size()); + + mapSaplingNoteData_t noteData; + SaplingOutPoint op {uint256(), 1}; + SaplingNoteData nd; + noteData.insert(std::make_pair(op, nd)); + + EXPECT_THROW(wtx.SetSaplingNoteData(noteData), std::logic_error); +} + TEST(WalletTests, GetSproutNoteNullifier) { CWallet wallet;