-
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 p2p protocol matches new Starknet spec
- Loading branch information
1 parent
0c6508c
commit 3514225
Showing
5 changed files
with
137 additions
and
28 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,67 @@ | ||
package sync | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/NethermindEth/juno/utils" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestProtocolIDs(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
network *utils.Network | ||
pidFunc func(*utils.Network) string | ||
expected string | ||
}{ | ||
{ | ||
name: "HeadersPID with SN_MAIN", | ||
network: &utils.Mainnet, | ||
pidFunc: func(n *utils.Network) string { return string(HeadersPID(n)) }, | ||
expected: "/starknet/SN_MAIN/sync/headers/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "EventsPID with SN_MAIN", | ||
network: &utils.Mainnet, | ||
pidFunc: func(n *utils.Network) string { return string(EventsPID(n)) }, | ||
expected: "/starknet/SN_MAIN/sync/events/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "TransactionsPID with SN_MAIN", | ||
network: &utils.Mainnet, | ||
pidFunc: func(n *utils.Network) string { return string(TransactionsPID(n)) }, | ||
expected: "/starknet/SN_MAIN/sync/transactions/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "ClassesPID with SN_MAIN", | ||
network: &utils.Mainnet, | ||
pidFunc: func(n *utils.Network) string { return string(ClassesPID(n)) }, | ||
expected: "/starknet/SN_MAIN/sync/classes/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "StateDiffPID with SN_MAIN", | ||
network: &utils.Mainnet, | ||
pidFunc: func(n *utils.Network) string { return string(StateDiffPID(n)) }, | ||
expected: "/starknet/SN_MAIN/sync/state_diffs/0.1.0-rc.0", | ||
}, | ||
{ | ||
name: "DHTPrefixPID with SN_MAIN", | ||
network: &utils.Mainnet, | ||
pidFunc: func(n *utils.Network) string { return string(DHTPrefixPID(n)) }, | ||
expected: "/starknet/SN_MAIN/sync", | ||
}, | ||
{ | ||
name: "HeadersPID with SN_SEPOLIA", | ||
network: &utils.Sepolia, | ||
pidFunc: func(n *utils.Network) string { return string(HeadersPID(n)) }, | ||
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.network) | ||
assert.Equal(t, tc.expected, result) | ||
}) | ||
} | ||
} |