-
Notifications
You must be signed in to change notification settings - Fork 959
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
Add disable_process_reveal_deadlines
decorator and reveal_deadlines_setting
meta tag
#2017
Conversation
…OCHS_PER_CUSTODY_PERIOD`-long transition
It's still unacceptable slow to generate these test vectors. I suggest applying |
disable_process_reveal_deadlines
decorator and reveal_deadlines_setting
meta tagdisable_process_reveal_deadlines
decorator and reveal_deadlines_setting
meta tag
I agree |
Skip the too-slow custody tests and turn on the generators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutating the spec during testing is tricky, but possible. See review comment, I think the new disable_process_reveal_deadlines
decorator doesn't work as expected.
@@ -165,6 +165,9 @@ bls_setting: int -- optional, can have 3 different values: | |||
but there is no change of outcome when running the test if BLS is ON or OFF. | |||
1: known as "BLS required" - if the test validity is strictly dependent on BLS being ON | |||
2: known as "BLS ignored" - if the test validity is strictly dependent on BLS being OFF | |||
reveal_deadlines_setting: -- optional, can have 2 different values: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be a bool, but if we end up having more settings then this is compatible. 👍
def disable_process_reveal_deadlines(fn): | ||
def entry(*args, spec: Spec, **kw): | ||
if hasattr(spec, 'process_reveal_deadlines'): | ||
spec.process_reveal_deadlines = lambda state: None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mutates the spec object. Making it not re-usable. I.e. other tests afterwards will also have a no-operation process_reveal_deadlines
. The decorator has to set the old function back, after running the wrapped test, for this to work as expected.
Also beware of returned generators not being evaluated directly; the wrapped function should be evaluated fully before undoing the no-op substitute. A similar thing is done in the BLS decorator, if you need an example. See bls_switch
in context.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch! 👍👍
I forgot that the test generator mode scope != pytest unit test mode scope.
Thinking long-term, a heavier but imho better approach for testing would be:
Shall I open an issue for this? I think it's out of scope for this PR, but given the easy mistake with cc @djrtwo |
9a1ed74
to
15614f1
Compare
…back to the spec function for other test cases afterwards
15614f1
to
fd4e7dd
Compare
Yes, I fully support it! 👍 I once tried to implement Trinity has a similar pattern. From what I can tell, it’s a much better way to handle the forks. The main benefit I see for other teams is that we could use Python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue
Fix #2015
Solution
disable_process_reveal_deadlines
decorator to disable phase 1process_reveal_deadlines
function.reveal_deadlines_setting
meta tag: ifreveal_deadlines_setting
is 1, disable theprocess_reveal_deadlines
function.TODOs
@disable_process_reveal_deadlines
to some custody game tests.process_reveal_deadlines
default to enabled. However,process_reveal_deadlines
may affect some more tests' state balances and make it difficult to debug. We may want to disable it in more irrelevant test cases.