Fix unit test crashes for Carrot v1 block format
This commit is contained in:
@@ -51,17 +51,17 @@ TEST(block_template, update)
|
||||
data.median_weight = 300000;
|
||||
data.already_generated_coins = 6887387843126525ULL; // Current Salvium supply
|
||||
data.median_timestamp = (1ULL << 35) - 2;
|
||||
|
||||
|
||||
Mempool mempool;
|
||||
Params params;
|
||||
params.m_miningWallet = Wallet("SC11n4s2UEj9Rc8XxppPbegwQethVmREpG9JP3aJUBGRCuD3wEvS4qtYtBjhqSx3S1hw3WDCfmbWKHJqa9g5Vqyo3jrsReJ5vp");
|
||||
|
||||
// Test 1: empty template
|
||||
tpl.update(data, mempool, ¶ms);
|
||||
ASSERT_EQ(tpl.get_reward(), 8813943600ULL);
|
||||
ASSERT_EQ(tpl.get_reward(), 8813943601ULL);
|
||||
|
||||
const PoolBlock* b = tpl.pool_block_template();
|
||||
ASSERT_EQ(b->m_sidechainId, H("f92ab4527786321616805260cc19effaa151da2d7b33d1f70d25408a4c5db2d0"));
|
||||
ASSERT_EQ(b->m_sidechainId, H("559b3c4ce0f85fb74862b21872c0e7652cd238cda0868bb5e109e45bba824987"));
|
||||
|
||||
std::vector<uint8_t> blobs;
|
||||
uint64_t height;
|
||||
@@ -80,7 +80,7 @@ TEST(block_template, update)
|
||||
|
||||
hash blobs_hash;
|
||||
keccak(blobs.data(), static_cast<int>(blobs.size()), blobs_hash.h);
|
||||
ASSERT_EQ(blobs_hash, H("7e890491cf2f4a208bbd8d215ae1c03731664f4c2a896b570372d159fec1134a"));
|
||||
ASSERT_EQ(blobs_hash, H("a0aa8de98e412b38856d3c3a60f4b24159c94bb7d0f847186c729538b2ed3b29"));
|
||||
|
||||
// Test 2: mempool with high fee and low fee transactions, it must choose high fee transactions
|
||||
for (uint64_t i = 0; i < 513; ++i) {
|
||||
@@ -113,10 +113,10 @@ TEST(block_template, update)
|
||||
ASSERT_EQ(mempool.size(), 512);
|
||||
|
||||
tpl.update(data, mempool, ¶ms);
|
||||
ASSERT_EQ(tpl.get_reward(), 23512552905ULL);;
|
||||
ASSERT_EQ(tpl.get_reward(), 20408427350ULL);
|
||||
|
||||
ASSERT_EQ(b->m_sidechainId, H("40629d200bcdc8cc346d4a038fec720e57deb00471495ac7149bd5ae48985920"));
|
||||
ASSERT_EQ(b->m_transactions.size(), 269);
|
||||
ASSERT_EQ(b->m_sidechainId, H("b141fb9d1ac6a0a657b342ca7febf8c3bd4fa26e5fcfe314698e5ed8a189b8b0"));
|
||||
ASSERT_EQ(b->m_transactions.size(), 258);
|
||||
|
||||
// Transaction selection algorithm differs with Salvium parameters
|
||||
/*
|
||||
@@ -134,7 +134,7 @@ TEST(block_template, update)
|
||||
ASSERT_EQ(template_id, 2U);
|
||||
|
||||
keccak(blobs.data(), static_cast<int>(blobs.size()), blobs_hash.h);
|
||||
ASSERT_EQ(blobs_hash, H("7b8ee351f6648a63e125d77e6c1f8833cf1a3b8cdd8686c120783ad6e8a8eedd"));
|
||||
ASSERT_EQ(blobs_hash, H("dd2d21ae05f434fb776d39a85e6a517315e70054681a10086343eae620ce301c"));
|
||||
|
||||
// Test 3: small but not empty mempool, and aux chains
|
||||
/*
|
||||
@@ -198,10 +198,10 @@ TEST(block_template, update)
|
||||
ASSERT_EQ(mempool.size(), 10000);
|
||||
|
||||
tpl.update(data, mempool, ¶ms);
|
||||
ASSERT_EQ(tpl.get_reward(), 35732708305ULL);
|
||||
ASSERT_EQ(tpl.get_reward(), 29290189890ULL);
|
||||
|
||||
ASSERT_EQ(b->m_sidechainId, H("4c5c4b7ea987dcf863ca50b6c897b900be6f4e2ff4c075a332a8a79e943f4231"));
|
||||
ASSERT_EQ(b->m_transactions.size(), 299);
|
||||
ASSERT_EQ(b->m_sidechainId, H("785a5525982ac554fcfeaa61efa71c0b479d418422ed2028021bf7e8e6b79412"));
|
||||
ASSERT_EQ(b->m_transactions.size(), 277);
|
||||
|
||||
tpl.get_hashing_blobs(0, 1000, blobs, height, diff, aux_diff, sidechain_diff, seed_hash, nonce_offset, template_id);
|
||||
|
||||
@@ -213,7 +213,7 @@ TEST(block_template, update)
|
||||
ASSERT_EQ(template_id, 3U);
|
||||
|
||||
keccak(blobs.data(), static_cast<int>(blobs.size()), blobs_hash.h);
|
||||
ASSERT_EQ(blobs_hash, H("9055cc42dbade070e044ced34ae15f6b27c980b9d307ff7631ba79fc57c63d01"));
|
||||
ASSERT_EQ(blobs_hash, H("ca4057ffed2822185c0f8ab6c30ec124c8eb024db56132d47c504b86607d45d7"));
|
||||
}
|
||||
destroy_crypto_cache();
|
||||
|
||||
@@ -276,8 +276,8 @@ TEST(block_template, submit_sidechain_block)
|
||||
data.median_timestamp += sidechain.block_time();
|
||||
}
|
||||
|
||||
ASSERT_EQ(sidechain.difficulty(), 219467);
|
||||
ASSERT_EQ(sidechain.blocksById().size(), 4491);
|
||||
ASSERT_EQ(sidechain.difficulty(), 21940);
|
||||
ASSERT_EQ(sidechain.blocksById().size(), 4637);
|
||||
ASSERT_TRUE(sidechain.precalcFinished());
|
||||
|
||||
const PoolBlock* tip = sidechain.chainTip();
|
||||
@@ -289,7 +289,7 @@ TEST(block_template, submit_sidechain_block)
|
||||
ASSERT_EQ(tip->m_txinGenHeight, data.height);
|
||||
ASSERT_EQ(tip->m_sidechainHeight, sidechain.chain_window_size() * 3 - 1);
|
||||
|
||||
ASSERT_EQ(tip->m_sidechainId, H("0746fd703dbe456d86cb118fd5d9aed56f3d5615e94e05b53b91f9bb1e3d4490"));
|
||||
ASSERT_EQ(tip->m_sidechainId, H("1f1264edf6756741774ed89af60a8d7edafb397eda07dc05aabc2ced929e4d06"));
|
||||
}
|
||||
destroy_crypto_cache();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user