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 test_get_sent_offer_by_squeak_and_peer_wrong_squeak_hash( squeak_db, inserted_sent_offer_id, sent_offer, peer_address, creation_date, expiry, ): expire_time_s = creation_date + expiry current_time_s = expire_time_s - 10 fake_current_time_ms = current_time_s * 1000 with mock.patch.object( SqueakDb, 'timestamp_now_ms', new_callable=mock.PropertyMock) as mock_timestamp_ms: mock_timestamp_ms.return_value = fake_current_time_ms retrieved_sent_offer = squeak_db.get_sent_offer_by_squeak_hash_and_peer( gen_random_hash(), peer_address, ) assert retrieved_sent_offer is None
def payment_hash(preimage): # TODO: This should be the hash of the preimage yield gen_random_hash()
def preimage(): yield gen_random_hash()
def other_block_info(): yield BlockInfo( block_height=5678, block_hash=gen_random_hash(), block_header=b'', )
def test_get_ancestor_squeak_entries_no_ancestors_or_root(squeak_db, ): # Get the ancestor squeak entries. squeak_entries = squeak_db.get_thread_ancestor_squeak_entries( squeak_hash=gen_random_hash(), ) assert len(squeak_entries) == 0
def test_get_sent_offer_missing(squeak_db, inserted_sent_offer_id): random_hash = gen_random_hash() retrieved_sent_offer = squeak_db.get_sent_offer_by_payment_hash( random_hash, ) assert retrieved_sent_offer is None
def test_get_received_offers_other_squeak_hash(squeak_db, inserted_received_offer_id): received_offers = squeak_db.get_received_offers( squeak_hash=gen_random_hash(), ) assert len(received_offers) == 0