nip60: Changes channel is a PublishUpdate hook now that must be set, to prevent unpublished updates -- and also now updates have more metadata so the client can display more info about them.

This commit is contained in:
fiatjaf
2025-01-30 10:32:23 -03:00
parent f0054af4d8
commit b86d5d52bb
7 changed files with 65 additions and 51 deletions

View File

@@ -35,6 +35,9 @@ func TestWalletTransfer(t *testing.T) {
if stash1 == nil {
t.Fatal("failed to load stash 1")
}
stash1.PublishUpdate = func(event nostr.Event, deleted, received, change *Token, isHistory bool) {
pool.PublishMany(ctx, testRelays, event)
}
// setup second wallet
sk2 := os.Getenv("NIP60_SECRET_KEY_2")
@@ -50,15 +53,14 @@ func TestWalletTransfer(t *testing.T) {
if stash2 == nil {
t.Fatal("failed to load stash 2")
}
stash2.PublishUpdate = func(event nostr.Event, deleted, received, change *Token, isHistory bool) {
pool.PublishMany(ctx, testRelays, event)
}
// handle events from both stashes
go func() {
for {
select {
case evt := <-stash1.Changes:
pool.PublishMany(ctx, testRelays, evt)
case evt := <-stash2.Changes:
pool.PublishMany(ctx, testRelays, evt)
case err := <-stash1.Processed:
if err != nil {
t.Errorf("stash1 processing error: %v", err)