lntest: add test node name to tmp directory name

In this commit we add the LND node name to the temporary directory's
name. This change makes it easier to identify a particular test node's
temporary directory.

This commit also replaces the depreciated `ioutil.TempDir` function call
with `os.MkdirTemp`.
This commit is contained in:
ffranr 2024-03-26 18:27:15 +00:00
parent 1422df27b2
commit 05db2c35df
No known key found for this signature in database
GPG Key ID: B1F8848557AA29D2

View File

@ -97,7 +97,12 @@ type HarnessNode struct {
func NewHarnessNode(t *testing.T, cfg *BaseNodeConfig) (*HarnessNode, error) {
if cfg.BaseDir == "" {
var err error
cfg.BaseDir, err = ioutil.TempDir("", "lndtest-node")
// Create a temporary directory for the node's data and logs.
// Use dash suffix as a separator between base name and random
// suffix.
dirBaseName := fmt.Sprintf("lndtest-node-%s-", cfg.Name)
cfg.BaseDir, err = os.MkdirTemp("", dirBaseName)
if err != nil {
return nil, err
}