You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
652 B
27 lines
652 B
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) |
|
}
|
|
|