detached 048fbd6

test(registry): check bind body encoding and version-0 globals

commit
048fbd6c132716e1d7a2d96656905aa797cfd674
author
brice · · 2026-10-01 05:55 UTC
parent
328be2b
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +22 -4
M registry_test.go +22 -4
@@ -3,6 +3,7 @@
33 package wlturbo
44
55 import (
6+ "bytes"
67 "encoding/binary"
78 "errors"
89 "io"
@@ -82,6 +83,19 @@ func TestBindNegotiated(t *testing.T) {
8283 t.Fatalf("supported zero: %d %v", v, err)
8384 }
8485
86+ // A global announced at version 0 is unusable.
87+ sendMessageWithFDs(t, peer, globalEvent(reg.ID(), 29, iface, 0), nil)
88+ if err := d.Dispatch(); err != nil {
89+ t.Fatal(err)
90+ }
91+ if v, err := reg.BindNegotiated(iface, 6, &BaseProxy{}); v != 0 || !errors.Is(err, ErrGlobalNotFound) {
92+ t.Fatalf("announced version 0: %d %v", v, err)
93+ }
94+ sendMessageWithFDs(t, peer, message(reg.ID(), 1, u32Body(29)), nil)
95+ if err := d.Dispatch(); err != nil {
96+ t.Fatal(err)
97+ }
98+
8599 for i, announced := range []uint32{2, 9} {
86100 name := uint32(30 + i)
87101 sendMessageWithFDs(t, peer, globalEvent(reg.ID(), name, iface, announced), nil)
@@ -101,11 +115,15 @@ func TestBindNegotiated(t *testing.T) {
101115 t.Fatalf("announced=%d negotiated=%d proxy version=%d, want %d", announced, negotiated, proxy.Version(), want)
102116 }
103117 obj, op, body := readRequest(t, peer)
104- // bind: name, string interface, version, new_id.
105- if obj != reg.ID() || op != 0 ||
118+ // bind: name, string (length incl. NUL, NUL, padding), version, new_id.
119+ padded := (len(iface) + 1 + 3) &^ 3
120+ if obj != reg.ID() || op != 0 || len(body) != 4+4+padded+4+4 ||
106121 binary.LittleEndian.Uint32(body) != name ||
107- binary.LittleEndian.Uint32(body[len(body)-8:]) != want ||
108- binary.LittleEndian.Uint32(body[len(body)-4:]) != proxy.ID() {
122+ binary.LittleEndian.Uint32(body[4:]) != uint32(len(iface)+1) ||
123+ string(body[8:8+len(iface)]) != iface ||
124+ !bytes.Equal(body[8+len(iface):8+padded], make([]byte, padded-len(iface))) ||
125+ binary.LittleEndian.Uint32(body[8+padded:]) != want ||
126+ binary.LittleEndian.Uint32(body[8+padded+4:]) != proxy.ID() {
109127 t.Fatalf("bind object=%d opcode=%d body=%x", obj, op, body)
110128 }
111129 // Remove the global so the next iteration is the only match.
@@ -3,6 +3,7 @@
3 package wlturbo3 package wlturbo
4 4
5 import (5 import (
6+ "bytes"
6 "encoding/binary"7 "encoding/binary"
7 "errors"8 "errors"
8 "io"9 "io"
@@ -82,6 +83,19 @@ func TestBindNegotiated(t *testing.T) {
82 t.Fatalf("supported zero: %d %v", v, err)83 t.Fatalf("supported zero: %d %v", v, err)
83 }84 }
84 85
86+ // A global announced at version 0 is unusable.
87+ sendMessageWithFDs(t, peer, globalEvent(reg.ID(), 29, iface, 0), nil)
88+ if err := d.Dispatch(); err != nil {
89+ t.Fatal(err)
90+ }
91+ if v, err := reg.BindNegotiated(iface, 6, &BaseProxy{}); v != 0 || !errors.Is(err, ErrGlobalNotFound) {
92+ t.Fatalf("announced version 0: %d %v", v, err)
93+ }
94+ sendMessageWithFDs(t, peer, message(reg.ID(), 1, u32Body(29)), nil)
95+ if err := d.Dispatch(); err != nil {
96+ t.Fatal(err)
97+ }
98+
85 for i, announced := range []uint32{2, 9} {99 for i, announced := range []uint32{2, 9} {
86 name := uint32(30 + i)100 name := uint32(30 + i)
87 sendMessageWithFDs(t, peer, globalEvent(reg.ID(), name, iface, announced), nil)101 sendMessageWithFDs(t, peer, globalEvent(reg.ID(), name, iface, announced), nil)
@@ -101,11 +115,15 @@ func TestBindNegotiated(t *testing.T) {
101 t.Fatalf("announced=%d negotiated=%d proxy version=%d, want %d", announced, negotiated, proxy.Version(), want)115 t.Fatalf("announced=%d negotiated=%d proxy version=%d, want %d", announced, negotiated, proxy.Version(), want)
102 }116 }
103 obj, op, body := readRequest(t, peer)117 obj, op, body := readRequest(t, peer)
104- // bind: name, string interface, version, new_id.118+ // bind: name, string (length incl. NUL, NUL, padding), version, new_id.
105- if obj != reg.ID() || op != 0 ||119+ padded := (len(iface) + 1 + 3) &^ 3
120+ if obj != reg.ID() || op != 0 || len(body) != 4+4+padded+4+4 ||
106 binary.LittleEndian.Uint32(body) != name ||121 binary.LittleEndian.Uint32(body) != name ||
107- binary.LittleEndian.Uint32(body[len(body)-8:]) != want ||122+ binary.LittleEndian.Uint32(body[4:]) != uint32(len(iface)+1) ||
108- binary.LittleEndian.Uint32(body[len(body)-4:]) != proxy.ID() {123+ string(body[8:8+len(iface)]) != iface ||
124+ !bytes.Equal(body[8+len(iface):8+padded], make([]byte, padded-len(iface))) ||
125+ binary.LittleEndian.Uint32(body[8+padded:]) != want ||
126+ binary.LittleEndian.Uint32(body[8+padded+4:]) != proxy.ID() {
109 t.Fatalf("bind object=%d opcode=%d body=%x", obj, op, body)127 t.Fatalf("bind object=%d opcode=%d body=%x", obj, op, body)
110 }128 }
111 // Remove the global so the next iteration is the only match.129 // Remove the global so the next iteration is the only match.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 8

↑↓ moveenter openesc close