| 1 | package config |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/ipfs/boxo/autoconf" |
| 7 | "github.com/stretchr/testify/assert" |
| 8 | "github.com/stretchr/testify/require" |
| 9 | ) |
| 10 | |
| 11 | func TestBootstrapPeerStrings(t *testing.T) { |
| 12 | // Test round-trip: string -> parse -> format -> string |
| 13 | // This ensures that parsing and formatting are inverse operations |
| 14 | |
| 15 | // Start with the default bootstrap peer multiaddr strings |
| 16 | originalStrings := autoconf.FallbackBootstrapPeers |
| 17 | |
| 18 | // Parse multiaddr strings into structured peer data |
| 19 | parsed, err := ParseBootstrapPeers(originalStrings) |
| 20 | require.NoError(t, err, "parsing bootstrap peers should succeed") |
| 21 | |
| 22 | // Format the parsed data back into multiaddr strings |
| 23 | formattedStrings := BootstrapPeerStrings(parsed) |
| 24 | |
| 25 | // Verify round-trip: we should get back exactly what we started with |
| 26 | assert.ElementsMatch(t, originalStrings, formattedStrings, |
| 27 | "round-trip through parse/format should preserve all bootstrap peers") |
| 28 | } |