libsecp256k1: use a static global context and add verification tests.

This commit is contained in:
fiatjaf
2024-05-29 15:40:57 -03:00
parent 427bfc7a4b
commit 31e0645afe
4 changed files with 34 additions and 25 deletions

View File

@@ -0,0 +1,20 @@
package libsecp256k1
import (
"encoding/json"
"testing"
"github.com/nbd-wtf/go-nostr"
"github.com/nbd-wtf/go-nostr/test_common"
"github.com/stretchr/testify/assert"
)
func TestEventVerification(t *testing.T) {
for _, jevt := range test_common.NormalEvents {
evt := &nostr.Event{}
json.Unmarshal([]byte(jevt), evt)
ok, _ := CheckSignature(evt)
shouldBe, _ := evt.CheckSignature()
assert.Equal(t, ok, shouldBe, "%s signature must be %s", jevt, shouldBe)
}
}