mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-29 15:11:09 +02:00
channeldb: read raw htlc attempt session key
This commit is contained in:
27
channeldb/mp_payment_test.go
Normal file
27
channeldb/mp_payment_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
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)
|
||||
}
|
Reference in New Issue
Block a user