More tests

This commit is contained in:
SChernykh 2023-11-23 14:02:00 +01:00
parent aebd9c28f5
commit 65d83aa09c
3 changed files with 21 additions and 5 deletions

View file

@ -588,7 +588,7 @@ void p2pool::submit_block_async(std::vector<uint8_t>&& blob)
}
}
void p2pool::submit_aux_block(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce)
void p2pool::submit_aux_block(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce) const
{
size_t nonce_offset = 0;
size_t extra_nonce_offset = 0;

View file

@ -87,7 +87,7 @@ public:
void submit_block_async(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
void submit_block_async(std::vector<uint8_t>&& blob);
void submit_aux_block(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
void submit_aux_block(const hash& chain_id, uint32_t template_id, uint32_t nonce, uint32_t extra_nonce) const;
bool submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);

View file

@ -281,12 +281,28 @@ TEST(merkle, params)
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(127, 0), 0x3F6U);
ASSERT_EQ(PoolBlock::encode_merkle_tree_data(127, 0xFFFFFFFFU), 0x3FFFFFFFFF6ULL);
PoolBlock b;
uint32_t n1, nonce1;
b.m_merkleTreeData = 0;
b.decode_merkle_tree_data(n1, nonce1);
ASSERT_TRUE(n1 == 1 && nonce1 == 0);
b.m_merkleTreeData = 0xFFFFFFFF0ULL;
b.decode_merkle_tree_data(n1, nonce1);
ASSERT_TRUE(n1 == 1 && nonce1 == 0xFFFFFFFFU);
b.m_merkleTreeData = 0x3F6U;
b.decode_merkle_tree_data(n1, nonce1);
ASSERT_TRUE(n1 == 127 && nonce1 == 0);
b.m_merkleTreeData = 0x3FFFFFFFFF6ULL;
b.decode_merkle_tree_data(n1, nonce1);
ASSERT_TRUE(n1 == 127 && nonce1 == 0xFFFFFFFFU);
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);