-
Notifications
You must be signed in to change notification settings - Fork 31
Added memory protocol #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Changed from codec=None to codec='memory' - Now properly uses the memory codec for encoding/decoding - Fixes the issue mentioned in PR multiformats#92 where the author was unsure about the codec parameter - Follows the established pattern used by other protocols with custom codecs
|
Hi @lla-dane . just add some tests and I'll merge it PR #92 Review: Memory Protocol ImplementationOverviewThis PR adds support for the memory protocol (code 777) to py-multiaddr, implementing a uint64-based memory address system. ✅ What's Working Well
❌ Missing Tests - Critical Gaps1. Integration Tests MissingThe memory protocol is only tested in isolation. Missing tests in main test suite: # Missing from tests/test_multiaddr.py
def test_memory_protocol_integration():
ma = Multiaddr('/memory/12345')
assert str(ma) == '/memory/12345'
assert ma.protocols()[0].name == 'memory'
assert ma.value_for_protocol(777) == '12345'
# Binary roundtrip
binary = ma.to_bytes()
reconstructed = Multiaddr(binary)
assert str(reconstructed) == str(ma)2. Protocol Property Tests MissingNo tests for memory protocol-specific behavior: # Missing from tests/test_protocols.py
def test_memory_protocol_properties():
proto = Protocol(P_MEMORY, "memory", "memory")
assert proto.size == 8 # uint64 size
assert proto.path == False # not a path protocol
assert proto.code == 777
assert proto.name == "memory"🔧 Suggested Test AdditionsAdd to
|
|
@lla-dane : Great efforts, Abhinav. The linting issues have been resolved. Wonderful to see the addition of memory protocol. We will follow this structure to add more protocols. Lets have 1 PR per protocol first while we test a couple of additions in py-libp2p. We can then go for one major PR with remaining protocol additions. |
f7776fe to
ad51d44
Compare
|
@lla-dane : Thank you Abhinav for considering all our feedback points. Appreciate your efforts. The test suite is looking near. Reviewing it in details. Re-ran the CI/CD pipeline, which is in progress. The PR is ready for final review + merge. Will review in details today and merge the PR. In the meantime, you could open PRs for adding other key protocols - you could have 1-2 per PR. This would enable testing in parallel in py-libp2p front as well. On the same note, please initially pick up the protocols, which you can test at your end in py-libp2p. This would enable us to scale efforts quickly. |
|
@lla-dane : This looks ready for merge. Please add a discussion page in py-libp2p repository covering the implementation steps for adding the memory protocol in py-multiaddr. Appreciate your efforts. |
Tracks multiformats/multiaddr#181
Added the memory codec in py-multiaddr in reference with go-multiaddr implementation of memory:
https://github.com/multiformats/go-multiaddr/blob/b2ad16d978ea6b0f2cc49d20da2c0db24c92063d/transcoders.go#L493C1-L520C2