Merge pull request #2536 from kcalvinalvin/2026-05-30-run-and-fix-broken-integration-tests-1
Some checks failed
Build and Test / Build (push) Has been cancelled
Build and Test / Unit coverage (push) Has been cancelled
Build and Test / Unit race (push) Has been cancelled
Build and Test / Unit rpctest (push) Has been cancelled

.github: actually run the integration tests in the CI
This commit is contained in:
Yong 2026-06-04 15:18:53 +08:00 committed by GitHub
commit 1966c38453
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 51 additions and 7 deletions

View file

@ -145,3 +145,18 @@ jobs:
- name: Test
run: make unit-race
test-rpctest:
name: Unit rpctest
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Check out source
uses: actions/checkout@v4
- name: Test
run: make unit

View file

@ -385,6 +385,9 @@ func (h *StringOrArray) UnmarshalJSON(data []byte) error {
}
switch v := unmarshalled.(type) {
case nil:
*h = nil
case string:
*h = []string{v}

View file

@ -350,6 +350,16 @@ func TestGetBlockChainInfoWarnings(t *testing.T) {
result: `{"warnings": []}`,
expected: btcjson.StringOrArray{},
},
{
name: "blockchain info with null warnings",
result: `{"warnings": null}`,
expected: nil,
},
{
name: "blockchain info with warnings field omitted",
result: `{}`,
expected: nil,
},
}
for _, test := range tests {

View file

@ -6,6 +6,7 @@ package integration
import (
"testing"
"github.com/btcsuite/btcd/address/v2"
"github.com/btcsuite/btcd/btcutil/v2"
"github.com/btcsuite/btcd/chaincfg/v2"
"github.com/btcsuite/btcd/integration/rpctest"
@ -46,7 +47,7 @@ func TestPayToAnchorSimple(t *testing.T) {
// Create a P2A output using the helper to get a P2A address. This
// ensures we're using the same P2A script generation logic.
p2aAddr, err := btcutil.NewAddressPayToAnchor(&chaincfg.SimNetParams)
p2aAddr, err := address.NewAddressPayToAnchor(&chaincfg.SimNetParams)
if err != nil {
t.Fatalf("unable to create P2A address: %v", err)
}

View file

@ -6,6 +6,7 @@ package rpctest
import (
"fmt"
"math/rand/v2"
"os/exec"
"path/filepath"
"runtime"
@ -43,8 +44,12 @@ func btcdExecutablePath() (string, error) {
return "", err
}
// Build btcd and output an executable in a static temp path.
outputPath := filepath.Join(testDir, "btcd")
// Build btcd to a random path so concurrent `go test` processes
// (e.g. when test packages run in parallel under `make unit`) do
// not race on the same output file. Each test process pays a
// one-time compile cost; within a process the compileMtx-guarded
// cache keeps it to one build.
outputPath := filepath.Join(testDir, fmt.Sprintf("btcd-%d", rand.Uint32()))
if runtime.GOOS == "windows" {
outputPath += ".exe"
}

View file

@ -6,6 +6,7 @@ package rpctest
import (
"fmt"
"math/rand/v2"
"net"
"os"
"path/filepath"
@ -76,7 +77,15 @@ var (
// lastPort is the last port determined to be free for use by a new
// node. It should be used atomically.
lastPort uint32 = defaultNodePort
//
// Seed with a random offset so concurrent `go test` processes
// (e.g. when integration/ and integration/rpctest/ run in parallel
// under `make unit`) do not race on the same port range. The
// bind-test in NextAvailablePort closes the listener before
// returning, leaving a window where another process could grab the
// same port; staggering each process's starting point avoids the
// collision. The 50k-port window leaves headroom below 65535.
lastPort uint32 = defaultNodePort + rand.Uint32N(50000)
)
// HarnessTestCase represents a test-case which utilizes an instance of the

View file

@ -1124,9 +1124,10 @@ func (sm *SyncManager) handleInvMsg(imsg *invMsg) {
peer.UpdateLastAnnouncedBlock(&invVects[lastBlock].Hash)
}
// Ignore invs from peers that aren't the sync if we are not current.
// Helps prevent fetching a mass of orphans.
if peer != sm.syncPeer && !sm.current() {
// Ignore invs from peers that aren't the sync peer if we are not
// current. Helps prevent fetching a mass of orphans. When syncPeer
// is nil, accept invs from any peer.
if sm.syncPeer != nil && peer != sm.syncPeer && !sm.current() {
return
}