mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 11:29:23 +00:00
Added Merkle tree params tests
This commit is contained in:
parent
13087dd45e
commit
aebd9c28f5
1 changed files with 22 additions and 1 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "keccak.h"
|
#include "keccak.h"
|
||||||
#include "merkle.h"
|
#include "merkle.h"
|
||||||
|
#include "pool_block.h"
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
namespace p2pool {
|
namespace p2pool {
|
||||||
|
@ -249,7 +250,7 @@ TEST(merkle, aux_nonce)
|
||||||
uint32_t nonce;
|
uint32_t nonce;
|
||||||
|
|
||||||
ASSERT_TRUE(find_aux_nonce(aux_id, nonce));
|
ASSERT_TRUE(find_aux_nonce(aux_id, nonce));
|
||||||
ASSERT_EQ(nonce, 0);
|
ASSERT_EQ(nonce, 0U);
|
||||||
|
|
||||||
uint8_t data[] = "aux0";
|
uint8_t data[] = "aux0";
|
||||||
|
|
||||||
|
@ -273,4 +274,24 @@ TEST(merkle, aux_nonce)
|
||||||
ASSERT_FALSE(find_aux_nonce(aux_id, nonce));
|
ASSERT_FALSE(find_aux_nonce(aux_id, nonce));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(merkle, params)
|
||||||
|
{
|
||||||
|
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(1, 0), 0U);
|
||||||
|
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(1, 0xFFFFFFFFU), 0xFFFFFFFF0ULL);
|
||||||
|
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(127, 0), 0x3F6U);
|
||||||
|
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(127, 0xFFFFFFFFU), 0x3FFFFFFFFF6ULL);
|
||||||
|
|
||||||
|
for (uint32_t n_aux_chains = 1; n_aux_chains < 128; ++n_aux_chains) {
|
||||||
|
for (uint32_t nonce = 1; nonce; nonce <<= 1) {
|
||||||
|
PoolBlock b;
|
||||||
|
b.m_merkleTreeData = PoolBlock::encode_merkle_tree_data(n_aux_chains, nonce);
|
||||||
|
|
||||||
|
uint32_t n1, nonce1;
|
||||||
|
b.decode_merkle_tree_data(n1, nonce1);
|
||||||
|
ASSERT_EQ(n1, n_aux_chains);
|
||||||
|
ASSERT_EQ(nonce1, nonce);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue