mirror of
https://github.com/lightninglabs/aperture.git
synced 2026-01-24 11:44:24 +01:00
auth: LsatAuthenticator -> L402Authenticator sed -i 's/LsatAuthenticator/L402Authenticator/g' aperture.go auth/authenticator.go auth/authenticator_test.go rename package lsat to l402 git mv lsat/ l402 sed 's@aperture/lsat@aperture/l402@g' -i `git grep -l aperture/lsat` sed -i 's@package lsat@package l402@' `git grep -l 'package lsat'` sed -i 's@lsat\.@l402.@g' -i `git grep -l 'lsat\.'` sed 's@l402.Id@lsat.Id@' -i mint/mint_test.go replace lsat with l402 in the code sed 's@lsat@l402@' -i mint/mint_test.go sed 's@Lsat@L402@' -i l402/client_interceptor.go sed 's@lsatstore@l402store@' -i l402/store_test.go replace LSAT to L402 in comments sed '/\/\//s@LSAT@L402@g' -i `git grep -l '//.*LSAT'` replace LSAT -> L402 in the code, skip when a string starts with it sed 's@\([^"/]\)LSAT@\1L402@g' -i `git grep -l LSAT`
71 lines
1.3 KiB
Go
71 lines
1.3 KiB
Go
package l402
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/lightningnetwork/lnd/lntypes"
|
|
)
|
|
|
|
var (
|
|
testPaymentHash lntypes.Hash
|
|
testTokenID [TokenIDSize]byte
|
|
)
|
|
|
|
// TestIdentifierSerialization ensures proper serialization of known identifier
|
|
// versions and failures for unknown versions.
|
|
func TestIdentifierSerialization(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
id Identifier
|
|
err error
|
|
}{
|
|
{
|
|
name: "valid identifier",
|
|
id: Identifier{
|
|
Version: LatestVersion,
|
|
PaymentHash: testPaymentHash,
|
|
TokenID: testTokenID,
|
|
},
|
|
err: nil,
|
|
},
|
|
{
|
|
name: "unknown version",
|
|
id: Identifier{
|
|
Version: LatestVersion + 1,
|
|
PaymentHash: testPaymentHash,
|
|
TokenID: testTokenID,
|
|
},
|
|
err: ErrUnknownVersion,
|
|
},
|
|
}
|
|
|
|
for _, test := range tests {
|
|
test := test
|
|
success := t.Run(test.name, func(t *testing.T) {
|
|
var buf bytes.Buffer
|
|
err := EncodeIdentifier(&buf, &test.id)
|
|
if !errors.Is(err, test.err) {
|
|
t.Fatalf("expected err \"%v\", got \"%v\"",
|
|
test.err, err)
|
|
}
|
|
if test.err != nil {
|
|
return
|
|
}
|
|
id, err := DecodeIdentifier(&buf)
|
|
if err != nil {
|
|
t.Fatalf("unable to decode identifier: %v", err)
|
|
}
|
|
if *id != test.id {
|
|
t.Fatalf("expected id %v, got %v", test.id, *id)
|
|
}
|
|
})
|
|
if !success {
|
|
return
|
|
}
|
|
}
|
|
}
|