diff --git a/chain/client/src/sync/header.rs b/chain/client/src/sync/header.rs index 52eafb4ae45..cdcff8b8f18 100644 --- a/chain/client/src/sync/header.rs +++ b/chain/client/src/sync/header.rs @@ -238,6 +238,7 @@ impl HeaderSync { if now > *stalling_ts + self.stall_ban_timeout && *highest_height == peer.highest_block_height { + // This message is used in sync_ban.py test. Consider checking there as well if you change it. // The peer is one of the peers with the highest height, but we consider the peer stalling. warn!(target: "sync", "Sync: ban a peer: {}, for not providing enough headers. Peer's height: {}", peer.peer_info, peer.highest_block_height); // Ban the peer, which blocks all interactions with the peer for some time. diff --git a/pytest/lib/utils.py b/pytest/lib/utils.py index 11f34855d00..d44a88d7581 100644 --- a/pytest/lib/utils.py +++ b/pytest/lib/utils.py @@ -111,6 +111,10 @@ def check(self, pattern: str) -> bool: """Check whether the pattern can be found in the logs.""" return pattern in self._read_file() + def check_re(self, pattern: str) -> bool: + """Check whether the regex pattern can be found in the logs.""" + return re.search(pattern, self._read_file()) != None + def reset(self) -> None: """Resets log offset to beginning of the file.""" self.offset = 0 diff --git a/pytest/tests/sanity/sync_ban.py b/pytest/tests/sanity/sync_ban.py index 707fcc8ae55..f682247078a 100755 --- a/pytest/tests/sanity/sync_ban.py +++ b/pytest/tests/sanity/sync_ban.py @@ -22,7 +22,7 @@ TIMEOUT = 300 EPOCH_LENGTH = 50 -BAN_STRING = 'ban a fraudulent peer' +BAN_STRING = 'ban a peer: [^\n]*, for not providing enough headers' class Handler(ProxyHandler): @@ -108,7 +108,7 @@ async def handle(self, msg, fr, to): assert time.time() - start < TIMEOUT if should_ban: - if tracker1.check(BAN_STRING): + if tracker1.check_re(BAN_STRING): break else: cur_height = nodes[0].get_latest_block().height @@ -122,8 +122,8 @@ async def handle(self, msg, fr, to): break time.sleep(2) - if not should_ban and (tracker0.check(BAN_STRING) or - tracker1.check(BAN_STRING)): + if not should_ban and (tracker0.check_re(BAN_STRING) or + tracker1.check_re(BAN_STRING)): assert False, "unexpected ban of peers" # logger.info('shutting down')