From 2367667a72fc163e4959abbe85af70f2893bdab9 Mon Sep 17 00:00:00 2001 From: bruwbird Date: Tue, 31 Dec 2024 15:36:20 +0900 Subject: [PATCH] test: replace 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. --- test/setup.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/setup.go b/test/setup.go index 8dc9e0fe..574b5ca4 100644 --- a/test/setup.go +++ b/test/setup.go @@ -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)