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

[Testing] Prefer pre-generated keys in tests #614

Open
1 of 8 tasks
bryanchriswhite opened this issue Mar 24, 2023 · 2 comments
Open
1 of 8 tasks

[Testing] Prefer pre-generated keys in tests #614

bryanchriswhite opened this issue Mar 24, 2023 · 2 comments
Assignees
Labels
testing Defining, adding, automating or modifying tests

Comments

@bryanchriswhite
Copy link
Contributor

bryanchriswhite commented Mar 24, 2023

Objective

Enabling faster and more deterministic tests.

Origin Document

image

Goals

  • Ability to pre-generate an arbitrary number of keys
  • Pre-generated keys are accessible via vanilla go imports (see: storj/common testidentity pkg)
  • Pre-generated keys are tracked in version control (same keys everywhere: devs, CI, etc.)

Deliverable

  • Add a make target which generates the keys, output as go source code. Load existing pre-generated keys from private-keys.yaml
  • Add a package (e.g. testkeys; also see [Testing] Organizing test utilities package(s) #609) which exports a means by which to retrieve the pre-generated as cryptoPocket.PrivateKeys
    • I think the iterator pattern is nice for this because it fits well with our use case as we typically don't want to reuse keys (identity), across nodes for example.
    • It would be prudent to ensure that we can also retrieve specific identities, I think via index should suffice.

Non-goals / Non-deliverables

  • Refactoring existing tests to use pre-generated identities.

General issue deliverables

  • Update the appropriate CHANGELOG(s)
  • Update any relevant local/global README(s)
  • Update relevant source code tree explanations
  • Add or update any relevant or supporting mermaid diagrams

Testing Methodology

  • All tests: make test_all
  • LocalNet: verify a LocalNet is still functioning correctly by following the instructions at docs/development/README.md

Creator: @bryanchriswhite
Co-Owners: @deblasis

@bryanchriswhite bryanchriswhite added the testing Defining, adding, automating or modifying tests label Mar 24, 2023
@bryanchriswhite bryanchriswhite moved this to Rescope in V1 Dashboard Mar 24, 2023
@bryanchriswhite bryanchriswhite moved this from Rescope to Backlog in V1 Dashboard Mar 24, 2023
@Olshansk
Copy link
Member

@bryanchriswhite Though it is not pre-generated, we do have runtime/test_artifacts/keygen/keygen.go which enables determinstic keys:

func (k *keyGenerator) SetSeed(seed int) (teardown func()) {
	k.privateKeySeed = seed
	return func() {
		k.reset()
	}
}

func (k *keyGenerator) Next() (privateKey, publicKey, address string) {
	k.privateKeySeed += 1 // Different on every call but deterministic

Do you think that's enough in terms of our testing utility to validate the need for this scope of work?

@bryanchriswhite
Copy link
Contributor Author

bryanchriswhite commented Apr 21, 2023

@Olshansk thanks for surfacing that! 🙌

That should address the determinism aspect. The only other improvement I was anticipating would potentially be a speed improvement in CI (depending on "things" which I haven't looked into yet).

This issue was based on observations I made while debugging tests. It's definitely not urgent but I'm not sure how important it is (or could be, depending on "things").

I think the MVC here is to just go after the second delivarable. We already have ~1K keypairs in private-keys.yaml which we could then use in unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Defining, adding, automating or modifying tests
Projects
Status: Backlog
Development

No branches or pull requests

2 participants