示例#1
0
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)
示例#2
0
 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
示例#3
0
 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
示例#4
0
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)
示例#5
0
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)
示例#6
0
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)
示例#7
0
 def matches_requested_squeak_range(self, interest: CInterested) -> bool:
     return squeak_matches_interest(self.squeak, interest)