pokt-network / pocket

Official implementation of the Pocket Network Protocol v1
https://pokt.network
MIT License
62 stars 33 forks source link

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

Open bryanchriswhite opened 1 year ago

bryanchriswhite commented 1 year ago

Objective

Enabling faster and more deterministic tests.

Origin Document

image

Goals

Deliverable

Non-goals / Non-deliverables

General issue deliverables

Testing Methodology


Creator: @bryanchriswhite Co-Owners: @deblasis

Olshansk commented 1 year ago

@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 commented 1 year ago

@Olshansk thanks for surfacing that! :raised_hands:

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.