- LNURLcash: mint single notes directly when the mint rounds fees to whole sats, recover lost direct-note funding, melt to the callback named in the note's own withdraw info, and poll for settlement so redeems/reclaims finish without waiting on the webhook. Read-only lookups use a pooled client; every mutation stays on the no-keep-alive client. - Webhook: expire replay markers only for payments without an invoice event, so an event callback can never run twice. - Tickets: on restart, enforce tickets that ran out while the bot was down unless LNbits says the invoice was paid; drop stale ones without a ban. - Telegram: register translated /faucet and /tipjar command aliases. - i18n: load translations from one language list and log broken files. - Config example: one entry per mint; ignore local docs/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package webhook
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/LightningTipBot/LightningTipBot/internal/storage"
|
|
"github.com/tidwall/buntdb"
|
|
)
|
|
|
|
func TestMarkHandled(t *testing.T) {
|
|
w := &Server{buntdb: storage.NewBunt(":memory:")}
|
|
|
|
for _, c := range []struct {
|
|
hash string
|
|
hasEvent bool
|
|
expires bool
|
|
}{
|
|
{"aa", true, false},
|
|
{"bb", false, true},
|
|
} {
|
|
first, err := w.markHandled(c.hash, c.hasEvent)
|
|
if err != nil || !first {
|
|
t.Fatalf("%s: first mark: %v %v", c.hash, first, err)
|
|
}
|
|
first, err = w.markHandled(c.hash, c.hasEvent)
|
|
if err != nil || first {
|
|
t.Fatalf("%s: second mark must be a repeat: %v %v", c.hash, first, err)
|
|
}
|
|
err = w.buntdb.View(func(tx *buntdb.Tx) error {
|
|
ttl, err := tx.TTL("webhook:" + c.hash)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// buntdb reports -1 for a key without expiry
|
|
if expires := ttl >= 0; expires != c.expires {
|
|
t.Errorf("%s: expires %t, want %t (ttl %s)", c.hash, expires, c.expires, ttl)
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
}
|