loop/staticaddr/deposit/outpoint_test.go
Slyghtning ee5d84b323
staticaddr/deposit: reject duplicate outpoints
Reject duplicate static-address deposit outpoints before creating
withdrawal, loop-in, or channel-open requests.

Use the shared outpoint duplicate helper so each flow reports the
same input validation failure.
2026-07-08 09:00:26 +02:00

40 lines
786 B
Go

package deposit
import (
"testing"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/wire"
"github.com/stretchr/testify/require"
)
func TestCheckDuplicates(t *testing.T) {
duplicate := wire.OutPoint{
Hash: chainhash.Hash{1},
Index: 2,
}
outpoints := []wire.OutPoint{{
Hash: chainhash.Hash{3},
Index: 4,
}, duplicate, {
Hash: chainhash.Hash{5},
Index: 6,
}, duplicate}
err := CheckDuplicates(outpoints)
require.ErrorContains(t, err, "duplicate outpoint")
require.ErrorContains(t, err, duplicate.String())
}
func TestCheckDuplicatesNoDuplicate(t *testing.T) {
outpoints := []wire.OutPoint{{
Hash: chainhash.Hash{1},
Index: 2,
}, {
Hash: chainhash.Hash{3},
Index: 4,
}}
require.NoError(t, CheckDuplicates(outpoints))
}