From d8ba37427fbe4a6d4c2977ed90d41b036e104109 Mon Sep 17 00:00:00 2001 From: Roland <33993199+rolznz@users.noreply.github.com> Date: Sat, 20 Jul 2024 17:31:17 +0700 Subject: [PATCH] fix: remove race flag from go test commands (#304) * fix: remove race flag from go test commands * fix: multi_ payments assertions --- .github/workflows/build-docker.yaml | 2 +- .github/workflows/http.yml | 2 +- README.md | 4 ++-- .../multi_pay_invoice_controller_test.go | 17 +++++++++++++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 4cc664c5..901b111a 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -16,7 +16,7 @@ jobs: with: go-version-file: "./go.mod" - name: Run tests - run: mkdir frontend/dist && touch frontend/dist/tmp && go test -race ./... + run: mkdir frontend/dist && touch frontend/dist/tmp && go test ./... - name: Docker build if: github.actor != 'dependabot[bot]' uses: mr-smithers-excellent/docker-build-push@v6 diff --git a/.github/workflows/http.yml b/.github/workflows/http.yml index 947e2c6e..3ef636bf 100644 --- a/.github/workflows/http.yml +++ b/.github/workflows/http.yml @@ -57,7 +57,7 @@ jobs: node-version: "20.x" - name: Run tests - run: mkdir frontend/dist && touch frontend/dist/tmp && go test -race ./... + run: mkdir frontend/dist && touch frontend/dist/tmp && go test ./... - name: Build frontend run: | diff --git a/README.md b/README.md index 0b28e003..7c6ead15 100644 --- a/README.md +++ b/README.md @@ -88,11 +88,11 @@ _If you get a blank screen, try running in your normal terminal (outside of vsco ### Testing - $ go test -race ./... + $ go test ./... #### Test matching regular expression - $ go test -race ./... -run TestHandleGetInfoEvent + $ go test ./... -run TestHandleGetInfoEvent ### Profiling diff --git a/nip47/controllers/multi_pay_invoice_controller_test.go b/nip47/controllers/multi_pay_invoice_controller_test.go index c6beec66..c651a350 100644 --- a/nip47/controllers/multi_pay_invoice_controller_test.go +++ b/nip47/controllers/multi_pay_invoice_controller_test.go @@ -160,6 +160,15 @@ func TestHandleMultiPayInvoiceEvent_OneMalformedInvoice(t *testing.T) { HandleMultiPayInvoiceEvent(ctx, nip47Request, requestEvent.ID, app, publishResponse) assert.Equal(t, 2, len(responses)) + assert.Equal(t, 2, len(dTags)) + + // we can't guarantee which request was processed first + // so swap them if they are back to front + if responses[0].Result != nil { + responses[0], responses[1] = responses[1], responses[0] + dTags[0], dTags[1] = dTags[1], dTags[0] + } + assert.Equal(t, "invoiceId123", dTags[0].GetFirst([]string{"d"}).Value()) assert.Equal(t, models.ERROR_INTERNAL, responses[0].Error.Code) assert.Nil(t, responses[0].Result) @@ -224,6 +233,14 @@ func TestHandleMultiPayInvoiceEvent_IsolatedApp_OneBudgetExceeded(t *testing.T) HandleMultiPayInvoiceEvent(ctx, nip47Request, dbRequestEvent.ID, app, publishResponse) assert.Equal(t, 2, len(responses)) + assert.Equal(t, 2, len(dTags)) + + // we can't guarantee which request was processed first + // so swap them if they are back to front + if responses[0].Result == nil { + responses[0], responses[1] = responses[1], responses[0] + dTags[0], dTags[1] = dTags[1], dTags[0] + } assert.Equal(t, "320c2c5a1492ccfd5bc7aa4ad9b657d6aaec3cfcc0d1d98413a29af4ac772ccf", dTags[0].GetFirst([]string{"d"}).Value()) assert.Equal(t, "123preimage", responses[0].Result.(payResponse).Preimage)