Skip to content

Commit

Permalink
Merge pull request #342 from ElementsProject/shorter-temp-paths
Browse files Browse the repository at this point in the history
test: replace t.TempDir()
  • Loading branch information
YusukeShimizu authored Jan 6, 2025
2 parents 02f6732 + 2367667 commit 4350878
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 4350878

Please sign in to comment.