Skip to content

Commit

Permalink
test: replace t.TempDir()
Browse files Browse the repository at this point in the history
Use os.MkdirTemp() instead of t.TempDir() for the DataDir.
The shorter temp paths avoid problems with
long unix socket paths composed using the DataDir.
See golang/go#62614.
  • Loading branch information
YusukeShimizu committed Dec 31, 2024
1 parent 02f6732 commit 2367667
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,19 @@ func clnclnSetupWithConfig(t *testing.T, fundAmt, pushAmt uint64,
// Get PeerSwap plugin path and test dir
_, filename, _, _ := runtime.Caller(0)
pathToPlugin := filepath.Join(filename, "..", "..", "out", "test-builds", "peerswap")
testDir := t.TempDir()

// Use os.MkdirTemp() instead of t.TempDir() for the DataDir.
// The shorter temp paths avoid problems with long unix socket paths composed
// using the DataDir.
// See https://github.com/golang/go/issues/62614.
makeDataDir := func() string {
tempDir, err := os.MkdirTemp("", "cln-test-")
require.NoError(t, err, "os.MkdirTemp failed")
t.Cleanup(func() { os.RemoveAll(tempDir) })
return tempDir
}

testDir := makeDataDir()

// Setup nodes (1 bitcoind, 2 lightningd)
bitcoind, err := testframework.NewBitcoinNode(testDir, 1)
Expand Down

0 comments on commit 2367667

Please sign in to comment.