Implement in-process multi-dataset sync isolation across core, network, persistence, and tests
All checks were successful
NuGet Package Publish / nuget (push) Successful in 1m14s
All checks were successful
NuGet Package Publish / nuget (push) Successful in 1m14s
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Google.Protobuf;
|
||||
using ZB.MOM.WW.CBDDC.Core;
|
||||
using ZB.MOM.WW.CBDDC.Network.Proto;
|
||||
using ZB.MOM.WW.CBDDC.Network.Protocol;
|
||||
using ZB.MOM.WW.CBDDC.Network.Security;
|
||||
@@ -145,6 +147,44 @@ public class ProtocolTests
|
||||
decoded.NodeId.ShouldBe("fragmented");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that dataset-aware protocol fields are serialized and parsed correctly.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DatasetAwareMessages_ShouldRoundTripDatasetFields()
|
||||
{
|
||||
var request = new PullChangesRequest
|
||||
{
|
||||
SinceWall = 10,
|
||||
SinceLogic = 1,
|
||||
SinceNode = "node-a",
|
||||
DatasetId = "logs"
|
||||
};
|
||||
|
||||
byte[] payload = request.ToByteArray();
|
||||
var decoded = PullChangesRequest.Parser.ParseFrom(payload);
|
||||
|
||||
decoded.DatasetId.ShouldBe("logs");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that legacy messages with no dataset id default to the primary dataset.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void DatasetAwareMessages_WhenMissingDataset_ShouldDefaultToPrimary()
|
||||
{
|
||||
var legacy = new HandshakeRequest
|
||||
{
|
||||
NodeId = "node-legacy",
|
||||
AuthToken = "token"
|
||||
};
|
||||
|
||||
byte[] payload = legacy.ToByteArray();
|
||||
var decoded = HandshakeRequest.Parser.ParseFrom(payload);
|
||||
|
||||
DatasetId.Normalize(decoded.DatasetId).ShouldBe(DatasetId.Primary);
|
||||
}
|
||||
|
||||
// Helper Stream for fragmentation test
|
||||
private class FragmentedMemoryStream : MemoryStream
|
||||
{
|
||||
@@ -169,4 +209,4 @@ public class ProtocolTests
|
||||
return await base.ReadAsync(buffer, offset, toRead, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user