mirror of
https://github.com/luxfi/utxo.git
synced 2026-10-30 15:13:57 +00:00
Completes the second cut of FINAL_RIP.md. The first cut (a0aab0a) dropped
the codec.Registry field from each fx's VM interface and the public API
codec.Manager params. This cut removes the remaining test-side residue:
- Strip `linearcodec.NewDefault()` Codec field literals from every TestVM
(the field no longer exists on TestVM).
- Drop the obsolete `TestCredentialSerialize`, `TestTransferInputSerialize`,
and `TestOutputSerialize` tests in secp256k1fx — they asserted the
legacy linearcodec wire-byte format. ZAP-native round-trips are covered
in wire/wire_test.go and the per-fx wire_test.go files.
- `go mod edit -droprequire github.com/luxfi/codec` + tidy — codec is now
indirect-only (transitively required via github.com/luxfi/vm for the
verify.State interface).
Build + test clean across all 11 packages. ZAP-native at the activation
boundary 2025-12-25T16:20:00-08:00.
88 lines
1.8 KiB
Go
88 lines
1.8 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package secp256k1fx
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/luxfi/vm/components/verify"
|
|
)
|
|
|
|
func TestTransferInputAmount(t *testing.T) {
|
|
require := require.New(t)
|
|
in := TransferInput{
|
|
Amt: 1,
|
|
Input: Input{
|
|
SigIndices: []uint32{0, 1},
|
|
},
|
|
}
|
|
require.Equal(uint64(1), in.Amount())
|
|
}
|
|
|
|
func TestTransferInputVerify(t *testing.T) {
|
|
require := require.New(t)
|
|
in := TransferInput{
|
|
Amt: 1,
|
|
Input: Input{
|
|
SigIndices: []uint32{0, 1},
|
|
},
|
|
}
|
|
require.NoError(in.Verify())
|
|
}
|
|
|
|
func TestTransferInputVerifyNil(t *testing.T) {
|
|
require := require.New(t)
|
|
in := (*TransferInput)(nil)
|
|
err := in.Verify()
|
|
require.ErrorIs(err, ErrNilInput)
|
|
}
|
|
|
|
func TestTransferInputVerifyNoValue(t *testing.T) {
|
|
require := require.New(t)
|
|
in := TransferInput{
|
|
Amt: 0,
|
|
Input: Input{
|
|
SigIndices: []uint32{0, 1},
|
|
},
|
|
}
|
|
err := in.Verify()
|
|
require.ErrorIs(err, ErrNoValueInput)
|
|
}
|
|
|
|
func TestTransferInputVerifyDuplicated(t *testing.T) {
|
|
require := require.New(t)
|
|
in := TransferInput{
|
|
Amt: 1,
|
|
Input: Input{
|
|
SigIndices: []uint32{0, 0},
|
|
},
|
|
}
|
|
err := in.Verify()
|
|
require.ErrorIs(err, ErrInputIndicesNotSortedUnique)
|
|
}
|
|
|
|
func TestTransferInputVerifyUnsorted(t *testing.T) {
|
|
require := require.New(t)
|
|
in := TransferInput{
|
|
Amt: 1,
|
|
Input: Input{
|
|
SigIndices: []uint32{1, 0},
|
|
},
|
|
}
|
|
err := in.Verify()
|
|
require.ErrorIs(err, ErrInputIndicesNotSortedUnique)
|
|
}
|
|
|
|
// Legacy linearcodec wire-format test deleted with the codec rip.
|
|
// ZAP-native wire round-trip is covered in wire_test.go.
|
|
|
|
func TestTransferInputNotState(t *testing.T) {
|
|
require := require.New(t)
|
|
intf := interface{}(&TransferInput{})
|
|
_, ok := intf.(verify.State)
|
|
require.False(ok)
|
|
}
|