mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-04 12:31:39 +02:00
watchtower: replace defer cleanup with t.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@ -1528,8 +1528,10 @@ func TestClient(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
h := newHarness(t, tc.cfg)
|
h := newHarness(t, tc.cfg)
|
||||||
defer h.server.Stop()
|
t.Cleanup(func() {
|
||||||
defer h.client.ForceQuit()
|
require.NoError(t, h.server.Stop())
|
||||||
|
h.client.ForceQuit()
|
||||||
|
})
|
||||||
|
|
||||||
tc.fn(h)
|
tc.fn(h)
|
||||||
})
|
})
|
||||||
|
@ -68,6 +68,9 @@ func initServer(t *testing.T, db wtserver.DB,
|
|||||||
if err = s.Start(); err != nil {
|
if err = s.Start(); err != nil {
|
||||||
t.Fatalf("unable to start server: %v", err)
|
t.Fatalf("unable to start server: %v", err)
|
||||||
}
|
}
|
||||||
|
t.Cleanup(func() {
|
||||||
|
require.NoError(t, s.Stop())
|
||||||
|
})
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@ -83,7 +86,6 @@ func TestServerOnlyAcceptOnePeer(t *testing.T) {
|
|||||||
const timeoutDuration = 500 * time.Millisecond
|
const timeoutDuration = 500 * time.Millisecond
|
||||||
|
|
||||||
s := initServer(t, nil, timeoutDuration)
|
s := initServer(t, nil, timeoutDuration)
|
||||||
defer s.Stop()
|
|
||||||
|
|
||||||
localPub := randPubKey(t)
|
localPub := randPubKey(t)
|
||||||
|
|
||||||
@ -284,7 +286,6 @@ func testServerCreateSession(t *testing.T, i int, test createSessionTestCase) {
|
|||||||
const timeoutDuration = 500 * time.Millisecond
|
const timeoutDuration = 500 * time.Millisecond
|
||||||
|
|
||||||
s := initServer(t, nil, timeoutDuration)
|
s := initServer(t, nil, timeoutDuration)
|
||||||
defer s.Stop()
|
|
||||||
|
|
||||||
localPub := randPubKey(t)
|
localPub := randPubKey(t)
|
||||||
|
|
||||||
@ -639,7 +640,6 @@ func testServerStateUpdates(t *testing.T, test stateUpdateTestCase) {
|
|||||||
const timeoutDuration = 100 * time.Millisecond
|
const timeoutDuration = 100 * time.Millisecond
|
||||||
|
|
||||||
s := initServer(t, nil, timeoutDuration)
|
s := initServer(t, nil, timeoutDuration)
|
||||||
defer s.Stop()
|
|
||||||
|
|
||||||
localPub := randPubKey(t)
|
localPub := randPubKey(t)
|
||||||
|
|
||||||
@ -747,7 +747,6 @@ func TestServerDeleteSession(t *testing.T) {
|
|||||||
const timeoutDuration = 100 * time.Millisecond
|
const timeoutDuration = 100 * time.Millisecond
|
||||||
|
|
||||||
s := initServer(t, db, timeoutDuration)
|
s := initServer(t, db, timeoutDuration)
|
||||||
defer s.Stop()
|
|
||||||
|
|
||||||
// Create a session for peer2 so that the server's db isn't completely
|
// Create a session for peer2 so that the server's db isn't completely
|
||||||
// empty.
|
// empty.
|
||||||
|
Reference in New Issue
Block a user