[Testing] Refactor test helpers#753
Conversation
…782) ## Description Add replace directives for `gocuke` and `go-mockdns` forks/releases until upstream PRs are merged. Includes `TECHDEBT` comments for removal. ## Issue Extracted from #753 ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [x] Other: swapping test dependencies for our own forks/releases thereof ## List of changes <!-- REMOVE this comment block after following the instructions List out all the changes made --> - Replaced `github.com/foxcpp/go-mockdns` with `github.com/pokt-network/go-mockdns v0.0.1` - Replaced `github.com/regen-network/gocuke` with `github.com/pokt-network/gocuke v0.0.1` ## Testing - [ ] `make develop_test`; if any code changes were made - [ ] `make test_e2e` on [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any code changes were made - [ ] `e2e-devnet-test` passes tests on [DevNet](https://pocketnetwork.notion.site/How-to-DevNet-ff1598f27efe44c09f34e2aa0051f0dd); if any code was changed - [ ] [Docker Compose LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md); if any major functionality was changed or introduced - [ ] [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any infrastructure or configuration changes were made ## Required Checklist - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added, or updated, [`godoc` format comments](https://go.dev/blog/godoc) on touched members (see: [tip.golang.org/doc/comment](https://tip.golang.org/doc/comment)) - [ ] I have tested my changes using the available tooling - [ ] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s)
| for i, done := 0, false; i < keyCount && !done; { | ||
| done = !scanner.Scan() | ||
| line := scanner.Text() | ||
| matches := privKeyManifestKeyRegex.FindStringSubmatch(line) |
There was a problem hiding this comment.
I wonder how this compares to this function performance wise. Decode YAML into struct and extract the keys vs. Regex
There was a problem hiding this comment.
IIRC, when I wrote this, private-keys.yaml was still embedding the genesis as json so I did not pursue yaml parsing. A quick benchmark should reveal a definitive answer but I'm betting on yaml parsing being faster (perhaps with a larger memory footprint).
| ) | ||
|
|
||
| func TestLoadLocalnetPrivateKeys(t *testing.T) { | ||
| keyCount := 1000 |
There was a problem hiding this comment.
This may need to be 3996 unless you are only checking validators
There was a problem hiding this comment.
Good looking out 👍
This test only exercises extracting the keys from the file, it has no notion of node types and doesn't interact with genesis.
| "context" | ||
| "fmt" | ||
| "github.com/pokt-network/pocket/internal/testutil/p2p" | ||
| "github.com/pokt-network/pocket/internal/testutil/persistence" |
There was a problem hiding this comment.
| "github.com/pokt-network/pocket/internal/testutil/persistence" | |
| persistence_testutil "github.com/pokt-network/pocket/internal/testutil/persistence" |
There was a problem hiding this comment.
@h5law you add these import aliases manually or did an IDE do it? Just curious. I explicitly (unconventionally) named the package so that an import alias wouldn't be required but I didn't have a strong opinion on whether to use one anyways.
There was a problem hiding this comment.
I did I saw the errors as you were using persistence_testutil in the code and assumed this would be the import name
| import ( | ||
| "context" | ||
| "fmt" | ||
| "github.com/pokt-network/pocket/internal/testutil/p2p" |
There was a problem hiding this comment.
| "github.com/pokt-network/pocket/internal/testutil/p2p" | |
| p2p_testutil "github.com/pokt-network/pocket/internal/testutil/p2p" |
| "github.com/pokt-network/pocket/p2p/providers/peerstore_provider" | ||
| "github.com/pokt-network/pocket/runtime" | ||
| "github.com/pokt-network/pocket/shared/messaging" | ||
| "github.com/regen-network/gocuke" |
There was a problem hiding this comment.
| "github.com/regen-network/gocuke" | |
| "github.com/pokt-network/gocuke" |
Now you have published releases should these update?
There was a problem hiding this comment.
Good question! Short answer, no.
We would prefer to use the upstream modules but need to be able to use our fork until those changes are merged upstream. To facilitate this we can use the replace directive (above) so that the import statements in the code don't need to be updated when we switch.
go.mod
Outdated
|
|
||
| go 1.18 | ||
|
|
||
| replace github.com/regen-network/gocuke v0.6.2 => ../gocuke |
There was a problem hiding this comment.
Mentioned this below, your new pokt-network/gocuke package and same for mockdns can be used here instead?
There was a problem hiding this comment.
Yup.. this branch is outdated. See https://github.com/pokt-network/pocket/pull/782/files
h5law
left a comment
There was a problem hiding this comment.
Did not do a thorough review of all of the new mock functions themselves, but left some comments around the keys and certain imports. Looks good so far <3
|
@h5law this is still very WIP. The most up to date thinking is reflected in the notion document we'll be talking about in protocol hour today: https://pocketnetwork.notion.site/Testutils-9cba9010e18447248e9daa8a3b87e3f2 (It will also be rebased at some point) |
|
@h5law FYI: The timeline item(s) that result will contain a link/ref to the old HEAD and AFAIK, until this branch is deleted, those commits should still be accessible if need be (i.e. can |
d089187 to
4dc8486
Compare
ab81389 to
b01996d
Compare
4dc8486 to
cb4bf21
Compare
b01996d to
a8206ec
Compare
…782) ## Description Add replace directives for `gocuke` and `go-mockdns` forks/releases until upstream PRs are merged. Includes `TECHDEBT` comments for removal. ## Issue Extracted from #753 ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] Bug fix - [ ] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [x] Other: swapping test dependencies for our own forks/releases thereof ## List of changes <!-- REMOVE this comment block after following the instructions List out all the changes made --> - Replaced `github.com/foxcpp/go-mockdns` with `github.com/pokt-network/go-mockdns v0.0.1` - Replaced `github.com/regen-network/gocuke` with `github.com/pokt-network/gocuke v0.0.1` ## Testing - [ ] `make develop_test`; if any code changes were made - [ ] `make test_e2e` on [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any code changes were made - [ ] `e2e-devnet-test` passes tests on [DevNet](https://pocketnetwork.notion.site/How-to-DevNet-ff1598f27efe44c09f34e2aa0051f0dd); if any code was changed - [ ] [Docker Compose LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md); if any major functionality was changed or introduced - [ ] [k8s LocalNet](https://github.com/pokt-network/pocket/blob/main/build/localnet/README.md); if any infrastructure or configuration changes were made ## Required Checklist - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added, or updated, [`godoc` format comments](https://go.dev/blog/godoc) on touched members (see: [tip.golang.org/doc/comment](https://tip.golang.org/doc/comment)) - [ ] I have tested my changes using the available tooling - [ ] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s)
Description
Issue
...
Type of change
Please mark the relevant option(s):
List of changes
Testing
make develop_test; if any code changes were madeRequired Checklist
godocformat comments on touched members (see: tip.golang.org/doc/comment)If Applicable Checklist
shared/docs/*if I updatedshared/*README(s)