-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure protocol naming matches latest Starknet p2p spec
The change ensures that DHT protocol follow latest Starknet specification.
- Loading branch information
1 parent
4ff174d
commit fee852d
Showing
5 changed files
with
132 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,66 @@ | ||
package starknet | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestProtocolIDs(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
chainID string | ||
pidFunc func(string) string | ||
expected string | ||
}{ | ||
{ | ||
name: "HeadersPID with SN_MAIN", | ||
chainID: "SN_MAIN", | ||
pidFunc: func(c string) string { return string(HeadersPID(c)) }, | ||
expected: "/starknet/SN_MAIN/sync/headers/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "EventsPID with SN_MAIN", | ||
chainID: "SN_MAIN", | ||
pidFunc: func(c string) string { return string(EventsPID(c)) }, | ||
expected: "/starknet/SN_MAIN/sync/events/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "TransactionsPID with SN_MAIN", | ||
chainID: "SN_MAIN", | ||
pidFunc: func(c string) string { return string(TransactionsPID(c)) }, | ||
expected: "/starknet/SN_MAIN/sync/transactions/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "ClassesPID with SN_MAIN", | ||
chainID: "SN_MAIN", | ||
pidFunc: func(c string) string { return string(ClassesPID(c)) }, | ||
expected: "/starknet/SN_MAIN/sync/classes/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "StateDiffPID with SN_MAIN", | ||
chainID: "SN_MAIN", | ||
pidFunc: func(c string) string { return string(StateDiffPID(c)) }, | ||
expected: "/starknet/SN_MAIN/sync/state_diffs/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "DHTPrefixPID with SN_MAIN", | ||
chainID: "SN_MAIN", | ||
pidFunc: func(c string) string { return string(DHTPrefixPID(c)) }, | ||
expected: "/starknet/SN_MAIN/sync", | ||
}, | ||
{ | ||
name: "HeadersPID with SN_SEPOLIA", | ||
chainID: "SN_SEPOLIA", | ||
pidFunc: func(c string) string { return string(HeadersPID(c)) }, | ||
expected: "/starknet/SN_SEPOLIA/sync/headers/0.1.0-rc.0", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
result := tc.pidFunc(tc.chainID) | ||
assert.Equal(t, tc.expected, result) | ||
}) | ||
} | ||
} |