From 34e7366d7c320491acf6aaebc573e6aac3a59cea Mon Sep 17 00:00:00 2001 From: efiten Date: Fri, 10 Apr 2026 02:36:34 +0200 Subject: [PATCH] test: add RouteTransportDirect zero-hop cases to ingestor decoder tests (#684) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Closes the symmetry gap flagged as a nit in PR #653 review: > The ingestor decoder tests omit `RouteTransportDirect` zero-hop tests — only the server decoder has those. Since the logic is identical, this is not a blocker, but adding them would make the test suites symmetric. - Adds `TestZeroHopTransportDirectHashSize` — `pathByte=0x00`, expects `HashSize=0` - Adds `TestZeroHopTransportDirectHashSizeWithNonZeroUpperBits` — `pathByte=0xC0` (hash_size bits set, hash_count=0), expects `HashSize=0` Both mirror the equivalent tests already present in `cmd/server/decoder_test.go`. ## Test plan - [ ] `cd cmd/ingestor && go test -run TestZeroHopTransportDirect -v` → both new tests pass - [ ] `cd cmd/ingestor && go test ./...` → no regressions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 4.6 --- cmd/ingestor/decoder_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cmd/ingestor/decoder_test.go b/cmd/ingestor/decoder_test.go index 22697525..bd2929ed 100644 --- a/cmd/ingestor/decoder_test.go +++ b/cmd/ingestor/decoder_test.go @@ -1602,3 +1602,29 @@ func TestDirectNonZeroHopKeepsHashSize(t *testing.T) { t.Errorf("DIRECT with 1 hop: want HashSize=1, got %d", pkt.Path.HashSize) } } + +func TestZeroHopTransportDirectHashSize(t *testing.T) { + // TRANSPORT_DIRECT (RouteType=3) + REQ (PayloadType=0) → header byte = 0x03 + // 4 bytes transport codes + pathByte=0x00 → hash_count=0 → should get HashSize=0 + hex := "03" + "11223344" + "00" + repeatHex("AA", 20) + pkt, err := DecodePacket(hex, nil) + if err != nil { + t.Fatalf("DecodePacket failed: %v", err) + } + if pkt.Path.HashSize != 0 { + t.Errorf("TRANSPORT_DIRECT zero-hop: want HashSize=0, got %d", pkt.Path.HashSize) + } +} + +func TestZeroHopTransportDirectHashSizeWithNonZeroUpperBits(t *testing.T) { + // TRANSPORT_DIRECT (RouteType=3) + REQ (PayloadType=0) → header byte = 0x03 + // 4 bytes transport codes + pathByte=0xC0 → hash_count=0, hash_size bits=11 → should still get HashSize=0 + hex := "03" + "11223344" + "C0" + repeatHex("AA", 20) + pkt, err := DecodePacket(hex, nil) + if err != nil { + t.Fatalf("DecodePacket failed: %v", err) + } + if pkt.Path.HashSize != 0 { + t.Errorf("TRANSPORT_DIRECT zero-hop with hash_size bits set: want HashSize=0, got %d", pkt.Path.HashSize) + } +}