package auth

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestDecodeWalletSignatureRejectsMalformedValues(t *testing.T) {
	_, err := decodeWalletSignature("deadbeef")
	require.ErrorContains(t, err, "signature must start with 0x")

	_, err = decodeWalletSignature("0x1234")
	require.ErrorContains(t, err, "invalid signature length")
}

func TestValidateJWTReturnsClaimsWhenDBUnavailable(t *testing.T) {
	secret := []byte("test-secret")
	auth := NewWalletAuth(nil, secret)

	token, _, err := auth.generateJWT("0x4A666F96fC8764181194447A7dFdb7d471b301C8", 4)
	require.NoError(t, err)

	address, track, err := auth.ValidateJWT(token)
	require.NoError(t, err)
	require.Equal(t, "0x4A666F96fC8764181194447A7dFdb7d471b301C8", address)
	require.Equal(t, 4, track)
}
