ceremonyclient/nekryptology/pkg/dkg/gennaro/participant_test.go

49 lines
1.3 KiB
Go
Raw Normal View History

2023-07-05 05:32:28 +00:00
//
// Copyright Coinbase, Inc. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
package gennaro
import (
"math/big"
"testing"
"github.com/btcsuite/btcd/btcec"
"github.com/stretchr/testify/require"
"source.quilibrium.com/quilibrium/monorepo/nekryptology/internal"
"source.quilibrium.com/quilibrium/monorepo/nekryptology/pkg/core/curves"
)
var testGenerator, _ = curves.NewScalarBaseMult(btcec.S256(), big.NewInt(3333))
func TestNewParticipantWorks(t *testing.T) {
p, err := NewParticipant(1, 2, testGenerator, curves.NewK256Scalar(), 2)
require.NoError(t, err)
require.NotNil(t, p)
require.Equal(t, p.id, uint32(1))
require.Equal(t, p.round, 1)
require.Equal(t, p.curve, btcec.S256())
require.NotNil(t, p.pedersen)
require.NotNil(t, p.feldman)
require.Nil(t, p.pedersenResult)
require.NotNil(t, p.otherParticipantShares)
require.NotNil(t, p.scalar)
_, ok := p.otherParticipantShares[2]
require.True(t, ok)
}
func TestNewParticipantBadInputs(t *testing.T) {
_, err := NewParticipant(0, 0, nil, nil)
require.Error(t, err)
require.Equal(t, err, internal.ErrNilArguments)
_, err = NewParticipant(1, 2, nil, nil)
require.Error(t, err)
require.Equal(t, err, internal.ErrNilArguments)
_, err = NewParticipant(1, 2, testGenerator, nil)
require.Error(t, err)
require.Equal(t, err, internal.ErrNilArguments)
}