test(network): add unit tests for eth2network connections and primary messaging#793
Open
zclawz wants to merge 1 commit into
Open
test(network): add unit tests for eth2network connections and primary messaging#793zclawz wants to merge 1 commit into
zclawz wants to merge 1 commit into
Conversation
… messaging Adds pkgs/network/src/test.zig with unit tests covering: - GossipEncoding encode/decode roundtrip and error handling - GossipTopic encode/decode roundtrip (block, aggregation, attestation with subnet_id) - GossipMessage.getGossipTopic active tag - GenericGossipHandler: subscribe and synchronous delivery of block msgs - GenericGossipHandler: multiple subscribers receive the same message - GenericGossipHandler: topic filtering (unsubscribed topics are dropped) - GenericGossipHandler: attestation subscribe + deliver - Mock network: publish attestation and receive via subscriber - Mock network: topic isolation (block subscriber drops attestation) - Mock network: concurrent block and attestation subscribers each receive only their own type Tests use only network interface objects (interface.zig, mock.zig, GenericGossipHandler) — no node dependencies. Closes #159
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #159
Summary
Adds
pkgs/network/src/test.zigwith 10 unit tests covering the network interface layer without any node dependencies:Interface encoding
GossipEncodingencode/decode roundtrip and unknown-string errorGossipTopicencode/decode roundtrip forblock,aggregation, andattestation(with subnet_id)GossipTopicdecode unknown returns errorGossipMessage.getGossipTopicreturns correct active tagGenericGossipHandler (direct)
Mock network
Testing
zig build testpassesNote: an existing PR (#202 by @bomanaps) targeted the same issue but has merge conflicts and uses the old API (
GossipTopicwas a plain enum;onGossipFnhad a different signature). This PR is based on currentmainand uses the current interface.