aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-12-08 17:55:24 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-12-10 22:00:01 +0000
commitd729730d380fa25f0b122dd4ef6f331a35748a4b (patch)
tree6e7725c03947b47272261de132abb166e11749b8 /tests
parentMerge pull request #7109 (diff)
downloadmonero-d729730d380fa25f0b122dd4ef6f331a35748a4b.tar.xz
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
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/block_queue.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/unit_tests/block_queue.cpp b/tests/unit_tests/block_queue.cpp
index 77c7f97ff..01c742c11 100644
--- a/tests/unit_tests/block_queue.cpp
+++ b/tests/unit_tests/block_queue.cpp
@@ -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);
}