Make unlock_and_withdraw test deterministic#130
Conversation
|
|
||
| time.sleep(500) | ||
| while client.current_era() < client.withdrawal_era(alice): | ||
| time.sleep(1) |
There was a problem hiding this comment.
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.
052db8f to
ba8f11a
Compare
|
@TheQuantumPhysicist Take a look and approve if you like it. |
|
|
||
| time.sleep(500) | ||
| num_attempts = 0 | ||
| max_attempts = 10000 |
There was a problem hiding this comment.
10000 seconds is like 3 hours... you sure?
There was a problem hiding this comment.
@TheQuantumPhysicist I chose this a bit randomly.... Should we go for 20 minutes? That's twice as long as it should take.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@TheQuantumPhysicist Two questions:
- Is error different from exception?
- I'm not sure if your suggestion regarding using time only refers to a change of the variable names or something more than that.
TheQuantumPhysicist
left a comment
There was a problem hiding this comment.
The wait mechanism can be improved. I made my comments there. But other than that, looks good. Good job!
84bd8c5 to
ceceb5a
Compare
ceceb5a to
f5c1ac2
Compare
No description provided.