mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-01 10:11:11 +02:00
macaroons: drop unused variables in tests
macaroons: defer service.Close() after error check in tests macaroons: linter requires that nil contexts are changed to context.TODO()
This commit is contained in:
@@ -61,18 +61,19 @@ func TestNewService(t *testing.T) {
|
||||
// Second, create the new service instance, unlock it and pass in a
|
||||
// checker that we expect it to add to the bakery.
|
||||
service, err := macaroons.NewService(tempDir, macaroons.IPLockChecker)
|
||||
defer service.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating new service: %v", err)
|
||||
}
|
||||
defer service.Close()
|
||||
err = service.CreateUnlock(&defaultPw)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unlocking root key storage: %v", err)
|
||||
}
|
||||
|
||||
// Third, check if the created service can bake macaroons.
|
||||
macaroon, err := service.Oven.NewMacaroon(nil, bakery.LatestVersion,
|
||||
nil, testOperation)
|
||||
macaroon, err := service.Oven.NewMacaroon(
|
||||
context.TODO(), bakery.LatestVersion, nil, testOperation,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating macaroon from service: %v", err)
|
||||
}
|
||||
@@ -104,18 +105,20 @@ func TestValidateMacaroon(t *testing.T) {
|
||||
tempDir := setupTestRootKeyStorage(t)
|
||||
defer os.RemoveAll(tempDir)
|
||||
service, err := macaroons.NewService(tempDir, macaroons.IPLockChecker)
|
||||
defer service.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating new service: %v", err)
|
||||
}
|
||||
defer service.Close()
|
||||
|
||||
err = service.CreateUnlock(&defaultPw)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unlocking root key storage: %v", err)
|
||||
}
|
||||
|
||||
// Then, create a new macaroon that we can serialize.
|
||||
macaroon, err := service.Oven.NewMacaroon(nil, bakery.LatestVersion,
|
||||
nil, testOperation)
|
||||
macaroon, err := service.Oven.NewMacaroon(
|
||||
context.TODO(), bakery.LatestVersion, nil, testOperation,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating macaroon from service: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user