CI: more tests

This commit is contained in:
SChernykh
2025-06-21 15:21:06 +02:00
parent 3f54025384
commit 5aea5768a7
3 changed files with 52 additions and 9 deletions

View File

@@ -416,12 +416,18 @@ TEST(difficulty_type, div128)
TEST(difficulty_type, compare)
{
const difficulty_type diff[4] = { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } };
const difficulty_type diff[9] = {
{ 0, 0 }, { 1, 0 }, { 2, 0 },
{ 0, 1 }, { 1, 1 }, { 2, 1 },
{ 0, 2 }, { 1, 2 }, { 2, 2 },
};
for (int i = 0; i <= 3; ++i) {
for (int j = 0; j <= 3; ++j) {
for (int i = 0; i < 9; ++i) {
for (int j = 0; j < 9; ++j) {
ASSERT_EQ(diff[i] > diff[j], i > j);
ASSERT_EQ(diff[i] < diff[j], i < j);
ASSERT_EQ(diff[i] >= diff[j], i >= j);
ASSERT_EQ(diff[i] <= diff[j], i <= j);
ASSERT_EQ(diff[i] == diff[j], i == j);
ASSERT_EQ(diff[i] != diff[j], i != j);
}
@@ -451,6 +457,15 @@ TEST(difficulty_type, input_output)
test_value(7766279631452241921ull, 5, "100000000000000000001");
test_value(14083847773837265618ull, 6692605942ull, "123456789012345678901234567890");
test_value(std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::max(), "340282366920938463463374607431768211455");
std::stringstream ss;
difficulty_type diff;
ss << "340599339356 test";
ss >> diff;
ASSERT_EQ(diff.lo, 340599339356ull);
ASSERT_EQ(diff.hi, 0ull);
}
TEST(difficulty_type, json_parser)

View File

@@ -70,9 +70,19 @@ TEST(hash, input_output)
std::stringstream ss;
ss << h;
ASSERT_EQ(ss.str(), s);
hash h2;
ss >> h2;
ASSERT_EQ(h2, h);
hash h3;
ASSERT_TRUE(from_hex(s, strlen(s), h3));
ASSERT_EQ(h3, h);
std::vector<uint8_t> v;
ASSERT_TRUE(from_hex(s, strlen(s), v));
ASSERT_EQ(v.size(), HASH_SIZE);
ASSERT_EQ(memcmp(v.data(), h.h, HASH_SIZE), 0);
};
hash h;
@@ -90,6 +100,13 @@ TEST(hash, input_output)
h.h[i] = 0xff - i;
}
check(h, "fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0");
ASSERT_FALSE(from_hex("123", 3, h));
ASSERT_FALSE(from_hex("000000000000000000000000000000000000000000000000000000000000000z", HASH_SIZE * 2, h));
std::vector<uint8_t> v;
ASSERT_FALSE(from_hex("123", 3, v));
ASSERT_FALSE(from_hex("000000000000000000000000000000000000000000000000000000000000000z", HASH_SIZE * 2, v));
}
TEST(hash, json_parser)

View File

@@ -129,14 +129,15 @@ TEST(pool_block, verify)
const char* m_fileName;
uint64_t m_txinGenHeight;
uint64_t m_sidechainHeight;
uint32_t m_expectedSharesNextBlock;
bool m_shuffle;
} tests[6] = {
{ "default", "sidechain_dump.dat", 3258121, 9443762, false },
{ "default", "sidechain_dump.dat", 3258121, 9443762, true },
{ "mini", "sidechain_dump_mini.dat", 3258121, 8912067, false },
{ "mini", "sidechain_dump_mini.dat", 3258121, 8912067, true },
{ "nano", "sidechain_dump_nano.dat", 3438036, 116651, false },
{ "nano", "sidechain_dump_nano.dat", 3438036, 116651, true },
{ "default", "sidechain_dump.dat", 3258121, 9443762, 30, false },
{ "default", "sidechain_dump.dat", 3258121, 9443762, 30, true },
{ "mini", "sidechain_dump_mini.dat", 3258121, 8912067, 593, false },
{ "mini", "sidechain_dump_mini.dat", 3258121, 8912067, 593, true },
{ "nano", "sidechain_dump_nano.dat", 3438036, 116651, 131, false },
{ "nano", "sidechain_dump_nano.dat", 3438036, 116651, 131, true },
};
for (const STest& t : tests)
@@ -203,6 +204,16 @@ TEST(pool_block, verify)
ASSERT_EQ(tip->m_txinGenHeight, t.m_txinGenHeight);
ASSERT_EQ(tip->m_sidechainHeight, t.m_sidechainHeight);
PoolBlock block;
block.m_minerWallet.decode("44MnN1f3Eto8DZYUWuE5XZNUtE3vcRzt2j6PzqWpPau34e6Cf4fAxt6X2MBmrm6F9YMEiMNjN6W4Shn4pLcfNAja621jwyg");
std::vector<MinerShare> shares;
sidechain.fill_sidechain_data(block, shares);
ASSERT_EQ(block.m_sidechainHeight, t.m_sidechainHeight + 1);
ASSERT_EQ(shares.size(), t.m_expectedSharesNextBlock);
}
destroy_crypto_cache();