Commit 6a1362ca authored by Dirk McCormick's avatar Dirk McCormick

fix: session peer manager ordering test timing (2)

parent ae275396
......@@ -149,7 +149,7 @@ func TestRecordingReceivedBlocks(t *testing.T) {
func TestOrderingPeers(t *testing.T) {
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, 30*time.Millisecond)
ctx, cancel := context.WithTimeout(ctx, 60*time.Millisecond)
defer cancel()
peerCount := 100
peers := testutil.GeneratePeers(peerCount)
......@@ -184,8 +184,6 @@ func TestOrderingPeers(t *testing.T) {
time.Sleep(5 * time.Millisecond)
sessionPeerManager.RecordPeerResponse(peer3, []cid.Cid{c[0]})
time.Sleep(5 * time.Millisecond)
sessionPeers := sessionPeerManager.GetOptimizedPeers()
if len(sessionPeers) != maxOptimizedPeers {
t.Fatal(fmt.Sprintf("Should not return more (%d) than the max of optimized peers (%d)", len(sessionPeers), maxOptimizedPeers))
......@@ -225,8 +223,6 @@ func TestOrderingPeers(t *testing.T) {
// Receive a second time
sessionPeerManager.RecordPeerResponse(peer3, []cid.Cid{c2[0]})
time.Sleep(5 * time.Millisecond)
// call again
nextSessionPeers := sessionPeerManager.GetOptimizedPeers()
if len(nextSessionPeers) != maxOptimizedPeers {
......@@ -235,7 +231,7 @@ func TestOrderingPeers(t *testing.T) {
// should sort by average latency
// peer1: ~5ms
// peer3: (~35ms + ~5ms + ~5ms) / 2 = ~23ms
// peer3: (~35ms + ~5ms) / 2 = ~20ms
// peer2: ~30ms
if (nextSessionPeers[0].Peer != peer1) || (nextSessionPeers[1].Peer != peer3) ||
(nextSessionPeers[2].Peer != peer2) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment