mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 08:17:37 +00:00
functional_tests: add a large (many randomx epochs) p2p reorg test
This commit is contained in:
parent
6a0b3b1f8a
commit
d20ff4f648
2 changed files with 54 additions and 4 deletions
|
@ -1181,11 +1181,42 @@ namespace cryptonote
|
|||
size_t core::get_block_sync_size(uint64_t height) const
|
||||
{
|
||||
static const uint64_t quick_height = m_nettype == TESTNET ? 801219 : m_nettype == MAINNET ? 1220516 : 0;
|
||||
size_t res = 0;
|
||||
if (block_sync_size > 0)
|
||||
return block_sync_size;
|
||||
if (height >= quick_height)
|
||||
return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT;
|
||||
return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4;
|
||||
res = block_sync_size;
|
||||
else if (height >= quick_height)
|
||||
res = BLOCKS_SYNCHRONIZING_DEFAULT_COUNT;
|
||||
else
|
||||
res = BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4;
|
||||
|
||||
static size_t max_block_size = 0;
|
||||
if (max_block_size == 0)
|
||||
{
|
||||
const char *env = getenv("SEEDHASH_EPOCH_BLOCKS");
|
||||
if (env)
|
||||
{
|
||||
int n = atoi(env);
|
||||
if (n <= 0)
|
||||
n = BLOCKS_SYNCHRONIZING_MAX_COUNT;
|
||||
size_t p = 1;
|
||||
while (p < (size_t)n)
|
||||
p <<= 1;
|
||||
max_block_size = p;
|
||||
}
|
||||
else
|
||||
max_block_size = BLOCKS_SYNCHRONIZING_MAX_COUNT;
|
||||
}
|
||||
if (res > max_block_size)
|
||||
{
|
||||
static bool warned = false;
|
||||
if (!warned)
|
||||
{
|
||||
MWARNING("Clamping block sync size to " << max_block_size);
|
||||
warned = true;
|
||||
}
|
||||
res = max_block_size;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::are_key_images_spent_in_pool(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const
|
||||
|
|
|
@ -139,6 +139,25 @@ class P2PTest():
|
|||
assert res.height == height + 6
|
||||
assert res.top_block_hash == daemon2_top_block_hash
|
||||
|
||||
# disconnect and mine a lot on daemon3
|
||||
daemon2.out_peers(0)
|
||||
daemon3.out_peers(0)
|
||||
res = daemon3.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 500)
|
||||
|
||||
# reconnect and wait for sync
|
||||
daemon2.out_peers(8)
|
||||
daemon3.out_peers(8)
|
||||
loops = 100
|
||||
while True:
|
||||
res2 = daemon2.get_info()
|
||||
res3 = daemon3.get_info()
|
||||
if res2.top_block_hash == res3.top_block_hash:
|
||||
break
|
||||
time.sleep(10)
|
||||
loops -= 1
|
||||
assert loops >= 0
|
||||
|
||||
|
||||
def test_p2p_tx_propagation(self):
|
||||
print('Testing P2P tx propagation')
|
||||
daemon2 = Daemon(idx = 2)
|
||||
|
|
Loading…
Reference in a new issue