Skip to content

Commit

Permalink
Tweaking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Aug 19, 2023
1 parent 4114961 commit 6724f27
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions tests/pubsub/testgossipinternal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ suite "GossipSub internal":
ihaveMessageId = byteutils.toHex(seqno) & $firstPeer.peerId
peer.handler = handler

# Action 1: Simulate that each peer sends an IHAVE message to our node
# Simulate that each peer sends an IHAVE message to our node
let msg = ControlIHave(
topicID: topic,
messageIDs: @[ihaveMessageId.toBytes()]
Expand All @@ -766,11 +766,11 @@ suite "GossipSub internal":
if iwants.messageIds.len > 0:
iwantCount += 1

# Check: Verify that our node responds with only one IWANT message
# Verify that our node responds with only one IWANT message
check: iwantCount == 1
check: gossipSub.outstandingIWANTs.contains(ihaveMessageId.toBytes())

# Action 2: Simulate that our node receives the RPCMsg in response to the IWANT
# Simulate that our node receives the RPCMsg in response to the IWANT
let actualMessageData = "Hello, World!".toBytes
let rpcMsg = RPCMsg(
messages: @[Message(
Expand Down Expand Up @@ -815,15 +815,13 @@ suite "GossipSub internal":
)
discard gossipSub.handleIHave(peer, @[ihaveMsg])

# Check that the message ID is in outstandingIWANTs
check: gossipSub.outstandingIWANTs.contains(ihaveMessageId)
check: peer.behaviourPenalty == 0.0

await sleepAsync(60.milliseconds)

# Check that the message ID has been removed from outstandingIWANTs after the timeout and peer has been penalized
check: not gossipSub.outstandingIWANTs.contains(ihaveMessageId)
check: peer.behaviourPenalty == 0.1

await allFuturesThrowing(conns.mapIt(it.close()))
await gossipSub.switch.stop()
await gossipSub.switch.stop()

0 comments on commit 6724f27

Please sign in to comment.