|
|
|
internal/records/sign_test.go raw
| 1 | package records | | 2 | | | 3 | import ( | | 4 | "context" | | 5 | "strings" | | 6 | "testing" | | 7 | "time" | | 8 | | | 9 | "github.com/FelineStateMachine/tinyrelay/internal/event" | | 10 | ) | | 11 | | | 12 | func TestProtocolSigningDoesNotWaitForProjectionLockOrAdvanceClock(t *testing.T) { | | 13 | s := &Service{secret: strings.Repeat("0" , 63) + "1" } | | 14 | s.mu.Lock() | | 15 | defer s.mu.Unlock() | | 16 | ctx, cancel := context.WithTimeout(context.Background(), time.Second) | | 17 | defer cancel() | | 18 | result := make(chan error, 1) | | 19 | go func() { | | 20 | for range 80 { | | 21 | proof, err := s.SignNIP98(ctx, "GET" , "https://relay.test/repo" , "" , 1234567890) | | 22 | if err != nil { | | 23 | result <- err | | 24 | return | | 25 | } | | 26 | if proof.CreatedAt != 1234567890 { | | 27 | result <- context.DeadlineExceeded | | 28 | return | | 29 | } | | 30 | if err := event.Validate(proof); err != nil { | | 31 | result <- err | | 32 | return | | 33 | } | | 34 | } | | 35 | result <- nil | | 36 | }() | | 37 | select { | | 38 | case err := <-result: | | 39 | if err != nil { | | 40 | t.Fatal(err) | | 41 | } | | 42 | case <-ctx.Done(): | | 43 | t.Fatal("protocol signing waited for projection lock" ) | | 44 | } | | 45 | } |
|
|
About| owner | c01503e8035f |
|---|
| visibility | public |
|---|
| head | d730679639bf |
|---|
Maintainers- c01503e8035f owner
- ba1b5beed5b5 agent hermes
Clonehttps://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git
|