Skip to content

Conversation

@Jineshbansal
Copy link
Contributor

@Jineshbansal Jineshbansal commented Jan 18, 2026

Fixes #1136

What was wrong?

The tests/interop/go_libp2p/ directory only contained a placeholder test that didn't verify any actual interoperability with go-libp2p. This meant py-libp2p had no automated way to verify it can communicate with the reference libp2p implementation (go-libp2p) .

Related: Following the pattern established by nim-libp2p interop tests

How was it fixed?

Implemented a complete interop testing suite that verifies py-libp2p can communicate with go-libp2p over QUIC transport using the echo protocol (/echo/1.0.0).

Components Added

  1. Go Echo Server (go_echo_server.go

    • Lightweight go-libp2p server that echoes back messages
    • Uses QUIC transport (same as py-libp2p tests)
    • Implements msgio varint-prefixed message format
  2. Build Script (scripts/setup_go_echo.sh)

    • Automated build process with caching
    • Checks Go installation and version
    • Skips rebuild if binary already exists
  3. Test Fixtures (conftest.py)

    • Manages Go server lifecycle (start/stop)
    • Parses server output to extract connection address
    • Gracefully skips tests if Go isn't installed
  4. Test Suite (test_echo_interop.py)

    • 6 comprehensive tests covering various scenarios
    • Tests basic echo, large messages, unicode, and multiple connections

Tests Implemented

Test Purpose
test_basic_echo Verify basic message exchange works
test_echo_empty_string Edge case handling
test_echo_large_message 10KB message handling
test_echo_unicode Verify Unicode support
test_echo_multiple_sequential 10 sequential messages
test_multiple_connections Multiple separate connections

Testing

All tests passing

Screenshot: Test Results

Screenshot From 2026-01-18 02-37-39

Manual verification

# Build the Go server
cd tests/interop/go_libp2p

./scripts/setup_go_echo.sh

# Run tests
pytest -v

@seetadev
Copy link
Contributor

@Jineshbansal : Hi Jinesh.

Wish to share that for all interop related tasks, please work at https://github.com/libp2p/test-plans.

In any case, we should avoid having .sh and .go files in py-libp2p main library.

As discussed in the maintainer's call, kindly collaborate with @sumanjeet0012 and @acul71 , who will help you in taking initiatives on interop suite front.

CCing @pacrob.

Please also study the documentation added by @dhuseby.

@Jineshbansal
Copy link
Contributor Author

Jineshbansal commented Jan 18, 2026

Hi @seetadev ,

Thanks for the feedback. I actually followed the existing pattern from nim_libp2p which already has .nim and .sh files in py-libp2p.

That said , I'll collaborate with @sumanjeet0012 and @acul71 on moving this work in test-plans repo.

@seetadev
Copy link
Contributor

@Jineshbansal : Hi Jinesh — thanks for opening this and for the very clear, well-structured proposal 🙌
You’ve done a solid job laying out the motivation, current gap, and an implementation plan, and you’re absolutely right that Echo-based interop with go-libp2p is high-value, especially given Go’s role as the reference implementation.

A few important alignment pointers to help you get this landed smoothly, especially since you’re a new contributor:

📍 Where interop tests should live

Even though there’s currently a placeholder under py-libp2p/tests/interop/go_libp2p, new interoperability test suites should not be implemented directly in the py-libp2p repo.

All cross-implementation interop tests (Go ↔ Python, Rust ↔ Python, JS ↔ Python, etc.) should live in the canonical repo:
👉 https://github.com/libp2p/test-plans

That repo is where:

  • Cross-stack interop scenarios are defined and reviewed
  • Shared orchestration patterns live
  • Long-term interop coverage is tracked consistently across implementations

Please follow the structure and conventions documented here:
https://github.com/libp2p/test-plans/tree/master/docs

So the Go echo server, build scripts, pytest fixtures, and test flow you outlined should be implemented under test-plans, rather than under py-libp2p/tests/interop.

📦 Scope of py-libp2p PRs

PRs to py-libp2p → main should only be opened if:

  • You’re changing core library behavior, or
  • You’re adding/updating shared utilities used by py-libp2p itself

If, while implementing the Go Echo interop test, you uncover:

  • A protocol mismatch
  • A missing feature
  • Or a bug in py-libp2p

…then a focused PR to py-libp2p is absolutely appropriate. Otherwise, the interop logic itself should stay in test-plans.

🧭 On your proposed approach

  • Using Echo (not just Ping) is the right call — it exercises real bidirectional stream behavior and catches issues that simpler tests miss.
  • Mirroring the nim-libp2p interop structure is the correct reference point.
  • The outlined flow (build → spawn server → interop test → teardown) makes sense and should translate well into test-plans.

From a roadmap perspective, this aligns very well with the Universal Connectivity / v0.6.0 goals.

🤝 Maintainers sync (recommended for new contributors)

Since you’re new to the libp2p ecosystem, please try to join the libp2p maintainers meeting every Thursday.
It’s the fastest way to:

  • Sanity-check interop scope (Echo expectations, reuse across Go/Rust/JS)
  • Coordinate with parallel work already happening
  • Avoid duplicated effort and get early feedback

Overall, this is a strong and well-motivated issue, and exactly the kind of contribution we want to encourage.
I’d suggest moving the implementation to test-plans, referencing this issue for context, and opening a draft PR there for early feedback. Happy to review and help iterate once it’s up — keep it up 🚀

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.

Implement go-libp2p interop tests (echo protocol)

2 participants