Files
zeekay 8f7179ae0d refactor: move fx packages to root
Drop redundant fx/ directory since packages already have fx suffix:
- github.com/luxfi/utxo/fx/secp256k1fx → github.com/luxfi/utxo/secp256k1fx
- github.com/luxfi/utxo/fx/nftfx → github.com/luxfi/utxo/nftfx
- github.com/luxfi/utxo/fx/propertyfx → github.com/luxfi/utxo/propertyfx

BREAKING CHANGE: Import paths changed
2026-01-10 12:54:02 -08:00

75 lines
1.5 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"
)
func TestInputVerifyNil(t *testing.T) {
tests := []struct {
name string
in *Input
expectedErr error
}{
{
name: "nil input",
in: nil,
expectedErr: ErrNilInput,
},
{
name: "not sorted",
in: &Input{SigIndices: []uint32{2, 1}},
expectedErr: ErrInputIndicesNotSortedUnique,
},
{
name: "not unique",
in: &Input{SigIndices: []uint32{2, 2}},
expectedErr: ErrInputIndicesNotSortedUnique,
},
{
name: "passes verification",
in: &Input{SigIndices: []uint32{1, 2}},
expectedErr: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.in.Verify()
require.ErrorIs(t, err, tt.expectedErr)
})
}
}
func TestInputCost(t *testing.T) {
tests := []struct {
name string
in *Input
expectedCost uint64
}{
{
name: "2 sigs",
in: &Input{SigIndices: []uint32{1, 2}},
expectedCost: 2 * CostPerSignature,
},
{
name: "3 sigs",
in: &Input{SigIndices: []uint32{1, 2, 3}},
expectedCost: 3 * CostPerSignature,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require := require.New(t)
cost, err := tt.in.Cost()
require.NoError(err)
require.Equal(tt.expectedCost, cost)
})
}
}