Skip to content

Conversation

@akrem-chabchoub
Copy link
Contributor

@akrem-chabchoub akrem-chabchoub commented Oct 29, 2025

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Add synctest in ping test.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

#5232

Screenshots (if appropriate):

@akrem-chabchoub akrem-chabchoub marked this pull request as ready for review October 29, 2025 13:40
Copilot AI review requested due to automatic review settings October 29, 2025 13:40
@akrem-chabchoub akrem-chabchoub added this to the v2.7.0 milestone Oct 29, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the pingpong test to use Go's testing/synctest package for deterministic virtual time testing. The main changes include removing platform-specific workarounds for Windows timing issues, updating the RTT validation logic to handle virtual time, and temporarily limiting CI test runs to the pingpong package only.

  • Replaced manual time delays and parallel testing with synctest.Test() for deterministic virtual time
  • Updated RTT validation to accept zero values in synctest's virtual time environment
  • Removed unused imports (runtime, time, p2p)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/pingpong/pingpong_test.go Refactored to use testing/synctest with virtual time, removed Windows-specific workarounds
Makefile Temporarily restricted CI test targets to only run ./pkg/pingpong tests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if err != nil {
t.Fatal(err)
}
// check that RTT is a same value (rtt can be 0 in synctest virtual time)
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'same' to 'sane' in comment.

Suggested change
// check that RTT is a same value (rtt can be 0 in synctest virtual time)
// check that RTT is a sane value (rtt can be 0 in synctest virtual time)

Copilot uses AI. Check for mistakes.
}

// check that RTT is a sane value
if rtt <= 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test must evaluate that the rtt is not 0 as well, as zero value can also signal that the protocol does not work.

It could be now made that the protocol waits when responding to messages with the middleware for any os (to remove the goos check), that and to check if the rtt value is measured correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to check the rtt is not zero as well, but the tests are failing. I think as I already mentioned since time is virtual in synctest so the the rtt can be zero.
https://github.com/ethersphere/bee/actions/runs/19616730484/job/56172634154

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, we have to make the time to advance in order to measure rtt in the bubble, by blocking something. I thought thought that it is good to use the middleware that you removed that sleeps, but for any os. Test is working with that approach, but it actually does not make the test correct as it measures the middleware, and we want to measure messages reading and writing latencies. So, I have added the option to recorder to introduce the message latency so that we can measure rtt, now even exactly, which is much better than before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, good.
Here it might be better to compare rtt as 2 * len(greetings) * messageLatency ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Updated.

@akrem-chabchoub akrem-chabchoub requested a review from acud November 29, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants