- desc = "normalize_root is idempotent"
-
- prop :: String -> Bool
- prop s = (normalize_root . normalize_root) bs == normalize_root bs
- where
- bs = BS.pack s
-
-dns_tests :: TestTree
-dns_tests =
- testGroup "DNS Tests" [
- test_normalize_case,
- test_normalize_root_adds_dot ]
-
-dns_properties :: TestTree
-dns_properties =
- testGroup "DNS Properties" [
- prop_normalize_case_idempotent,
- prop_normalize_root_idempotent ]
+ -- Convert, normalize, and de-dupe the @domains@.
+ unique_domains :: [Domain]
+ unique_domains = nub $ map (normalize . BS.pack) domains
+
+ -- | Convert a string domain name into a pair containing the
+ -- domain name in the first component and a set of its mail
+ -- exchangers (as strings) in the second component.
+ --
+ make_pair :: Domain -> IO (String, Set String)
+ make_pair domain = do
+ -- Lookup the @domain@'s MX records.
+ mx_list <- lookup_mxs domain
+
+ -- Now convert the MX records *back* to strings.
+ let string_mx_list = map BS.unpack mx_list
+
+ -- Convert the list into a set
+ let string_mx_set = Set.fromList string_mx_list
+
+ -- Finally, construct the pair and return it.
+ return (BS.unpack domain, string_mx_set)