test(daemon): match node names on the NAME column, not anywhere in the table #739

Merged
admin merged 1 commits from fix/node-name-in-peer-id into dev 2026-10-25 19:14:34 +00:00
Owner

Closes #738.

What failed

TestTrustInOneDirectionOnly failed on #734, which doesn't touch the daemon. The test checks strings.Contains(out, "rig") against the laptop's nodes table. The laptop's own random peer ID contained rig (…VqVrigez…), so the check fired even though the rig had no row.

Fix

  • New test helper listsNode(table, name) that only looks at the NAME column of each row.
  • Used for the two negative name checks that read nodes output:
    • reciprocal_test.go: "the rig is not working for the laptop".
    • cli_test.go: "the coordinator-only boss doesn't appear as a worker". boss is all base58 characters too, so it had the same flaw.

Names containing l or O (such as laptop) can't occur inside a base58 ID, so the other checks are safe and stay as they are.

Testing

  • Both tests pass locally (go test -run … -v).
  • gofmt and go vet are clean.
  • Test-only change: no production code and no docs affected.
Closes #738. ## What failed `TestTrustInOneDirectionOnly` failed on #734, which doesn't touch the daemon. The test checks `strings.Contains(out, "rig")` against the laptop's `nodes` table. The laptop's own random peer ID contained `rig` (`…VqV`**`rig`**`ez…`), so the check fired even though the rig had no row. ## Fix - New test helper `listsNode(table, name)` that only looks at the NAME column of each row. - Used for the two negative name checks that read `nodes` output: - `reciprocal_test.go`: "the rig is not working for the laptop". - `cli_test.go`: "the coordinator-only `boss` doesn't appear as a worker". `boss` is all base58 characters too, so it had the same flaw. Names containing `l` or `O` (such as `laptop`) can't occur inside a base58 ID, so the other checks are safe and stay as they are. ## Testing - Both tests pass locally (`go test -run … -v`). - `gofmt` and `go vet` are clean. - Test-only change: no production code and no docs affected.
rvnminers-A-and-N left a comment
Owner

listsNode is right: it compares only the first field of each row, so a header line or a peer ID can't match. Both call sites read correctly.

There's one more check in the same file with the same flaw, in TestNodesThatTrustEachOtherWorkForEachOther (around reciprocal_test.go:793, after the laptop withdraws its trust):

waitFor(t, func() bool {
	return !strings.Contains(workers(rig), "laptop") && !strings.Contains(workers(laptop), "rig")
})

workers is nodes --addr. If the laptop's random peer ID contains rig, the condition can never be true, and the test times out the same way #738 failed. laptop is safe because l isn't in base58, so only the rig half needs listsNode. The strings.Contains(out, "laptop") at :761 is also fine for the same reason.

The positive waits (waitForOutput(t, "rig", "nodes", ...) at :776, and "hand" in cli_test.go) can pass too early on a peer-ID match, but they don't fail. The later checks would catch a missing row, so I'd leave them as they are.

`listsNode` is right: it compares only the first field of each row, so a header line or a peer ID can't match. Both call sites read correctly. There's one more check in the same file with the same flaw, in `TestNodesThatTrustEachOtherWorkForEachOther` (around `reciprocal_test.go:793`, after the laptop withdraws its trust): ```go waitFor(t, func() bool { return !strings.Contains(workers(rig), "laptop") && !strings.Contains(workers(laptop), "rig") }) ``` `workers` is `nodes --addr`. If the laptop's random peer ID contains `rig`, the condition can never be true, and the test times out the same way #738 failed. `laptop` is safe because `l` isn't in base58, so only the `rig` half needs `listsNode`. The `strings.Contains(out, "laptop")` at :761 is also fine for the same reason. The positive waits (`waitForOutput(t, "rig", "nodes", ...)` at :776, and `"hand"` in `cli_test.go`) can pass too early on a peer-ID match, but they don't fail. The later checks would catch a missing row, so I'd leave them as they are.
excho0 left a comment
Author
Owner

Austin spotted one more vulnerable negative check in TestNodesThatTrustEachOtherWorkForEachOther, around reciprocal_test.go:793:

return !strings.Contains(workers(rig), "laptop") && !strings.Contains(workers(laptop), "rig")

The "rig" substring can also occur inside the laptop peer ID there, making waitFor time out. Could this PR replace that half with !listsNode(workers(laptop), "rig") as well? The laptop check is safe because l is not in base58. /cc @rvnminers-A-and-N

Austin spotted one more vulnerable negative check in `TestNodesThatTrustEachOtherWorkForEachOther`, around `reciprocal_test.go:793`: ```go return !strings.Contains(workers(rig), "laptop") && !strings.Contains(workers(laptop), "rig") ``` The `"rig"` substring can also occur inside the laptop peer ID there, making `waitFor` time out. Could this PR replace that half with `!listsNode(workers(laptop), "rig")` as well? The `laptop` check is safe because `l` is not in base58. /cc @rvnminers-A-and-N
Owner

Thanks for merging. The "rig" half at reciprocal_test.go:793 (TestNodesThatTrustEachOtherWorkForEachOther) is still a substring check on dev at 3123a9d:

return !strings.Contains(workers(rig), "laptop") && !strings.Contains(workers(laptop), "rig")

Want me to open a one-line follow-up switching it to !listsNode(workers(laptop), "rig")? Or are you already on it?

Thanks for merging. The `"rig"` half at `reciprocal_test.go:793` (`TestNodesThatTrustEachOtherWorkForEachOther`) is still a substring check on `dev` at 3123a9d: ```go return !strings.Contains(workers(rig), "laptop") && !strings.Contains(workers(laptop), "rig") ``` Want me to open a one-line follow-up switching it to `!listsNode(workers(laptop), "rig")`? Or are you already on it?
Author
Owner

Austin, I’ll take the one-line follow-up; no need for you to open it. I’ll reopen #738 with the remaining call site, make the focused test-only PR, and request your review. /cc @rvnminers-A-and-N

Austin, I’ll take the one-line follow-up; no need for you to open it. I’ll reopen #738 with the remaining call site, make the focused test-only PR, and request your review. /cc @rvnminers-A-and-N
Sign in to join this conversation.
No labels area:daemon bug testing
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Sisyphus/Sisyphus#739