Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed test_bilateral_transaction_timestamps depending on real time #7703

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import unittest.mock

from ipv8.keyvault.crypto import default_eccrypto
from ipv8.peer import Peer

Expand Down Expand Up @@ -66,10 +68,17 @@ async def test_bilateral_transaction(self):

async def test_bilateral_transaction_timestamps(self):
"""
Test creating subsequent transactions and check whether the timestamps are different.
Test whether the timestamps are different for transactions created at different times.

We do not depend on chance and ensure that `time.time()` is different between calls.
"""
tx1 = await self.overlay(ID1).do_payout(self.peer(ID2), 500)
tx2 = await self.overlay(ID1).do_payout(self.peer(ID2), 500)
with unittest.mock.patch('time.time') as fake_time:
fake_time.return_value = 10.0
tx1 = await self.overlay(ID1).do_payout(self.peer(ID2), 500)

with unittest.mock.patch('time.time') as fake_time:
fake_time.return_value = 11.0
tx2 = await self.overlay(ID1).do_payout(self.peer(ID2), 500)

assert tx1.timestamp != tx2.timestamp

Expand Down
Loading