mirror of
https://github.com/luxfi/proto.git
synced 2026-10-30 15:21:09 +00:00
Adds .hanzo/workflows/cicd.yml calling the canonical pipeline and drops the GitHub-hosted workflows it replaces. Lands here because this is where the repo is written — git.hanzo.ai is upstream and github.com is its push mirror, so the same change made on github.com never reaches the runner fleet.
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package payload
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/luxfi/ids"
|
|
"github.com/luxfi/zap"
|
|
)
|
|
|
|
var junkBytes = []byte{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}
|
|
|
|
func TestParseJunk(t *testing.T) {
|
|
require := require.New(t)
|
|
_, err := Parse(junkBytes)
|
|
require.ErrorIs(err, zap.ErrBufferTooSmall)
|
|
}
|
|
|
|
func TestParseWrongPayloadType(t *testing.T) {
|
|
require := require.New(t)
|
|
hashPayload, err := NewHash(ids.GenerateTestID())
|
|
require.NoError(err)
|
|
|
|
shortID := ids.GenerateTestShortID()
|
|
addressedPayload, err := NewAddressedCall(
|
|
shortID[:],
|
|
[]byte{1, 2, 3},
|
|
)
|
|
require.NoError(err)
|
|
|
|
_, err = ParseAddressedCall(hashPayload.Bytes())
|
|
require.ErrorIs(err, ErrWrongType)
|
|
|
|
_, err = ParseHash(addressedPayload.Bytes())
|
|
require.ErrorIs(err, ErrWrongType)
|
|
}
|
|
|
|
func TestParse(t *testing.T) {
|
|
require := require.New(t)
|
|
hashPayload, err := NewHash(ids.ID{4, 5, 6})
|
|
require.NoError(err)
|
|
|
|
parsedHashPayload, err := Parse(hashPayload.Bytes())
|
|
require.NoError(err)
|
|
require.Equal(hashPayload, parsedHashPayload)
|
|
|
|
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)
|
|
|
|
parsedAddressedPayload, err := Parse(addressedPayload.Bytes())
|
|
require.NoError(err)
|
|
require.Equal(addressedPayload, parsedAddressedPayload)
|
|
}
|