2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-06-23 18:38:41 +00:00

FetchTypeDef

This commit is contained in:
2026-06-16 16:07:57 +03:00
parent 147572a138
commit 3d0f97ade0
5 changed files with 101 additions and 23 deletions
+15
View File
@@ -18,6 +18,14 @@ public class FetchCycleDetectionTests
return g;
}
static Dictionary<ulong, HashSet<ulong>> Graph64(params (ulong parent, ulong[] children)[] edges)
{
var g = new Dictionary<ulong, HashSet<ulong>>();
foreach (var (parent, children) in edges)
g[parent] = new HashSet<ulong>(children);
return g;
}
[Fact]
public void AppFacingFetch_NoChain_NeverCycles()
{
@@ -83,4 +91,11 @@ public class FetchCycleDetectionTests
var g = Graph((2u, new uint[] { 3 }), (3u, new uint[] { 2 }));
Assert.False(EpConnection.HasWaitForCycle(2, new uint[] { 1 }, g));
}
[Fact]
public void TypeDefIds_UseSameCycleDetection()
{
var g = Graph64((2ul, new ulong[] { 3 }), (3ul, new ulong[] { 1 }));
Assert.True(EpConnection.HasWaitForCycle(2ul, new ulong[] { 1 }, g));
}
}
@@ -49,6 +49,17 @@ public class DeadlockDetectionTests
foreach (var grp in edgeList.GroupBy(e => e.from))
ns[grp.Key].Links = grp.Select(e => ns[e.to]).ToArray();
});
if (mode == DeadlockResolutionMode.NaiveWait)
{
// Node.Links is self-referential at the typedef level. Warm it with the default
// resolver so this test isolates NaiveWait behavior to the resource graph.
var nodeTypeDef = cluster.ServerWarehouse.GetLocalTypeDefByName(typeof(Node).FullName ?? nameof(Node));
if (nodeTypeDef == null)
throw new InvalidOperationException("Node typedef was not registered.");
await cluster.Connection.FetchTypeDef(nodeTypeDef.Id, null);
}
cluster.Connection.DeadlockResolution = mode;
return cluster;
}