aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/block_weight/block_weight.cpp6
-rwxr-xr-xtests/block_weight/block_weight.py16
-rw-r--r--tests/core_tests/wallet_tools.h1
-rw-r--r--tests/performance_tests/performance_tests.h13
-rw-r--r--tests/trezor/trezor_tests.cpp1
-rw-r--r--tests/unit_tests/crypto.cpp9
-rw-r--r--tests/unit_tests/epee_utils.cpp1
-rw-r--r--tests/unit_tests/multisig.cpp25
8 files changed, 40 insertions, 32 deletions
diff --git a/tests/block_weight/block_weight.cpp b/tests/block_weight/block_weight.cpp
index 4b00fc63f..676d56006 100644
--- a/tests/block_weight/block_weight.cpp
+++ b/tests/block_weight/block_weight.cpp
@@ -138,7 +138,7 @@ static uint32_t lcg()
static void test(test_t t, uint64_t blocks)
{
- PREFIX(10);
+ PREFIX(HF_VERSION_2021_SCALING);
for (uint64_t h = 0; h < LONG_TERM_BLOCK_WEIGHT_WINDOW; ++h)
{
@@ -177,8 +177,8 @@ static void test(test_t t, uint64_t blocks)
}
uint64_t ltw = bc->get_next_long_term_block_weight(w);
cryptonote::block b;
- b.major_version = 10;
- b.minor_version = 10;
+ b.major_version = HF_VERSION_2021_SCALING;
+ b.minor_version = HF_VERSION_2021_SCALING;
bc->get_db().add_block(std::make_pair(std::move(b), ""), w, ltw, bc->get_db().height(), bc->get_db().height(), {});
if (!bc->update_next_cumulative_weight_limit())
diff --git a/tests/block_weight/block_weight.py b/tests/block_weight/block_weight.py
index 5ec09896d..cfd0900fb 100755
--- a/tests/block_weight/block_weight.py
+++ b/tests/block_weight/block_weight.py
@@ -18,14 +18,20 @@ ltembw = MEDIAN_THRESHOLD
weights = [MEDIAN_THRESHOLD]*MEDIAN_WINDOW_SMALL # weights of recent blocks (B), with index -1 most recent
lt_weights = [MEDIAN_THRESHOLD]*MEDIAN_WINDOW_BIG # long-term weights
+# see contrib/epee/include/misc_language.h, get_mid
+def get_mid(a, b):
+ return (a//2) + (b//2) + ((a - 2*(a//2)) + (b - 2*(b//2)))//2;
+
# Compute the median of a list
def get_median(vec):
- #temp = vec
+ if len(vec) == 1:
+ return vec[0]
temp = sorted(vec)
+ n = len(temp) // 2
if len(temp) % 2 == 1:
- return temp[len(temp)//2]
+ return temp[n]
else:
- return int((temp[len(temp)//2]+temp[len(temp)//2-1])//2)
+ return get_mid(temp[n-1], temp[n])
def LCG():
global lcg_seed
@@ -46,7 +52,7 @@ def run(t, blocks):
# determine the effective weight
stmedian = get_median(weights[-MEDIAN_WINDOW_SMALL:])
- embw = min(max(MEDIAN_THRESHOLD,stmedian),int(MULTIPLIER_BIG*ltembw))
+ embw = min(max(ltembw,stmedian),int(MULTIPLIER_BIG*ltembw))
# drop the lowest values
weights = weights[1:]
@@ -64,7 +70,7 @@ def run(t, blocks):
else:
sys.exit(1)
weights.append(max_weight)
- lt_weights.append(min(max_weight,int(ltembw + int(ltembw * 2 / 5))))
+ lt_weights.append(min(max(max_weight, ltembw * 10 // 17),int(ltembw + int(ltembw * 7 / 10))))
#print "H %u, r %u, BW %u, EMBW %u, LTBW %u, LTEMBW %u, ltmedian %u" % (block, r, max_weight, embw, lt_weights[-1], ltembw, ltmedian)
print("H %u, BW %u, EMBW %u, LTBW %u" % (block, max_weight, embw, lt_weights[-1]))
diff --git a/tests/core_tests/wallet_tools.h b/tests/core_tests/wallet_tools.h
index 5136cc247..94921e56e 100644
--- a/tests/core_tests/wallet_tools.h
+++ b/tests/core_tests/wallet_tools.h
@@ -53,6 +53,7 @@ class wallet_accessor_test
{
public:
static void set_account(tools::wallet2 * wallet, cryptonote::account_base& account);
+ static void set_password(tools::wallet2 * wallet, const epee::wipeable_string & password) { wallet->setup_keys(password); }
static tools::wallet2::transfer_container & get_transfers(tools::wallet2 * wallet) { return wallet->m_transfers; }
static subaddresses_t & get_subaddresses(tools::wallet2 * wallet) { return wallet->m_subaddresses; }
static void process_parsed_blocks(tools::wallet2 * wallet, uint64_t start_height, const std::vector<cryptonote::block_complete_entry> &blocks, const std::vector<tools::wallet2::parsed_block> &parsed_blocks, uint64_t& blocks_added);
diff --git a/tests/performance_tests/performance_tests.h b/tests/performance_tests/performance_tests.h
index 0f16ff8fc..68679a36c 100644
--- a/tests/performance_tests/performance_tests.h
+++ b/tests/performance_tests/performance_tests.h
@@ -249,7 +249,7 @@ bool run_test(const std::string &filter, ParamsT &params_shuttle, const char* te
double stddev = runner.get_stddev();
double npskew = runner.get_non_parametric_skew();
- std::vector<TimingsDatabase::instance> prev_instances = params.td.get(test_name);
+ const TimingsDatabase::instance* prev_instance = params.td.get_most_recent(test_name);
params.td.add(test_name, {time(NULL), runner.get_size(), min, max, mean, med, stddev, npskew, quantiles});
std::cout << (params.verbose ? " time per call: " : " ") << time_per_call << " " << unit << "/call" << (params.verbose ? "\n" : "");
@@ -260,15 +260,14 @@ bool run_test(const std::string &filter, ParamsT &params_shuttle, const char* te
uint64_t p95s = quantiles[9] / scale;
uint64_t stddevs = stddev / scale;
std::string cmp;
- if (!prev_instances.empty())
+ if (prev_instance)
{
- const TimingsDatabase::instance &prev_instance = prev_instances.back();
- if (!runner.is_same_distribution(prev_instance.npoints, prev_instance.mean, prev_instance.stddev))
+ if (!runner.is_same_distribution(prev_instance->npoints, prev_instance->mean, prev_instance->stddev))
{
- double pc = fabs(100. * (prev_instance.mean - runner.get_mean()) / prev_instance.mean);
- cmp = ", " + std::to_string(pc) + "% " + (mean > prev_instance.mean ? "slower" : "faster");
+ double pc = fabs(100. * (prev_instance->mean - runner.get_mean()) / prev_instance->mean);
+ cmp = ", " + std::to_string(pc) + "% " + (mean > prev_instance->mean ? "slower" : "faster");
}
- cmp += " -- " + std::to_string(prev_instance.mean);
+ cmp += " -- " + std::to_string(prev_instance->mean);
}
std::cout << " (min " << mins << " " << unit << ", 90th " << p95s << " " << unit << ", median " << meds << " " << unit << ", std dev " << stddevs << " " << unit << ")" << cmp;
}
diff --git a/tests/trezor/trezor_tests.cpp b/tests/trezor/trezor_tests.cpp
index b21da95c0..0fcd10cef 100644
--- a/tests/trezor/trezor_tests.cpp
+++ b/tests/trezor/trezor_tests.cpp
@@ -2206,6 +2206,7 @@ bool gen_trezor_wallet_passphrase::generate(std::vector<test_event_entry>& event
const auto wallet_path = (m_wallet_dir / "alice2").string();
const epee::wipeable_string& password = epee::wipeable_string("test-pass");
+ wallet_accessor_test::set_password(m_wl_alice2.get(), password);
m_wl_alice2->store_to(wallet_path, password);
// Positive load
diff --git a/tests/unit_tests/crypto.cpp b/tests/unit_tests/crypto.cpp
index 88ecb5853..9f79ed60e 100644
--- a/tests/unit_tests/crypto.cpp
+++ b/tests/unit_tests/crypto.cpp
@@ -112,6 +112,7 @@ TEST(Crypto, tree_branch)
{
crypto::hash inputs[6];
crypto::hash branch[8];
+ crypto::hash branch_1[8 + 1];
crypto::hash root, root2;
size_t depth;
uint32_t path, path2;
@@ -296,12 +297,16 @@ TEST(Crypto, tree_branch)
ASSERT_FALSE(crypto::is_branch_in_tree(inputs[5].data, root.data, (const char(*)[32])branch, depth, path));
ASSERT_FALSE(crypto::is_branch_in_tree(crypto::null_hash.data, root.data, (const char(*)[32])branch, depth, path));
+ // a version with an extra (dummy) hash
+ memcpy(branch_1, branch, sizeof(branch));
+ branch_1[depth] = crypto::null_hash;
+
ASSERT_FALSE(crypto::is_branch_in_tree(inputs[4].data, root.data, (const char(*)[32])branch, depth - 1, path));
- ASSERT_FALSE(crypto::is_branch_in_tree(inputs[4].data, root.data, (const char(*)[32])branch, depth + 1, path));
+ ASSERT_FALSE(crypto::is_branch_in_tree(inputs[4].data, root.data, (const char(*)[32])branch_1, depth + 1, path));
ASSERT_FALSE(crypto::is_branch_in_tree(inputs[4].data, root.data, (const char(*)[32])branch, depth, path ^ 1));
ASSERT_FALSE(crypto::is_branch_in_tree(inputs[4].data, root.data, (const char(*)[32])branch, depth, path ^ 2));
ASSERT_FALSE(crypto::is_branch_in_tree(inputs[4].data, root.data, (const char(*)[32])branch, depth, path ^ 3));
- ASSERT_FALSE(crypto::is_branch_in_tree(inputs[4].data, root.data, (const char(*)[32])(branch + 1), depth, path));
+ ASSERT_FALSE(crypto::is_branch_in_tree(inputs[4].data, root.data, (const char(*)[32])(branch_1 + 1), depth, path));
// five, not found
ASSERT_FALSE(crypto::tree_branch((const char(*)[32])inputs, 5, crypto::null_hash.data, (char(*)[32])branch, &depth, &path));
diff --git a/tests/unit_tests/epee_utils.cpp b/tests/unit_tests/epee_utils.cpp
index dd3aafaa6..3573f21ba 100644
--- a/tests/unit_tests/epee_utils.cpp
+++ b/tests/unit_tests/epee_utils.cpp
@@ -1899,7 +1899,6 @@ TEST(parsing, strtoul)
p = "q";
endp = nullptr;
ul = std::strtoul(p, const_cast<char**>(&endp), 10);
- EXPECT_EQ(0, errno);
EXPECT_EQ(0, ul);
EXPECT_EQ(p, endp);
diff --git a/tests/unit_tests/multisig.cpp b/tests/unit_tests/multisig.cpp
index a79b81e84..c044591c1 100644
--- a/tests/unit_tests/multisig.cpp
+++ b/tests/unit_tests/multisig.cpp
@@ -159,12 +159,12 @@ static void check_results(const std::vector<std::string> &intermediate_infos,
for (size_t i = 0; i < wallets.size(); ++i)
{
EXPECT_TRUE(!intermediate_infos[i].empty());
- bool ready;
- uint32_t threshold, total;
- EXPECT_TRUE(wallets[i].multisig(&ready, &threshold, &total));
- EXPECT_TRUE(ready);
- EXPECT_TRUE(threshold == M);
- EXPECT_TRUE(total == wallets.size());
+ const multisig::multisig_account_status ms_status{wallets[i].get_multisig_status()};
+ EXPECT_TRUE(ms_status.multisig_is_active);
+ EXPECT_TRUE(ms_status.kex_is_done);
+ EXPECT_TRUE(ms_status.is_ready);
+ EXPECT_TRUE(ms_status.threshold == M);
+ EXPECT_TRUE(ms_status.total == wallets.size());
wallets[i].decrypt_keys("");
@@ -226,10 +226,8 @@ static void make_wallets(const unsigned int M, const unsigned int N, const bool
}
// wallets should not be multisig yet
- for (const auto &wallet: wallets)
- {
- ASSERT_FALSE(wallet.multisig());
- }
+ for (const auto& wallet: wallets)
+ ASSERT_FALSE(wallet.get_multisig_status().multisig_is_active);
// make wallets multisig, get second round kex messages (if appropriate)
std::vector<std::string> intermediate_infos(wallets.size());
@@ -242,16 +240,15 @@ static void make_wallets(const unsigned int M, const unsigned int N, const bool
++rounds_complete;
// perform kex rounds until kex is complete
- bool ready;
- wallets[0].multisig(&ready);
- while (!ready)
+ multisig::multisig_account_status ms_status{wallets[0].get_multisig_status()};
+ while (!ms_status.is_ready)
{
if (force_update)
intermediate_infos = exchange_round_force_update(wallets, intermediate_infos, rounds_complete + 1);
else
intermediate_infos = exchange_round(wallets, intermediate_infos);
- wallets[0].multisig(&ready);
+ ms_status = wallets[0].get_multisig_status();
++rounds_complete;
}