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

Electrum integration tests for mainnet servers #3599

Merged
merged 30 commits into from
Jun 15, 2023
Merged

Conversation

nkuba
Copy link
Member

@nkuba nkuba commented Jun 2, 2023

In this PR we implement support for mainnet servers in the electrum client integration tests.

We also include the embedded electrum servers in the verification.

To run the tests execute:

go test -v -tags=integration ./pkg/bitcoin/electrum -count=1

Closes: #3594

nkuba added 8 commits June 2, 2023 12:21
We add test vectors for mainnet and extract exisitng test data for
testnet from integration test to the test data package.
We extract functions to assert the server messages, the responses depend
not only on the electrum server implementation but a daemon running
behind it. It's hard to maintain the exact response for the particular
server, so we just define a list of responses that are fine.
We need to cancel the connections for electrum client so nothing is
dangling in the background.
We want to execute the whole suite of tests for all the servers
including the embedded ones.

To do that we have to get the list from the config package, we use go:linkname
for that, instead of exposing the readEmbeddedServers function publicly.

We combine testnet and mainnet servers in the config, distinguishing it
with by bitcoin network property.

We renamed the package to `electrum_test` to overcome the cyclic
dependency problem that we have between the config and electrum
packages.

We read the servers in init function and then remove duplicates (by
URL), so we don't execute the test twice for the same server.
Handle testnet and mainnet, read testdata from common package, improve
latest block check to confirm all servers are on the same page.
This file is no longer needed as we test the embedded servers in
pkg/bitcoin/electrum/electrum_integration_test.go
@nkuba nkuba self-assigned this Jun 2, 2023
@pdyraga pdyraga mentioned this pull request Jun 7, 2023
2 tasks
nkuba added 5 commits June 8, 2023 16:05
Version 1.18.3 was causing tests execution to fail with panic, e.g.
https://github.com/keep-network/keep-core/actions/runs/5210502339/jobs/9402113717?pr=3599

With the latest release for 1.18 everything works fine.
The server is unstable, we have other servers for testing TCP client.
The script helps to run the integration tests consistently with the CI
job as it's based on the same solutions as defined in the workflow.
func assertConfirmationsCloseTo(t *testing.T, expected uint, actual uint) {
delta := uint(2)

func assertNumberCloseTo(t *testing.T, expected uint, actual uint, delta uint) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could make it a part of testutils. Non-blocking, it does not come from this PR.

@pdyraga
Copy link
Member

pdyraga commented Jun 12, 2023

I've executed several attempts locally and I was not able to get a green build.

However, the problems that occurred are not caused by this code. This code reveals those problems which is great.

One problem is a panic in go-electrum library, I captured the issue in the respective repository: checksum0/go-electrum#10

Other problems are timeouts for individual tests that should lead to tweaks in the number of retries and timeouts.

That being said, I would recommend:

  • Addressing the comments from the review.
  • Making this job triggered only for Electrum-related changes.
  • Making this job not required for the merge.

And then, I am happy to merge.

The last two items are already done based on what I know, but please confirm.

nkuba added 8 commits June 13, 2023 10:20
These are details of transactions swept from actual mainnet wallet.
We want to workaround the strange panic in CI, so maybe this sleep will help.
We use consistent timeouts, with exception for blockstream's servers
which need to set them longer.
We should remove entry from the test configs.
We need to capture `testName` and `testConfig` if we use `t.Parallel()`.
See `TestGroupedParallel` example [here](https://pkg.go.dev/testing).
@nkuba
Copy link
Member Author

nkuba commented Jun 13, 2023

@pdyraga it's ready for review.

Making this job triggered only for Electrum-related changes.

It was covered in #3600.

Making this job not required for the merge.

Yes, we will not require it.

nkuba added 2 commits June 13, 2023 11:51
The tag got removed by accident.
We need the details for debugging, it will help.
@nkuba nkuba requested a review from pdyraga June 15, 2023 08:25
@pdyraga
Copy link
Member

pdyraga commented Jun 15, 2023

I was able to run tests locally. All of them but TestGetTransaction_Integration/embedded/mainnet/wss://electrumx.prod-utility-eks-us-west-2.staked.cloud:443/multiple_inputs succeed. @nkuba investigated it and it is a problem with Staked Electrum server instance so the integration tests serve their purpose.

@pdyraga pdyraga enabled auto-merge June 15, 2023 08:38
@pdyraga pdyraga merged commit 78da87c into main Jun 15, 2023
@pdyraga pdyraga deleted the integration-tests-mainnet branch June 15, 2023 09:56
@pdyraga pdyraga added this to the v2.0.0-m4 milestone Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mainnet Electrum Servers Monitoring
2 participants