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
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package payload
|
|
|
|
import (
|
|
"encoding/base64"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/luxfi/codec"
|
|
"github.com/luxfi/ids"
|
|
)
|
|
|
|
func TestAddressedCall(t *testing.T) {
|
|
require := require.New(t)
|
|
shortID := ids.GenerateTestShortID()
|
|
|
|
addressedPayload, err := NewAddressedCall(
|
|
shortID[:],
|
|
[]byte{1, 2, 3},
|
|
)
|
|
require.NoError(err)
|
|
|
|
addressedPayloadBytes := addressedPayload.Bytes()
|
|
parsedAddressedPayload, err := ParseAddressedCall(addressedPayloadBytes)
|
|
require.NoError(err)
|
|
require.Equal(addressedPayload, parsedAddressedPayload)
|
|
}
|
|
|
|
func TestParseAddressedCallJunk(t *testing.T) {
|
|
_, err := ParseAddressedCall(junkBytes)
|
|
require.ErrorIs(t, err, codec.ErrUnknownVersion)
|
|
}
|
|
|
|
func TestAddressedCallBytes(t *testing.T) {
|
|
require := require.New(t)
|
|
base64Payload := "AAAAAAABAAAAEAECAwAAAAAAAAAAAAAAAAAAAAADCgsM"
|
|
addressedPayload, err := NewAddressedCall(
|
|
[]byte{1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
|
[]byte{10, 11, 12},
|
|
)
|
|
require.NoError(err)
|
|
require.Equal(base64Payload, base64.StdEncoding.EncodeToString(addressedPayload.Bytes()))
|
|
}
|