diff --git a/macaroons/constraints_test.go b/macaroons/constraints_test.go index dd97536a..569acea8 100644 --- a/macaroons/constraints_test.go +++ b/macaroons/constraints_test.go @@ -1,6 +1,7 @@ package macaroons_test import ( + "fmt" "strings" "testing" "time" @@ -14,7 +15,7 @@ var ( testID = []byte("dummyId") testLocation = "lnd" testVersion = macaroon.LatestVersion - expectedTimeCaveatSubstring = "time-before " + string(time.Now().Year()) + expectedTimeCaveatSubstring = fmt.Sprintf("time-before %d", time.Now().Year()) ) func createDummyMacaroon(t *testing.T) *macaroon.Macaroon { @@ -67,8 +68,8 @@ func TestTimeoutConstraint(t *testing.T) { } // Finally, check that the created caveat has an - // acceptable value - if strings.HasPrefix(string(testMacaroon.Caveats()[0].Id), + // acceptable value. + if !strings.HasPrefix(string(testMacaroon.Caveats()[0].Id), expectedTimeCaveatSubstring) { t.Fatalf("Added caveat '%s' does not meet the expectations!", testMacaroon.Caveats()[0].Id) @@ -90,7 +91,7 @@ func TestIpLockConstraint(t *testing.T) { } // Finally, check that the created caveat has an - // acceptable value + // acceptable value. if string(testMacaroon.Caveats()[0].Id) != "ipaddr 127.0.0.1" { t.Fatalf("Added caveat '%s' does not meet the expectations!", testMacaroon.Caveats()[0].Id)