handles codex events without node or peer

This commit is contained in:
benbierens 2024-10-14 09:11:09 +02:00
parent 1bd84a4892
commit 672092b232
No known key found for this signature in database
GPG Key ID: 877D2C2E09A22F3A
4 changed files with 13 additions and 9 deletions

View File

@ -117,10 +117,10 @@ namespace FrameworkTests.OverwatchTranscriptTests
var e = events.SingleOrDefault(e => e.Moment.Utc == utc && e.Payload.EventData == data); var e = events.SingleOrDefault(e => e.Moment.Utc == utc && e.Payload.EventData == data);
if (e == null) Assert.Fail("Event not found"); if (e == null) Assert.Fail("Event not found");
Assert.That(e.Moment.Utc, Is.EqualTo(utc)); Assert.That(e!.Moment.Utc, Is.EqualTo(utc));
Assert.That(e.Moment.Duration, Is.EqualTo(duration)); Assert.That(e!.Moment.Duration, Is.EqualTo(duration));
Assert.That(e.Moment.Index, Is.EqualTo(index)); Assert.That(e!.Moment.Index, Is.EqualTo(index));
Assert.That(e.Payload.EventData, Is.EqualTo(data)); Assert.That(e!.Payload.EventData, Is.EqualTo(data));
} }
private void AssertFileContent() private void AssertFileContent()

View File

@ -19,18 +19,19 @@ namespace TranscriptAnalysis.Receivers
Header = header; Header = header;
} }
protected string GetPeerId(int nodeIndex) protected string? GetPeerId(int nodeIndex)
{ {
return GetIdentity(nodeIndex).PeerId; return GetIdentity(nodeIndex)?.PeerId;
} }
protected string GetName(int nodeIndex) protected string? GetName(int nodeIndex)
{ {
return GetIdentity(nodeIndex).Name; return GetIdentity(nodeIndex)?.Name;
} }
protected CodexNodeIdentity GetIdentity(int nodeIndex) protected CodexNodeIdentity? GetIdentity(int nodeIndex)
{ {
if (nodeIndex < 0) return null;
return Header.Nodes[nodeIndex]; return Header.Nodes[nodeIndex];
} }

View File

@ -14,6 +14,8 @@ namespace TranscriptAnalysis.Receivers
{ {
var peerId = GetPeerId(@event.Payload.NodeIdentity); var peerId = GetPeerId(@event.Payload.NodeIdentity);
var name = GetName(@event.Payload.NodeIdentity); var name = GetName(@event.Payload.NodeIdentity);
if (peerId == null) return;
if (name == null) return;
if (!seen.Contains(peerId)) if (!seen.Contains(peerId))
{ {

View File

@ -54,6 +54,7 @@ namespace TranscriptAnalysis.Receivers
if (@event.Payload.DialSuccessful != null) if (@event.Payload.DialSuccessful != null)
{ {
var peerId = GetPeerId(@event.Payload.NodeIdentity); var peerId = GetPeerId(@event.Payload.NodeIdentity);
if (peerId == null) return;
AddDial(peerId, @event.Payload.DialSuccessful.TargetPeerId); AddDial(peerId, @event.Payload.DialSuccessful.TargetPeerId);
} }
} }