content: {-# LANGUAGE DataKinds          #-}
  {-# LANGUAGE FlexibleInstances  #-}
  {-# LANGUAGE NoImplicitPrelude  #-}
  {-# LANGUAGE NumericUnderscores #-}
  {-# LANGUAGE OverloadedStrings  #-}
  
  module Main where
  
  import           Plutus.Model         (Run,
                                         TypedValidator (TypedValidator),
                                         adaValue, defaultBabbage, mustFail, testNoErrors,
                                         toV2, FakeCoin (FakeCoin), fakeValue)
  import           PlutusTx.Prelude     (($))
  import           Prelude              (IO, (.), (<>), undefined)
  import qualified ExploitableSwap      as OnChain
  import           Test.Tasty           (defaultMain, testGroup)
  
  ---------------------------------------------------------------------------------------------------
  ------------------------------------------ TESTING ------------------------------------------------
  
  main :: IO ()
  main = do
    defaultMain $ do
      testGroup
        "Catch double spend with testing"
        [ good "Normal spending" normalSpending
        , bad  "Double spending" doubleSpending
        ]
   where
      bad msg = good msg . mustFail
      good = testNoErrors (adaValue 10_000_000 <> fakeValue scToken 100) defaultBabbage
  
  ---------------------------------------------------------------------------------------------------
  ----------------------------- HELPER FUNCTIONS/INSTANCES/TYPES ------------------------------------
  
  scToken :: FakeCoin
  scToken = FakeCoin "Super-Cool-Token"
   
  type HomeworkScript = TypedValidator OnChain.DatumSwap ()
  
  swapScript :: HomeworkScript
  swapScript = TypedValidator $ toV2 OnChain.validator
  
  lockingTx = undefined
  
  consumingTx = undefined
  
  doubleConsumingTx = undefined
  
  ---------------------------------------------------------------------------------------------------
  -------------------------------------- TESTING SPENDING -------------------------------------------
  
  normalSpending :: Run ()
  normalSpending = undefined
  
  
  doubleSpending :: Run ()
  doubleSpending = undefined