def test_squeak_matches_interest_is_not_reply(signing_key): replyto_hash = gen_random_hash() squeak = gen_squeak(signing_key, 5678, replyto_hash=replyto_hash) other_replyto_hash = gen_random_hash() interest = CInterested(hashReplySqk=other_replyto_hash, ) assert not squeak_matches_interest(squeak, interest)
def is_remote_subscribed(self, squeak: CSqueak): if self.remote_subscription is None: return False for interest in self.remote_subscription.vInterested: if squeak_matches_interest(squeak, interest): return True return False
def squeak_matches_interest(self, squeak: CSqueak) -> bool: locator = self.squeak_controller.get_interested_locator() for interest in locator.vInterested: if squeak_matches_interest(squeak, interest) \ and self.squeak_controller.squeak_in_limit_of_interest(squeak, interest): return True return False
def test_squeak_matches_interest_empty_addresses(signing_key, address): squeak = gen_squeak(signing_key, 5678) interest = CInterested( nMinBlockHeight=5000, nMaxBlockHeight=6000, ) assert squeak_matches_interest(squeak, interest)
def test_squeak_matches_interest_below_block_range(signing_key, address): squeak = gen_squeak(signing_key, 5678) interest = CInterested( addresses=(address, ), nMinBlockHeight=6000, nMaxBlockHeight=7000, ) assert not squeak_matches_interest(squeak, interest)
def test_squeak_matches_interest_address_no_match(signing_key, address): squeak = gen_squeak(signing_key, 5678) other_addresses = tuple(gen_squeak_addresses(3)) interest = CInterested( addresses=other_addresses, nMinBlockHeight=5000, nMaxBlockHeight=6000, ) assert not squeak_matches_interest(squeak, interest)
def matches_requested_squeak_range(self, interest: CInterested) -> bool: return squeak_matches_interest(self.squeak, interest)