package relay import ( "fmt" "testing" "git.smesh.lol/torly/pkg/store" ) // TestCheckpointUnderTraffic drives more saves than the checkpoint threshold so // the database domain's checkpoint branch runs while clients are publishing, then // asks for everything back. The point is that moving the checkpoint out of the // save path did not lose or duplicate events. func TestCheckpointUnderTraffic(t *testing.T) { tr := startTestRelay(t, false) pub := dialWS(t, tr.addr) // One past the store's checkpoint threshold. const total = store.CheckpointEvery + 4 for i := 0; i < total; i++ { publish(t, pub, testEvent(t, byte(i%200)+1, 1, nil, fmt.Sprintf("note %d", i))) } if n, _ := countFilter(t, tr.addr, `{"kinds":[1]}`); n != total { t.Fatalf("stored %d events, want %d", n, total) } }