|
| 1 | +package sync |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/NethermindEth/juno/utils" |
| 7 | + "github.com/stretchr/testify/assert" |
| 8 | +) |
| 9 | + |
| 10 | +func TestProtocolIDs(t *testing.T) { |
| 11 | + testCases := []struct { |
| 12 | + name string |
| 13 | + network *utils.Network |
| 14 | + pidFunc func(*utils.Network) string |
| 15 | + expected string |
| 16 | + }{ |
| 17 | + { |
| 18 | + name: "HeadersPID with SN_MAIN", |
| 19 | + network: &utils.Mainnet, |
| 20 | + pidFunc: func(n *utils.Network) string { return string(HeadersPID(n)) }, |
| 21 | + expected: "/starknet/SN_MAIN/sync/headers/0.1.0-rc.0", |
| 22 | + }, |
| 23 | + { |
| 24 | + name: "EventsPID with SN_MAIN", |
| 25 | + network: &utils.Mainnet, |
| 26 | + pidFunc: func(n *utils.Network) string { return string(EventsPID(n)) }, |
| 27 | + expected: "/starknet/SN_MAIN/sync/events/0.1.0-rc.0", |
| 28 | + }, |
| 29 | + { |
| 30 | + name: "TransactionsPID with SN_MAIN", |
| 31 | + network: &utils.Mainnet, |
| 32 | + pidFunc: func(n *utils.Network) string { return string(TransactionsPID(n)) }, |
| 33 | + expected: "/starknet/SN_MAIN/sync/transactions/0.1.0-rc.0", |
| 34 | + }, |
| 35 | + { |
| 36 | + name: "ClassesPID with SN_MAIN", |
| 37 | + network: &utils.Mainnet, |
| 38 | + pidFunc: func(n *utils.Network) string { return string(ClassesPID(n)) }, |
| 39 | + expected: "/starknet/SN_MAIN/sync/classes/0.1.0-rc.0", |
| 40 | + }, |
| 41 | + { |
| 42 | + name: "StateDiffPID with SN_MAIN", |
| 43 | + network: &utils.Mainnet, |
| 44 | + pidFunc: func(n *utils.Network) string { return string(StateDiffPID(n)) }, |
| 45 | + expected: "/starknet/SN_MAIN/sync/state_diffs/0.1.0-rc.0", |
| 46 | + }, |
| 47 | + { |
| 48 | + name: "DHTPrefixPID with SN_MAIN", |
| 49 | + network: &utils.Mainnet, |
| 50 | + pidFunc: func(n *utils.Network) string { return string(DHTPrefixPID(n)) }, |
| 51 | + expected: "/starknet/SN_MAIN/sync", |
| 52 | + }, |
| 53 | + { |
| 54 | + name: "HeadersPID with SN_SEPOLIA", |
| 55 | + network: &utils.Sepolia, |
| 56 | + pidFunc: func(n *utils.Network) string { return string(HeadersPID(n)) }, |
| 57 | + expected: "/starknet/SN_SEPOLIA/sync/headers/0.1.0-rc.0", |
| 58 | + }, |
| 59 | + } |
| 60 | + |
| 61 | + for _, tc := range testCases { |
| 62 | + t.Run(tc.name, func(t *testing.T) { |
| 63 | + result := tc.pidFunc(tc.network) |
| 64 | + assert.Equal(t, tc.expected, result) |
| 65 | + }) |
| 66 | + } |
| 67 | +} |
0 commit comments