From 3c98c4c4fd15b701ecd19603c53bcc87572c8e99 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 28 Feb 2026 06:35:12 -0500 Subject: [PATCH] feat(batch1): implement proto varint encoder parity --- .../Internal/ProtoWire.cs | 6 +++ .../Internal/ProtoWireTests.cs | 37 ++++++++++++++++++ porting.db | Bin 6352896 -> 6352896 bytes reports/current.md | 8 ++-- reports/report_c1ae46f.md | 37 ++++++++++++++++++ 5 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 reports/report_c1ae46f.md diff --git a/dotnet/src/ZB.MOM.NatsNet.Server/Internal/ProtoWire.cs b/dotnet/src/ZB.MOM.NatsNet.Server/Internal/ProtoWire.cs index 035e0c4..26ca11e 100644 --- a/dotnet/src/ZB.MOM.NatsNet.Server/Internal/ProtoWire.cs +++ b/dotnet/src/ZB.MOM.NatsNet.Server/Internal/ProtoWire.cs @@ -311,4 +311,10 @@ public static class ProtoWire (byte)((v >> 56) & 0x7F | 0x80), 1]; } + + /// + /// Compatibility mapped entrypoint for PortTracker: protoEncodeVarint. + /// + public static byte[] ProtoEncodeVarint(ulong v) + => EncodeVarint(v); } diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Internal/ProtoWireTests.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Internal/ProtoWireTests.cs index 45b5048..2e1af2a 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Internal/ProtoWireTests.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Internal/ProtoWireTests.cs @@ -74,4 +74,41 @@ public class ProtoWireTests typ.ShouldBe(2); size.ShouldBe(5); } + + [Theory] + [InlineData(1UL << 7, 2)] + [InlineData(1UL << 14, 3)] + [InlineData(1UL << 21, 4)] + [InlineData(1UL << 28, 5)] + [InlineData(1UL << 35, 6)] + [InlineData(1UL << 42, 7)] + [InlineData(1UL << 49, 8)] + [InlineData(1UL << 56, 9)] + [InlineData(1UL << 63, 10)] + public void ProtoEncodeVarint_BoundaryValues_ReturnsExpectedLength(ulong value, int expectedLength) + { + var encoded = ProtoWire.ProtoEncodeVarint(value); + + encoded.Length.ShouldBe(expectedLength); + } + + [Theory] + [InlineData(1UL << 7)] + [InlineData(1UL << 14)] + [InlineData(1UL << 21)] + [InlineData(1UL << 28)] + [InlineData(1UL << 35)] + [InlineData(1UL << 42)] + [InlineData(1UL << 49)] + [InlineData(1UL << 56)] + [InlineData(1UL << 63)] + public void ProtoEncodeVarint_BoundaryValues_RoundTripThroughProtoScanVarint(ulong value) + { + var encoded = ProtoWire.ProtoEncodeVarint(value); + var (decoded, size, err) = ProtoWire.ProtoScanVarint(encoded); + + err.ShouldBeNull(); + size.ShouldBe(encoded.Length); + decoded.ShouldBe(value); + } } diff --git a/porting.db b/porting.db index 3e27d6e2160bbfddd1957fac1a6b2c3304567edf..09cdad193c80368a125ab4a00b3830b01f96618f 100644 GIT binary patch delta 642 zcmYMrJ4_RC90%~;wLDq{4zVCgYpGgZmbQ15$03R+J^%#;LBT2oYQj=XAA^Gl4at`Q zN0WbIjEadXeiyxsIGYgTq=SPo#KED7iKBzRxHx>q&)T@jUmRmAn@&g;0|uQ^{6`sZr*4_B=U{xO=IU0ZL~JT8}O+W9%4hjTu!+pp&f z#YJCaqj6goZs8FXqEb|eYT*?=u}|z5HKNvO+^#F9J-_u@ml~QhLQcD3jB2`GR=IlP zk@{6{6tu^xJY_sl0A4R3=X>cs)kAPx$@XcSH2kZ2Z%#SzgW0*<#K`1F}tG=l;4 z{!Oq)y?7O@^d#+M91Ma-!4TLAhQVXtaqt8f0o%ZKumkJ_yTFrR6zm3Lpu_}df){4uH-V^OL^N$s85}#m4KDBt=>{_Gy1Ph_)D$-TSS$< z=pAaUD^;UDMp9vOB)hb_oS8}IR$&w|O6%vGEry!%-rU=+$XYVj}di zi_nWaw`OOFqpK{-=CFfE=IG%2Nj{suwyaHN4&vfy>o9H(<05t{BIfLmNREoXIwv9b z#g$1XWKx*R26^GOZe1Q7x>Kd*JShXhF0_Ku{Ogp_ua0Ni<*cr)uQ-vE|5(zZ%^W^p zF5S$d!+aL7kRIbdet5lX|Cb(@?wwF!6H{tL=rym}5O?~Gr}kH6 z9OnclImKztaF*{l$9cZz2QK`uGatWLKAF|I;l)}be#;%1%0?Ht#7`z0{oHqc4-M+M A?f?J) diff --git a/reports/current.md b/reports/current.md index 13ed1a8..39c1120 100644 --- a/reports/current.md +++ b/reports/current.md @@ -1,6 +1,6 @@ # NATS .NET Porting Status Report -Generated: 2026-02-28 11:33:10 UTC +Generated: 2026-02-28 11:35:12 UTC ## Modules (12 total) @@ -12,10 +12,10 @@ Generated: 2026-02-28 11:33:10 UTC | Status | Count | |--------|-------| -| deferred | 2368 | +| deferred | 2367 | | n_a | 24 | | stub | 1 | -| verified | 1280 | +| verified | 1281 | ## Unit Tests (3257 total) @@ -34,4 +34,4 @@ Generated: 2026-02-28 11:33:10 UTC ## Overall Progress -**2482/6942 items complete (35.8%)** +**2483/6942 items complete (35.8%)** diff --git a/reports/report_c1ae46f.md b/reports/report_c1ae46f.md new file mode 100644 index 0000000..39c1120 --- /dev/null +++ b/reports/report_c1ae46f.md @@ -0,0 +1,37 @@ +# NATS .NET Porting Status Report + +Generated: 2026-02-28 11:35:12 UTC + +## Modules (12 total) + +| Status | Count | +|--------|-------| +| verified | 12 | + +## Features (3673 total) + +| Status | Count | +|--------|-------| +| deferred | 2367 | +| n_a | 24 | +| stub | 1 | +| verified | 1281 | + +## Unit Tests (3257 total) + +| Status | Count | +|--------|-------| +| deferred | 2091 | +| n_a | 187 | +| verified | 979 | + +## Library Mappings (36 total) + +| Status | Count | +|--------|-------| +| mapped | 36 | + + +## Overall Progress + +**2483/6942 items complete (35.8%)**