@j-berman comments 4

This commit is contained in:
jeffro256 2024-04-10 12:23:21 -05:00
parent aa99643e43
commit d7fba8867b
No known key found for this signature in database
GPG Key ID: 6F79797A6E392442
3 changed files with 49 additions and 4 deletions

View File

@ -193,7 +193,7 @@ int check_flush(cryptonote::core &core, std::vector<block_complete_entry> &block
block_verification_context bvc = {};
pool_supplement ps{};
core.handle_incoming_block(block_entry.block, pblocks.empty() ? NULL : &pblocks[blockidx++], bvc, ps); // <--- process block
core.handle_incoming_block(block_entry.block, pblocks.empty() ? NULL : &pblocks[blockidx++], bvc, ps, false); // <--- process block
if(bvc.m_verifivation_failed)
{

View File

@ -1498,7 +1498,8 @@ namespace cryptonote
m_core.handle_incoming_block(block_entry.block,
pblocks.empty() ? NULL : &pblocks[blockidx],
bvc,
block_txs); // <--- process block
block_txs,
false); // <--- process block
if(bvc.m_verifivation_failed)
{

View File

@ -44,7 +44,8 @@ class P2PTest():
self.create()
self.mine(80)
self.test_p2p_reorg()
self.test_p2p_tx_propagation()
txid = self.test_p2p_tx_propagation()
self.test_p2p_block_propagation(txid)
def reset(self):
print('Resetting blockchain')
@ -179,7 +180,7 @@ class P2PTest():
assert len(res.txs) == 1
tx_details = res.txs[0]
assert not tx_details.in_pool
#assert res.txs[0].block_height > (6 + 500 - 2), res.txs[0].block_height
daemon2_tx_height = tx_details.block_height
# reconnect, daemon3 will now switch to daemon2's chain
daemon2.out_peers(8)
@ -194,6 +195,13 @@ class P2PTest():
assert daemon2_height == daemon3_height
assert daemon2_top_block_hash == daemon3_top_block_hash
# assert that the tx is in daemon3's blockchain now
res = daemon3.get_transactions([txid])
assert len(res.txs) == 1
tx_details = res.txs[0]
assert not tx_details.in_pool
assert tx_details.block_height == daemon2_tx_height
def test_p2p_tx_propagation(self):
print('Testing P2P tx propagation')
daemon2 = Daemon(idx = 2)
@ -218,6 +226,42 @@ class P2PTest():
assert len(res.tx_hashes) == 1
assert res.tx_hashes[0] == txid
return txid
def test_p2p_block_propagation(self, daemon2_mempool_txid):
print('Testing P2P block propagation')
daemon2 = Daemon(idx = 2)
daemon3 = Daemon(idx = 3)
# check precondition: txid in daemon2 mempool
res = daemon2.get_transaction_pool_hashes()
assert daemon2_mempool_txid in res.tx_hashes
res = daemon2.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1)
block_height = res.height
# wait until both are synced
loops = 5
while True:
res2 = daemon2.get_info()
res3 = daemon3.get_info()
if res2.top_block_hash == res3.top_block_hash:
break
time.sleep(5)
loops -= 1
assert loops >= 0
# check the tx is in both daemons
for daemon in [daemon2, daemon3]:
res = daemon.get_transaction_pool_hashes()
assert not 'tx_hashes' in res or len(res.tx_hashes) == 0
res = daemon.get_transactions([daemon2_mempool_txid])
assert len(res.txs) == 1
tx_details = res.txs[0]
assert not tx_details.in_pool
assert tx_details.block_height == block_height
if __name__ == '__main__':
P2PTest().run_test()