From 7cabcd8dc32244b59a59182258c9d43cdd2c51c6 Mon Sep 17 00:00:00 2001 From: Tomas Bezouska Date: Thu, 31 Oct 2024 23:20:47 +0100 Subject: [PATCH] Fix protocol version fallback --- src/Negentropy/Negentropy.cs | 2 +- test/Negentropy.Tests/ReconcileTests.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Negentropy/Negentropy.cs b/src/Negentropy/Negentropy.cs index 476bc17..d25181a 100644 --- a/src/Negentropy/Negentropy.cs +++ b/src/Negentropy/Negentropy.cs @@ -66,7 +66,7 @@ public NegentropyReconciliation Reconcile(string query) if (version != PROTOCOL_VERSION) { if (this.isInitiator) throw new InvalidOperationException("unsupported negentropy protocol version requested: " + (version - 0x60)); - else writer.ToHexString(); + else return new NegentropyReconciliation(writer.ToHexString(), [], []); } var prevBoundOut = Bound.Min; diff --git a/test/Negentropy.Tests/ReconcileTests.cs b/test/Negentropy.Tests/ReconcileTests.cs index 90bcec7..5f8432e 100644 --- a/test/Negentropy.Tests/ReconcileTests.cs +++ b/test/Negentropy.Tests/ReconcileTests.cs @@ -223,6 +223,16 @@ public void LoadFromFileFrameSizeLimit() //result = ne1.Reconcile(result.Query); //result.Query.Should().Be(expectations[4]); + + } + + [Fact] + public void VersionFallbackTest() + { + var ne = new NegentropyBuilder(new NegentropyOptions()).Build(); + var result = ne.Reconcile("62aabbccddeeff"); + + result.Query.Should().Be("61"); } } }