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 f58be5c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 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,13 +815,11 @@ 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

Expand Down

0 comments on commit f58be5c

Please sign in to comment.