From afed04e3286281cdec7ea41cf381e565f744a664 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Sat, 9 Mar 2024 09:58:39 +0100 Subject: [PATCH] fix tests --- curves/bls12381/signature_test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/curves/bls12381/signature_test.go b/curves/bls12381/signature_test.go index 318adc9..ddfa229 100644 --- a/curves/bls12381/signature_test.go +++ b/curves/bls12381/signature_test.go @@ -89,7 +89,7 @@ func TestSignatureFromBytes(t *testing.T) { res, err := SignatureFromBytes(test.input) if test.err != nil { assert.NotEqual(t, nil, err, "No error returned") - assert.ErrorContains(t, test.err, err.Error(), "Unexpected error returned") + assert.ErrorContains(t, err, test.err.Error(), "Unexpected error returned") } else { assert.NoError(t, err) assert.Equal(t, 0, bytes.Compare(res.Marshal(), test.input)) @@ -143,7 +143,7 @@ func TestSignatureFromBytesNoValidation(t *testing.T) { res, err := SignatureFromBytesNoValidation(test.input) if test.err != nil { assert.NotEqual(t, nil, err, "No error returned") - assert.ErrorContains(t, test.err, err.Error(), "Unexpected error returned") + assert.ErrorContains(t, err, test.err.Error(), "Unexpected error returned") } else { assert.NoError(t, err) assert.Equal(t, 0, bytes.Compare(res.Marshal(), test.input)) @@ -152,6 +152,11 @@ func TestSignatureFromBytesNoValidation(t *testing.T) { } } +// TestCopy is a unit test function that tests the Copy method of the Signature struct. +// It generates a random private key, creates two signatures using the key, and verifies +// that the Copy method creates a deep copy of the original signature. It then modifies +// one of the signatures and verifies that the modified signature is not equal to the +// original signature. func TestCopy(t *testing.T) { priv, err := RandKey() require.NoError(t, err) @@ -162,8 +167,6 @@ func TestCopy(t *testing.T) { signatureB, ok := signatureA.Copy().(*Signature) require.Equal(t, true, ok) - assert.NotEqual(t, signatureA, signatureB) - assert.NotEqual(t, signatureA.s, signatureB.s) assert.Equal(t, signatureA, signatureB) signatureA.s.Sign(key.p, []byte("bar"), dst)