a bunch of [32]byte conversions. still more needed.

This commit is contained in:
fiatjaf
2025-04-14 17:31:23 -03:00
parent 40535e6b19
commit b4268d649c
132 changed files with 857 additions and 879 deletions

View File

@@ -1,6 +1,7 @@
package nostr
import (
"encoding/hex"
"fmt"
"math/rand/v2"
"testing"
@@ -34,15 +35,18 @@ func TestEventParsingAndVerifying(t *testing.T) {
}
func TestEventSerialization(t *testing.T) {
sig := [64]byte{}
hex.Decode(sig[:], []byte("ed08d2dd5b0f7b6a3cdc74643d4adee3158ddede9cc848e8cd97630c097001acc2d052d2d3ec2b7ac4708b2314b797106d1b3c107322e61b5e5cc2116e099b79"))
events := []Event{
{
ID: "92570b321da503eac8014b23447301eb3d0bbdfbace0d11a4e4072e72bb7205d",
PubKey: "e9142f724955c5854de36324dab0434f97b15ec6b33464d56ebe491e3f559d1b",
ID: MustIDFromHex("92570b321da503eac8014b23447301eb3d0bbdfbace0d11a4e4072e72bb7205d"),
PubKey: MustPubKeyFromHex("e9142f724955c5854de36324dab0434f97b15ec6b33464d56ebe491e3f559d1b"),
Kind: KindEncryptedDirectMessage,
CreatedAt: Timestamp(1671028682),
Tags: Tags{Tag{"p", "f8340b2bde651576b75af61aa26c80e13c65029f00f7f64004eece679bf7059f"}},
Content: "you say yes, I say no",
Sig: "ed08d2dd5b0f7b6a3cdc74643d4adee3158ddede9cc848e8cd97630c097001acc2d052d2d3ec2b7ac4708b2314b797106d1b3c107322e61b5e5cc2116e099b79",
Sig: sig,
},
}
@@ -73,7 +77,7 @@ func TestEventSerialization(t *testing.T) {
}
}
func mustSignEvent(t *testing.T, privkey string, event *Event) {
func mustSignEvent(t *testing.T, privkey [32]byte, event *Event) {
t.Helper()
if err := event.Sign(privkey); err != nil {
t.Fatalf("event.Sign: %v", err)