summaryrefslogtreecommitdiff
path: root/tests/info-hash.hs
blob: ce8d7db27687509c4e7ed122091e47d9f88f4a2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE OverloadedStrings #-}
module Main (main) where

import           Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as BC
import Data.Torrent

import System.Environment
import System.Exit


checkInfo :: ByteString
checkInfo = "0221caf96aa3cb94f0f58d458e78b0fc344ad8bf"

torrentFileName :: String
torrentFileName = "tests/dapper-dvd-amd64.iso.torrent"

main :: IO ()
main = do
  args <- getArgs
  let path = if length args == 0 then torrentFileName else head args

  Right t <- fromFile path

  BC.putStr "info hash: "
  BC.putStrLn (ppHex (tInfoHash t))

  let passed = checkInfo == ppHex (tInfoHash t)
  print passed
  if passed then exitSuccess else exitFailure