funding: use T.TempDir to create temporary test directory

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun 2022-08-15 21:06:13 +08:00
parent dbf3cf62fe
commit 4f1e4ff87a
No known key found for this signature in database
GPG Key ID: DAEBBD2E34C111E6

View File

@ -8,9 +8,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"runtime"
"strings"
@ -644,19 +642,13 @@ type cfgOption func(*Config)
func setupFundingManagers(t *testing.T,
options ...cfgOption) (*testNode, *testNode) {
aliceTestDir, err := ioutil.TempDir("", "alicelnwallet")
require.NoError(t, err, "unable to create temp directory")
alice, err := createTestFundingManager(
t, alicePrivKey, aliceAddr, aliceTestDir, options...,
t, alicePrivKey, aliceAddr, t.TempDir(), options...,
)
require.NoError(t, err, "failed creating fundingManager")
bobTestDir, err := ioutil.TempDir("", "boblnwallet")
require.NoError(t, err, "unable to create temp directory")
bob, err := createTestFundingManager(
t, bobPrivKey, bobAddr, bobTestDir, options...,
t, bobPrivKey, bobAddr, t.TempDir(), options...,
)
require.NoError(t, err, "failed creating fundingManager")
@ -699,8 +691,6 @@ func tearDownFundingManagers(t *testing.T, a, b *testNode) {
if err := b.fundingMgr.Stop(); err != nil {
t.Fatalf("failed stop funding manager: %v", err)
}
os.RemoveAll(a.testDir)
os.RemoveAll(b.testDir)
}
// openChannel takes the funding process to the point where the funding