Fixed problem with AuthorityTest & LatencyNodeProviderTest
This commit is contained in:
parent
e3b030b3fb
commit
9b27bced03
2 changed files with 13 additions and 12 deletions
|
@ -7,6 +7,7 @@ import org.junit.Test;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by nelson on 12/16/16.
|
* Created by nelson on 12/16/16.
|
||||||
|
@ -48,7 +49,7 @@ public class AuthorityTest {
|
||||||
@Test
|
@Test
|
||||||
public void equals() throws Exception {
|
public void equals() throws Exception {
|
||||||
assertEquals("Equal authorities", authority, sameAuthority);
|
assertEquals("Equal authorities", authority, sameAuthority);
|
||||||
assertEquals("Different authorities ", authority, differentAuthority);
|
assertNotEquals("Different authorities ", authority, differentAuthority);
|
||||||
assertEquals("Two public keys with the same public key should be equal", keyAuthority1, keyAuthority2);
|
assertEquals("Two public keys with the same public key should be equal", keyAuthority1, keyAuthority2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package cy.agorise.graphenej.network;
|
package cy.agorise.graphenej.network;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class LatencyNodeProviderTest {
|
public class LatencyNodeProviderTest {
|
||||||
private FullNode nodeA, nodeB, nodeC;
|
private FullNode nodeA, nodeB, nodeC;
|
||||||
private LatencyNodeProvider latencyNodeProvider;
|
private LatencyNodeProvider latencyNodeProvider;
|
||||||
|
@ -34,9 +34,9 @@ public class LatencyNodeProviderTest {
|
||||||
|
|
||||||
// Confirming that the getSortedNodes gives us a sorted list of nodes in increasing latency order
|
// Confirming that the getSortedNodes gives us a sorted list of nodes in increasing latency order
|
||||||
List<FullNode> fullNodeList = latencyNodeProvider.getSortedNodes();
|
List<FullNode> fullNodeList = latencyNodeProvider.getSortedNodes();
|
||||||
Assert.assertSame(nodeC, fullNodeList.get(0));
|
assertEquals(nodeC, fullNodeList.get(0));
|
||||||
Assert.assertSame(nodeB, fullNodeList.get(1));
|
assertEquals(nodeB, fullNodeList.get(1));
|
||||||
Assert.assertSame(nodeA, fullNodeList.get(2));
|
assertEquals(nodeA, fullNodeList.get(2));
|
||||||
|
|
||||||
// Adding more nodes with different latencies measurements
|
// Adding more nodes with different latencies measurements
|
||||||
FullNode nodeD = new FullNode("wss://nodeD");
|
FullNode nodeD = new FullNode("wss://nodeD");
|
||||||
|
@ -55,11 +55,11 @@ public class LatencyNodeProviderTest {
|
||||||
|
|
||||||
FullNode bestNode = latencyNodeProvider.getBestNode();
|
FullNode bestNode = latencyNodeProvider.getBestNode();
|
||||||
// Checking for best node
|
// Checking for best node
|
||||||
Assert.assertSame("Verifying that the nodeE is the best now", nodeE, bestNode);
|
assertEquals("Verifying that the nodeE is the best now", nodeE, bestNode);
|
||||||
fullNodeList = latencyNodeProvider.getSortedNodes();
|
fullNodeList = latencyNodeProvider.getSortedNodes();
|
||||||
FullNode worstNode = fullNodeList.get(fullNodeList.size() - 1);
|
FullNode worstNode = fullNodeList.get(fullNodeList.size() - 1);
|
||||||
// Checking for worst node
|
// Checking for worst node
|
||||||
Assert.assertSame("Verifying that the nodeF is the worst now", nodeF, worstNode);
|
assertEquals("Verifying that the nodeF is the worst now", nodeF, worstNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -68,7 +68,7 @@ public class LatencyNodeProviderTest {
|
||||||
|
|
||||||
// Confirming that the best node is nodeC
|
// Confirming that the best node is nodeC
|
||||||
FullNode bestNode = latencyNodeProvider.getBestNode();
|
FullNode bestNode = latencyNodeProvider.getBestNode();
|
||||||
Assert.assertSame("Check that the best node is nodeC", nodeC, bestNode);
|
assertEquals("Check that the best node is nodeC", nodeC, bestNode);
|
||||||
|
|
||||||
// Improving nodeA score by feeding it with new better latency measurements
|
// Improving nodeA score by feeding it with new better latency measurements
|
||||||
latencyNodeProvider.updateNode(nodeA, 10);
|
latencyNodeProvider.updateNode(nodeA, 10);
|
||||||
|
@ -80,7 +80,7 @@ public class LatencyNodeProviderTest {
|
||||||
latencyNodeProvider.updateNode(nodeA);
|
latencyNodeProvider.updateNode(nodeA);
|
||||||
bestNode = latencyNodeProvider.getBestNode();
|
bestNode = latencyNodeProvider.getBestNode();
|
||||||
System.out.println("Best node latency after update: "+bestNode.getLatencyValue());
|
System.out.println("Best node latency after update: "+bestNode.getLatencyValue());
|
||||||
Assert.assertSame("Check that the best node now is the nodeA", nodeA, bestNode);
|
assertEquals("Check that the best node now is the nodeA", nodeA, bestNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -89,7 +89,7 @@ public class LatencyNodeProviderTest {
|
||||||
nodeA.addLatencyValue(Long.MAX_VALUE);
|
nodeA.addLatencyValue(Long.MAX_VALUE);
|
||||||
latencyNodeProvider.updateNode(nodeA);
|
latencyNodeProvider.updateNode(nodeA);
|
||||||
FullNode best = latencyNodeProvider.getBestNode();
|
FullNode best = latencyNodeProvider.getBestNode();
|
||||||
Assert.assertSame(nodeC, best);
|
assertEquals(nodeC, best);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -174,6 +174,6 @@ public class LatencyNodeProviderTest {
|
||||||
provider.updateNode(node20);
|
provider.updateNode(node20);
|
||||||
|
|
||||||
FullNode best = provider.getBestNode();
|
FullNode best = provider.getBestNode();
|
||||||
Assert.assertSame("Expects node4 to be the best", node4, best);
|
assertEquals("Expects node4 to be the best", node4, best);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue