Skip to content
This repository was archived by the owner on Apr 8, 2022. It is now read-only.

Make unlock_and_withdraw test deterministic#130

Merged
royster57 merged 4 commits intostagingfrom
roy/functional_b
Nov 22, 2021
Merged

Make unlock_and_withdraw test deterministic#130
royster57 merged 4 commits intostagingfrom
roy/functional_b

Conversation

@royster57
Copy link

No description provided.


time.sleep(500)
while client.current_era() < client.withdrawal_era(alice):
time.sleep(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there should be a hard timeout as well in case there is a bug somewhere that causes withdrawal_era to never be reached.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I will add it.

@royster57
Copy link
Author

@TheQuantumPhysicist Take a look and approve if you like it.


time.sleep(500)
num_attempts = 0
max_attempts = 10000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10000 seconds is like 3 hours... you sure?

Copy link
Author

@royster57 royster57 Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheQuantumPhysicist I chose this a bit randomly.... Should we go for 20 minutes? That's twice as long as it should take.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I'd prefer that you change this whole thing to wait for time units, not retry count. If it isn't clear what I mean, hit me with a DM.

num_attempts = 0
max_attempts = 10000
while client.current_era() < client.withdrawal_era(alice):
num_attempts += 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this in terms of time, I'd use a period instead of num_attempts, and then wait that period in the sleep. When max_wait is exceeded, I'd call it an error. Since Python is very tolerant with types, you can make use of it and have only time instead of time + unitless numeric attempts.

Copy link
Author

@royster57 royster57 Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheQuantumPhysicist Two questions:

  1. Is error different from exception?
  2. I'm not sure if your suggestion regarding using time only refers to a change of the variable names or something more than that.

Copy link
Contributor

@TheQuantumPhysicist TheQuantumPhysicist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wait mechanism can be improved. I made my comments there. But other than that, looks good. Good job!

@royster57 royster57 force-pushed the roy/functional_b branch 7 times, most recently from 84bd8c5 to ceceb5a Compare November 22, 2021 03:43
@royster57 royster57 merged commit e2ca982 into staging Nov 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants