Skip to content

Commit

Permalink
feat: better cache initialization (#30)
Browse files Browse the repository at this point in the history
* feat: better cache initialization

* chore: updated dkg-common
  • Loading branch information
maxirmx authored Sep 14, 2024
1 parent 5c0f416 commit a57ab67
Show file tree
Hide file tree
Showing 18 changed files with 369 additions and 645 deletions.
2 changes: 1 addition & 1 deletion dkg-common
2 changes: 1 addition & 1 deletion dkgNodeLibrary/Services/DkgNodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public async Task<StatusResponse> ReportStatus(HttpClient httpClient, string[]?
var statusResponse = new StatusResponse(roundId, Failed);
string r = $"[status '{NodeStatusConstants.GetNodeStatusById(Status).Name}', round '{(Round == null ? 0: Round)}']";

var report = new StatusReport(Config.PublicKey!, Name, Round ?? 0, Status);
var report = new StatusReport(Config.Address, Name, Round ?? 0, Status);
if (data != null)
{
report.Data = data;
Expand Down
16 changes: 8 additions & 8 deletions dkgNodesTests/NodeComparer.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public void Compare_FirstNodeNull_ReturnsOne()

var history1 = new NodesRoundHistory { NodeId = 100181, RoundId = 1, NodeRandom = 5 };
var history2 = new NodesRoundHistory { NodeId = 100182, RoundId = 1, NodeRandom = 3 };
nodesRoundHistoryCache.LoadNodesRoundHistoryToCache(history1);
nodesRoundHistoryCache.LoadNodesRoundHistoryToCache(history2);
nodesRoundHistoryCache.SaveNodesRoundHistoryToCache(history1);
nodesRoundHistoryCache.SaveNodesRoundHistoryToCache(history2);

var result = comparer.Compare(null, node);
Assert.That(result, Is.EqualTo(1));
Expand All @@ -76,8 +76,8 @@ public void Compare_BothNodesHaveSameNodeRandom_ReturnsZero()
var history1 = new NodesRoundHistory { NodeId = 1001811, RoundId = 1, NodeRandom = 5 };
var history2 = new NodesRoundHistory { NodeId = 1001812, RoundId = 1, NodeRandom = 5 };

nodesRoundHistoryCache.LoadNodesRoundHistoryToCache(history1);
nodesRoundHistoryCache.LoadNodesRoundHistoryToCache(history2);
nodesRoundHistoryCache.SaveNodesRoundHistoryToCache(history1);
nodesRoundHistoryCache.SaveNodesRoundHistoryToCache(history2);

var result = comparer.Compare(node1, node2);
Assert.That(result, Is.EqualTo(0));
Expand All @@ -93,8 +93,8 @@ public void Compare_FirstNodeHasSmallerNodeRandom_ReturnsMinusOne()
var history1 = new NodesRoundHistory { NodeId = 1001821, RoundId = 1, NodeRandom = 3 };
var history2 = new NodesRoundHistory { NodeId = 1001822, RoundId = 1, NodeRandom = 5 };

nodesRoundHistoryCache.LoadNodesRoundHistoryToCache(history1);
nodesRoundHistoryCache.LoadNodesRoundHistoryToCache(history2);
nodesRoundHistoryCache.SaveNodesRoundHistoryToCache(history1);
nodesRoundHistoryCache.SaveNodesRoundHistoryToCache(history2);

var result = comparer.Compare(node1, node2);
Assert.That(result, Is.EqualTo(-1));
Expand All @@ -110,8 +110,8 @@ public void Compare_SecondNodeHasSmallerNodeRandom_ReturnsOne()
var history1 = new NodesRoundHistory { NodeId = 1001831, RoundId = 1, NodeRandom = 5 };
var history2 = new NodesRoundHistory { NodeId = 1001832, RoundId = 1, NodeRandom = 3 };

nodesRoundHistoryCache.LoadNodesRoundHistoryToCache(history1);
nodesRoundHistoryCache.LoadNodesRoundHistoryToCache(history2);
nodesRoundHistoryCache.SaveNodesRoundHistoryToCache(history1);
nodesRoundHistoryCache.SaveNodesRoundHistoryToCache(history2);

var result = comparer.Compare(node1, node2);
Assert.That(result, Is.EqualTo(1));
Expand Down
159 changes: 0 additions & 159 deletions dkgNodesTests/NodesCache.Tests.cs

This file was deleted.

119 changes: 0 additions & 119 deletions dkgNodesTests/NodesRoundHistoryCache.Tests.cs

This file was deleted.

Loading

0 comments on commit a57ab67

Please sign in to comment.