-
Notifications
You must be signed in to change notification settings - Fork 98
Add basic test vectors for the Portal wire protocol #106
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| # Portal Wire Test Vectors | ||
|
|
||
| This document provides a collection of test vectors for the Portal wire protocol | ||
| aimed to aid new implementations to conform to the specification. | ||
|
|
||
| ## Protocol Message Encodings | ||
|
|
||
| This section provides test vectors for the individual protocol messages defined | ||
| in the [Portal wire protocol](./portal-wire-protocol.md). These test vectors can | ||
| primarily verify the SSZ encoding and decoding of each protocol message. | ||
|
|
||
| ### Ping Request | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| enr_seq = 1 | ||
| data_radius = 2^256 - 2 # Maximum value - 1 | ||
| custom_payload = serialize(Container(data_radius)) | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x0101000000000000000c000000feffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff | ||
| ``` | ||
|
|
||
| ### Pong Response | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| enr_seq = 1 | ||
| data_radius = (2^256 - 1) / 2 # Maximum value / 2 | ||
| custom_payload = serialize(Container(data_radius)) | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x0201000000000000000c000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f | ||
| ``` | ||
|
|
||
| ### Find Nodes Request | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| distances = [256, 255] | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x03040000000001ff00 | ||
| ``` | ||
|
|
||
| ### Nodes Response - Empty enrs | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| total = 1 | ||
| enrs = [] | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x040105000000 | ||
| ``` | ||
|
|
||
| ### Nodes Response - Multiple enrs | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| enr1 = "enr:-HW4QBzimRxkmT18hMKaAL3IcZF1UcfTMPyi3Q1pxwZZbcZVRI8DC5infUAB_UauARLOJtYTxaagKoGmIjzQxO2qUygBgmlkgnY0iXNlY3AyNTZrMaEDymNMrg1JrLQB2KTGtv6MVbcNEVv0AHacwUAPMljNMTg" | ||
|
|
||
| enr2 = "enr:-HW4QNfxw543Ypf4HXKXdYxkyzfcxcO-6p9X986WldfVpnVTQX1xlTnWrktEWUbeTZnmgOuAY_KUhbVV1Ft98WoYUBMBgmlkgnY0iXNlY3AyNTZrMaEDDiy3QkHAxPyOgWbxp5oF1bDdlYE6dLCUUp8xfVw50jU" | ||
|
|
||
| total = 1 | ||
| enrs = [enr1, enr2] | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x040105000000080000007f000000f875b8401ce2991c64993d7c84c29a00bdc871917551c7d330fca2dd0d69c706596dc655448f030b98a77d4001fd46ae0112ce26d613c5a6a02a81a6223cd0c4edaa53280182696482763489736563703235366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd3138f875b840d7f1c39e376297f81d7297758c64cb37dcc5c3beea9f57f7ce9695d7d5a67553417d719539d6ae4b445946de4d99e680eb8063f29485b555d45b7df16a1850130182696482763489736563703235366b31a1030e2cb74241c0c4fc8e8166f1a79a05d5b0dd95813a74b094529f317d5c39d235 | ||
| ``` | ||
|
|
||
| ### Find Content Request | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| content_key = 0x706f7274616c | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x0504000000706f7274616c | ||
| ``` | ||
|
|
||
| ### Content Response - Connection id | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| connection_id = [0x01, 0x02] | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x06000102 | ||
| ``` | ||
|
|
||
| ### Content Response - Content payload | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| content = 0x7468652063616b652069732061206c6965 | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x06017468652063616b652069732061206c6965 | ||
| ``` | ||
|
|
||
| ### Content Response - Multiple enrs | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| enr1 = "enr:-HW4QBzimRxkmT18hMKaAL3IcZF1UcfTMPyi3Q1pxwZZbcZVRI8DC5infUAB_UauARLOJtYTxaagKoGmIjzQxO2qUygBgmlkgnY0iXNlY3AyNTZrMaEDymNMrg1JrLQB2KTGtv6MVbcNEVv0AHacwUAPMljNMTg" | ||
|
|
||
| enr2 = "enr:-HW4QNfxw543Ypf4HXKXdYxkyzfcxcO-6p9X986WldfVpnVTQX1xlTnWrktEWUbeTZnmgOuAY_KUhbVV1Ft98WoYUBMBgmlkgnY0iXNlY3AyNTZrMaEDDiy3QkHAxPyOgWbxp5oF1bDdlYE6dLCUUp8xfVw50jU" | ||
|
|
||
| enrs = [enr1, enr2] | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x0602080000007f000000f875b8401ce2991c64993d7c84c29a00bdc871917551c7d330fca2dd0d69c706596dc655448f030b98a77d4001fd46ae0112ce26d613c5a6a02a81a6223cd0c4edaa53280182696482763489736563703235366b31a103ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd3138f875b840d7f1c39e376297f81d7297758c64cb37dcc5c3beea9f57f7ce9695d7d5a67553417d719539d6ae4b445946de4d99e680eb8063f29485b555d45b7df16a1850130182696482763489736563703235366b31a1030e2cb74241c0c4fc8e8166f1a79a05d5b0dd95813a74b094529f317d5c39d235 | ||
| ``` | ||
|
|
||
| ### Offer Request | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| content_key1 = 0x010203 | ||
| content_keys = [content_key1] | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x070400000004000000010203 | ||
| ``` | ||
|
|
||
| ### Accept Response | ||
|
|
||
| #### Input Parameters | ||
| ``` | ||
| connection_id = [0x01, 0x02] | ||
| content_keys = [1, 0, 0, 0, 0, 0, 0, 0] # 8 bits bitlist, 0 bit set = byte 0x01 | ||
| ``` | ||
|
|
||
| #### Expected Output | ||
| ``` | ||
| message = 0x080102060000000101 | ||
| ``` | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is clear. How to best represent here a bitlist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine with the
bitlistannotation. In JS, I'm mapping this to an actual array of Booleans and evidently there is something wrong with my encoding since your inputs produce08010206000000ff01when I serialize it.