summaryrefslogtreecommitdiff
path: root/tests/InfoHash.hs
blob: 3f5a14325eeb9b45d4fb8abc01d5f72838852dd3 (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 :: String
checkInfo = "0221caf96aa3cb94f0f58d458e78b0fc344ad8bf"

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

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

  t <- fromFile path

  BC.putStr "info hash: "
  print (ppInfoHash (tInfoHash t))

  let passed = checkInfo == show (ppInfoHash (tInfoHash t))

  print passed
  if passed then exitSuccess else exitFailure