-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure DHT protocol ID matches latest Starknet spec
Use dht.ProtocolExtension to set chainID in protocol ID format for DHT. Add test to verify protocol ID format for different networks: - /starknet/SN_SEPOLIA/kad/1.0.0 for Sepolia - /starknet/SN_MAIN/kad/1.0.0 for Mainnet The change ensures that DHT protocol follow latest Starknet specification.
- Loading branch information
1 parent
ec24744
commit 629f346
Showing
6 changed files
with
131 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
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: "ChainPID with SN_MAIN", | ||
chainID: "SN_MAIN", | ||
pidFunc: func(c string) string { return string(ChainPID(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) | ||
}) | ||
} | ||
} |