-
Notifications
You must be signed in to change notification settings - Fork 8
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
test: refactor test data generation #51
Conversation
e9e7b5d
to
7ec4e5f
Compare
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. Just some issues with data files name formatting, and some outdated module refs that would be nice to fix before merging.
r := rand.New(rand.NewSource(time.Now().UnixNano())) | ||
|
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.
So, if I understand correctly, the same random source needs to be used for all of the data generation?
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.
Yes. This seems to be a good practice. The issue I was facing is as follows. I was using two fresh r := rand.New(rand.NewSource(time.Now().UnixNano()))
to generate secret keys for covenant members and finality providers in test data. Since the code was fast, the two r
end up using the same timestamp and being the same value. Then the 1st covenant secret key is same as the 1st finality provider secret key. As Babylon does not accept duplicate keys in the staking script (i.e., any duplication among FP keys, covenant keys and staker key), the tests panicked. Using the same rand source solves this issue.
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.
Makes sense overall, but I find difficult to believe that both r
have the same seed, as it's a timestamp in nanoseconds resolution. Are these routines being called in parallel or so?
582c8da
to
4294b13
Compare
This PR refactors the tests, including
This is the prerequisite for testing the full validation of finality providers / BTC delegations.