aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbenevanoff <benjaminevanoff99@gmail.com>2023-11-03 13:07:17 -0500
committernahuhh <50635951+nahuhh@users.noreply.github.com>2025-07-03 16:10:29 +0000
commit8f5a7b0f1a0c2954a249318cf2f3760096991b67 (patch)
tree9c00f654bebbe8ced6297f32deebccc96c02a849 /tests
parentdf765433699ee53f4ee0fef1b3991ab14e9f2267 (diff)
downloadmonzero-core-8f5a7b0f1a0c2954a249318cf2f3760096991b67.tar.gz
monzero-core-8f5a7b0f1a0c2954a249318cf2f3760096991b67.tar.xz
monzero-core-8f5a7b0f1a0c2954a249318cf2f3760096991b67.zip
wallet: ensure subaddress keys table is at least size of requested lookahead
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/subaddress.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/unit_tests/subaddress.cpp b/tests/unit_tests/subaddress.cpp
index 17fc0fe78..b03e58f5a 100644
--- a/tests/unit_tests/subaddress.cpp
+++ b/tests/unit_tests/subaddress.cpp
@@ -28,6 +28,7 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#include <boost/filesystem.hpp>
+#include <boost/optional/optional_io.hpp>
#include "gtest/gtest.h"
#include "include_base_utils.h"
@@ -101,3 +102,29 @@ TEST_F(WalletSubaddress, OutOfBoundsIndexes)
EXPECT_STREQ("index.minor is out of bound", e.what());
}
}
+
+TEST_F(WalletSubaddress, ExpandPubkeyTable)
+{
+ // these test assume we are starting with the default setup state
+ EXPECT_EQ(2, w1.get_num_subaddress_accounts());
+ EXPECT_EQ(50, w1.get_subaddress_lookahead().first);
+ EXPECT_EQ(200, w1.get_subaddress_lookahead().second);
+ // get_subaddress_index looks up keys in the private m_subaddresses dictionary so we will use it to test if a key is properly being scanned for
+ cryptonote::subaddress_index test_idx = {50, 199};
+ auto subaddr = w1.get_subaddress(test_idx);
+ EXPECT_NE(boost::none, w1.get_subaddress_index(subaddr));
+ // fist test expanding the major lookahead
+ w1.set_subaddress_lookahead(100, 200);
+ EXPECT_EQ(100, w1.get_subaddress_lookahead().first);
+ EXPECT_EQ(200, w1.get_subaddress_lookahead().second);
+ test_idx = {100, 199};
+ subaddr = w1.get_subaddress(test_idx);
+ EXPECT_NE(boost::none, w1.get_subaddress_index(subaddr));
+ // next test expanding the minor lookahead
+ w1.set_subaddress_lookahead(100, 300);
+ EXPECT_EQ(100, w1.get_subaddress_lookahead().first);
+ EXPECT_EQ(300, w1.get_subaddress_lookahead().second);
+ test_idx = {100, 299};
+ subaddr = w1.get_subaddress(test_idx);
+ EXPECT_NE(boost::none, w1.get_subaddress_index(subaddr));
+}