Let the config choose protocol 2 or 3, and fall back for one session only.
The default stays v2. A reflector that refuses that version and names the other gets one session of it, then the station announces the configured protocol again. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -49,7 +49,7 @@ func loginLog(t *testing.T, callsign, key string, tg int, id uint16, codecs []st
|
||||
_ = st.Run(ctx)
|
||||
}()
|
||||
refl.accept(t)
|
||||
declineTo2(t, refl)
|
||||
expectVersion(t, refl, 2, 0)
|
||||
challenge := make([]byte, 20)
|
||||
for i := range challenge {
|
||||
challenge[i] = byte(i + 1)
|
||||
@@ -98,6 +98,14 @@ func loginLog(t *testing.T, callsign, key string, tg int, id uint16, codecs []st
|
||||
return loggedIn{st: st, clock: clock, refl: refl, cancel: cancel, id: id, path: path}
|
||||
}
|
||||
|
||||
func expectVersion(t *testing.T, refl *reflector, major, minor uint16) {
|
||||
t.Helper()
|
||||
typ, body := refl.readFrame(t)
|
||||
if typ != 5 || !versionIs(body, major, minor) {
|
||||
t.Fatalf("version type %d body %v, want %d.%d", typ, body, major, minor)
|
||||
}
|
||||
}
|
||||
|
||||
func declineTo2(t *testing.T, refl *reflector) {
|
||||
t.Helper()
|
||||
typ, body := refl.readFrame(t)
|
||||
@@ -163,8 +171,8 @@ func TestDropRetriesUntilQuit(t *testing.T) {
|
||||
in.clock.Advance(2 * time.Second)
|
||||
in.refl.accept(t)
|
||||
typ, body := in.refl.readFrame(t)
|
||||
if typ != 5 || !versionIs(body, 3, 0) {
|
||||
t.Fatalf("retry protocol type %d body %v, want 3.0", typ, body)
|
||||
if typ != 5 || !versionIs(body, 2, 0) {
|
||||
t.Fatalf("retry protocol type %d body %v, want 2.0", typ, body)
|
||||
}
|
||||
in.cancel()
|
||||
in.clock.Advance(2 * time.Second)
|
||||
@@ -281,7 +289,7 @@ func TestMissingOpusStopsRetries(t *testing.T) {
|
||||
_ = st.Run(ctx)
|
||||
}()
|
||||
refl.accept(t)
|
||||
declineTo2(t, refl)
|
||||
expectVersion(t, refl, 2, 0)
|
||||
challenge := make([]byte, 20)
|
||||
refl.writeFrame(t, 10, appendBytes(nil, challenge))
|
||||
refl.readFrame(t)
|
||||
|
||||
Reference in New Issue
Block a user