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

time_travel always fails when blocks is 0 #358

Closed
antazoey opened this issue Dec 31, 2024 · 3 comments
Closed

time_travel always fails when blocks is 0 #358

antazoey opened this issue Dec 31, 2024 · 3 comments

Comments

@antazoey
Copy link

(Pdb) env
<boa.environment.Env object at 0x111088170>
(Pdb) env.time_travel(seconds=123, blocks=0)
*** ValueError: One of seconds or blocks should be set

Looking at the code:

if (seconds is None) == (blocks is None):

Both seconds is not None and blocks is not None and those are equal so i get the weird error message.
Workaround:

env.time_travel(seconds=123, blocks=None)

^ but kinda weird when params are dynamically figured out

@charles-cooper
Copy link
Member

i think this is expected behavior -- time_travel only allows one of block_number or timestamp to be set. if you want to set them in a "low-level" way, just modify patch.block_number and patch.timestamp directly

@antazoey
Copy link
Author

antazoey commented Jan 1, 2025

Ah, in that case I would suggest adjusting the error message:

ValueError: One of seconds or blocks should be set

to something like

ValueError: One (and only one) of seconds or blocks should be set

@antazoey antazoey closed this as completed Jan 1, 2025
@charles-cooper
Copy link
Member

#359

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants