diff --git a/cert/selfsigned_test.go b/cert/selfsigned_test.go index dd9953e2a..3f5e694b2 100644 --- a/cert/selfsigned_test.go +++ b/cert/selfsigned_test.go @@ -1,7 +1,6 @@ package cert_test import ( - "io/ioutil" "testing" "time" @@ -21,16 +20,13 @@ var ( // TestIsOutdatedCert checks that we'll consider the TLS certificate outdated // if the ip addresses or dns names don't match. func TestIsOutdatedCert(t *testing.T) { - tempDir, err := ioutil.TempDir("", "certtest") - if err != nil { - t.Fatal(err) - } + tempDir := t.TempDir() certPath := tempDir + "/tls.cert" keyPath := tempDir + "/tls.key" // Generate TLS files with two extra IPs and domains. - err = cert.GenCertPair( + err := cert.GenCertPair( "lnd autogenerated cert", certPath, keyPath, extraIPs[:2], extraDomains[:2], false, testTLSCertDuration, ) @@ -76,16 +72,13 @@ func TestIsOutdatedCert(t *testing.T) { // nor dulicates in the lists, matter for whether we consider the certificate // outdated. func TestIsOutdatedPermutation(t *testing.T) { - tempDir, err := ioutil.TempDir("", "certtest") - if err != nil { - t.Fatal(err) - } + tempDir := t.TempDir() certPath := tempDir + "/tls.cert" keyPath := tempDir + "/tls.key" // Generate TLS files from the IPs and domains. - err = cert.GenCertPair( + err := cert.GenCertPair( "lnd autogenerated cert", certPath, keyPath, extraIPs[:], extraDomains[:], false, testTLSCertDuration, ) @@ -143,16 +136,13 @@ func TestIsOutdatedPermutation(t *testing.T) { // TestTLSDisableAutofill checks that setting the --tlsdisableautofill flag // does not add interface ip addresses or hostnames to the cert. func TestTLSDisableAutofill(t *testing.T) { - tempDir, err := ioutil.TempDir("", "certtest") - if err != nil { - t.Fatal(err) - } + tempDir := t.TempDir() certPath := tempDir + "/tls.cert" keyPath := tempDir + "/tls.key" // Generate TLS files with two extra IPs and domains and no interface IPs. - err = cert.GenCertPair( + err := cert.GenCertPair( "lnd autogenerated cert", certPath, keyPath, extraIPs[:2], extraDomains[:2], true, testTLSCertDuration, )