mirror of
https://github.com/luxfi/platformvm.git
synced 2026-10-30 15:22:12 +00:00
- Drop atomic_block.go + legacy *_block_test.go (consolidated) - Add block/v0/ subdir + lift_v0.go for old version handling - Copyright header: 'Lux Industries, Inc.' → 'Lux Industries Inc' (no comma) - block_adapter.go: new adapter layer
52 lines
1.0 KiB
Go
52 lines
1.0 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package warp
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/luxfi/codec"
|
|
"github.com/luxfi/constants"
|
|
"github.com/luxfi/crypto/bls"
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
func TestMessage(t *testing.T) {
|
|
require := require.New(t)
|
|
|
|
payload := []byte("payload")
|
|
|
|
unsignedMsg, err := NewUnsignedMessage(
|
|
constants.UnitTestID,
|
|
ids.GenerateTestID(),
|
|
payload,
|
|
)
|
|
require.NoError(err)
|
|
require.Len(unsignedMsg.Bytes(), 42+len(payload))
|
|
|
|
msg, err := NewMessage(
|
|
unsignedMsg,
|
|
&BitSetSignature{
|
|
Signers: []byte{1, 2, 3},
|
|
Signature: [bls.SignatureLen]byte{4, 5, 6},
|
|
},
|
|
)
|
|
require.NoError(err)
|
|
|
|
msgBytes := msg.Bytes()
|
|
msg2, err := ParseMessage(msgBytes)
|
|
require.NoError(err)
|
|
require.Equal(msg, msg2)
|
|
}
|
|
|
|
func TestParseMessageJunk(t *testing.T) {
|
|
require := require.New(t)
|
|
|
|
bytes := []byte{0, 1, 2, 3, 4, 5, 6, 7}
|
|
_, err := ParseMessage(bytes)
|
|
require.ErrorIs(err, codec.ErrUnknownVersion)
|
|
}
|