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

Update tests using rand.Seed as it is deprecated in go 1.20+ #2831

Closed
4 tasks
pinebit opened this issue Jan 26, 2024 · 1 comment
Closed
4 tasks

Update tests using rand.Seed as it is deprecated in go 1.20+ #2831

pinebit opened this issue Jan 26, 2024 · 1 comment
Labels
good first issue Good for newcomers protocol Protocol Team tickets

Comments

@pinebit
Copy link
Contributor

pinebit commented Jan 26, 2024

🎯 Problem to be solved

Some tests like TestEncode relay on deterministic random numbers generation. This guarantees test stability. Such the tests currently use rand.Seed(1) which is now deprecated and therefore need to be changed to rand.New(rand.NewSource(seed)). The returned instance needs to be propagated to various random generation functions such as testutil.RandomETHAddress().

🛠️ Proposed solution

  • Find all instances of using rand.Seed(seed) and replace it with rand.New(rand.NewSource(seed)).
  • The returned instance needs to be propagated to various random generation functions such as testutil.RandomETHAddress().

🧪 Tests

  • Make sure the existing tests remain stable (i.e. do not modify golden files).
  • Tested by new automated unit/integration/smoke tests
@pinebit pinebit added the good first issue Good for newcomers label Jan 26, 2024
@github-actions github-actions bot added the protocol Protocol Team tickets label Jan 26, 2024
obol-bulldozer bot pushed a commit that referenced this issue Feb 5, 2024
- Update global `rand.Seed(x)` with local `rand.New(rand.NewSource(x))`;
- Update test random functions that used global seed with local seed;
- Update `math/rand.Read(x)` with `crypto/rand.Read(x)` (not included in the issue, but deprecated as well).

category: refactor
ticket: #2831
@pinebit
Copy link
Contributor Author

pinebit commented Feb 5, 2024

Thank you @KaloyanTanev for the contribution!

@pinebit pinebit closed this as completed Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers protocol Protocol Team tickets
Projects
None yet
Development

No branches or pull requests

1 participant