Skip to content

Commit

Permalink
Add golden test.
Browse files Browse the repository at this point in the history
Checked with previous version, it is working fine.

Signed-off-by: Antonio Navarro Perez <[email protected]>
  • Loading branch information
ajnavarro committed Nov 20, 2023
1 parent 673bcdb commit 1ae6215
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tm2/pkg/crypto/ed25519/ed25519_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package ed25519_test

import (
"encoding/hex"
"testing"

"github.com/gnolang/gno/tm2/pkg/crypto"
"github.com/gnolang/gno/tm2/pkg/crypto/ed25519"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/gnolang/gno/tm2/pkg/crypto"
"github.com/gnolang/gno/tm2/pkg/crypto/ed25519"
)

func TestSignAndValidateEd25519(t *testing.T) {
Expand All @@ -28,3 +30,17 @@ func TestSignAndValidateEd25519(t *testing.T) {

assert.False(t, pubKey.VerifyBytes(msg, sig))
}

const privKeySecretGolden = "secret_golden"

Check failure on line 34 in tm2/pkg/crypto/ed25519/ed25519_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gofumpt`-ed (gofumpt)
const msgGolden = "msg_golden"
const signedGolden = "f9d4e6a665dfb6cd7e2fedf0d46a1725472e640a5e93d654ce4caa986e5defd23c8b3af76aa6e39c24c582f0ebee860f66254b29cf6d034ce461ae2773133703"

func TestSignAndVerifyGolden(t *testing.T) {
privKey := ed25519.GenPrivKeyFromSecret([]byte(privKeySecretGolden))
// pubKey := privKey.PubKey()
out, err := privKey.Sign([]byte(msgGolden))
require.NoError(t, err)

hexOut := hex.EncodeToString(out)
require.Equal(t, signedGolden, hexOut)
}

0 comments on commit 1ae6215

Please sign in to comment.