lnd/channeldb/mp_payment_test.go

28 lines
652 B
Go

package channeldb
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
)
// TestLazySessionKeyDeserialize tests that we can read htlc attempt session
// keys that were previously serialized as a private key as raw bytes.
func TestLazySessionKeyDeserialize(t *testing.T) {
var b bytes.Buffer
// Serialize as a private key.
err := WriteElements(&b, priv)
require.NoError(t, err)
// Deserialize into [btcec.PrivKeyBytesLen]byte.
attempt := HTLCAttemptInfo{}
err = ReadElements(&b, &attempt.sessionKey)
require.NoError(t, err)
require.Zero(t, b.Len())
sessionKey := attempt.SessionKey()
require.Equal(t, priv, sessionKey)
}