diff options
author | Crypto City <cryptocity@example.com> | 2023-11-12 11:33:20 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2023-11-30 17:01:52 +0000 |
commit | 53e632b435582193d4a708e2b7cf0bfc01ae821b (patch) | |
tree | 7a4b79bf488284a743124a0d25dd025e55d2dc61 /tests/unit_tests/crypto.cpp | |
parent | Merge pull request #9050 (diff) | |
download | monero-53e632b435582193d4a708e2b7cf0bfc01ae821b.tar.xz |
fix merge mining with more than one merge mined chain
reported by sech1
Diffstat (limited to '')
-rw-r--r-- | tests/unit_tests/crypto.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/unit_tests/crypto.cpp b/tests/unit_tests/crypto.cpp index e41f3955f..88ecb5853 100644 --- a/tests/unit_tests/crypto.cpp +++ b/tests/unit_tests/crypto.cpp @@ -307,17 +307,21 @@ TEST(Crypto, tree_branch) ASSERT_FALSE(crypto::tree_branch((const char(*)[32])inputs, 5, crypto::null_hash.data, (char(*)[32])branch, &depth, &path)); // depth encoding roundtrip - for (uint32_t n_chains = 1; n_chains <= 65; ++n_chains) + for (uint32_t n_chains = 1; n_chains <= 256; ++n_chains) { - for (uint32_t nonce = 0; nonce < 1024; ++nonce) + for (uint32_t nonce = 0xffffffff - 512; nonce != 1025; ++nonce) { - const uint32_t depth = cryptonote::encode_mm_depth(n_chains, nonce); + const uint64_t depth = cryptonote::encode_mm_depth(n_chains, nonce); uint32_t n_chains_2, nonce_2; ASSERT_TRUE(cryptonote::decode_mm_depth(depth, n_chains_2, nonce_2)); ASSERT_EQ(n_chains, n_chains_2); ASSERT_EQ(nonce, nonce_2); } } + + // 257 chains is too much + try { cryptonote::encode_mm_depth(257, 0); ASSERT_TRUE(false); } + catch (...) {} } TEST(Crypto, generator_consistency) |