mirror of
https://github.com/monero-project/monero.git
synced 2025-07-23 19:20:42 -04:00
protocol: drop origin IP if a block fails to verify in sync mode
It would otherwise be possible for a peer to send bad blocks, then disconnect and reconnect again, escaping bans
This commit is contained in:
parent
f570ce1349
commit
d729730d38
6 changed files with 64 additions and 33 deletions
|
@ -52,36 +52,38 @@ TEST(block_queue, empty)
|
|||
|
||||
TEST(block_queue, add_stepwise)
|
||||
{
|
||||
epee::net_utils::network_address na;
|
||||
cryptonote::block_queue bq;
|
||||
bq.add_blocks(0, 200, uuid1());
|
||||
bq.add_blocks(0, 200, uuid1(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 199);
|
||||
bq.add_blocks(200, 200, uuid1());
|
||||
bq.add_blocks(200, 200, uuid1(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 399);
|
||||
bq.add_blocks(401, 200, uuid1());
|
||||
bq.add_blocks(401, 200, uuid1(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 600);
|
||||
bq.add_blocks(400, 10, uuid1());
|
||||
bq.add_blocks(400, 10, uuid1(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 600);
|
||||
}
|
||||
|
||||
TEST(block_queue, flush_uuid)
|
||||
{
|
||||
cryptonote::block_queue bq;
|
||||
epee::net_utils::network_address na;
|
||||
|
||||
bq.add_blocks(0, 200, uuid1());
|
||||
bq.add_blocks(0, 200, uuid1(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 199);
|
||||
bq.add_blocks(200, 200, uuid2());
|
||||
bq.add_blocks(200, 200, uuid2(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 399);
|
||||
bq.flush_spans(uuid2());
|
||||
ASSERT_EQ(bq.get_max_block_height(), 199);
|
||||
bq.flush_spans(uuid1());
|
||||
ASSERT_EQ(bq.get_max_block_height(), 0);
|
||||
|
||||
bq.add_blocks(0, 200, uuid1());
|
||||
bq.add_blocks(0, 200, uuid1(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 199);
|
||||
bq.add_blocks(200, 200, uuid2());
|
||||
bq.add_blocks(200, 200, uuid2(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 399);
|
||||
bq.flush_spans(uuid1());
|
||||
ASSERT_EQ(bq.get_max_block_height(), 399);
|
||||
bq.add_blocks(0, 200, uuid1());
|
||||
bq.add_blocks(0, 200, uuid1(), na);
|
||||
ASSERT_EQ(bq.get_max_block_height(), 399);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue