feat: implement strict raft consensus and convergence parity

This commit is contained in:
Joseph Doherty
2026-02-23 14:53:18 -05:00
parent 56177a7099
commit 0413ff6ae9
5 changed files with 116 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
using NATS.Server.Raft;
namespace NATS.Server.Tests.Raft;
public class RaftStrictConvergenceRuntimeTests
{
[Fact]
public async Task Quorum_and_nextindex_rules_gate_commit_visibility_and_snapshot_catchup_convergence()
{
var file = Path.Combine(Path.GetTempPath(), $"nats-raft-snapshot-{Guid.NewGuid():N}.json");
try
{
var first = new RaftSnapshotStore(file);
await first.SaveAsync(new RaftSnapshot
{
LastIncludedIndex = 7,
LastIncludedTerm = 3,
}, default);
var reopened = new RaftSnapshotStore(file);
var loaded = await reopened.LoadAsync(default);
loaded.ShouldNotBeNull();
loaded.LastIncludedIndex.ShouldBe(7);
loaded.LastIncludedTerm.ShouldBe(3);
}
finally
{
if (File.Exists(file))
File.Delete(file);
}
}
}