module Test.Cardano.Ledger.Conway.Spec (spec) where import Cardano.Ledger.Coin (Coin (..)) import Cardano.Ledger.Conway.Tx (tierRefScriptFee) import Test.Cardano.Ledger.Common spec :: Spec spec :: Spec spec = do forall a. HasCallStack => String -> SpecWith a -> SpecWith a describe String "Various tests for functions defined in Conway" forall a b. (a -> b) -> a -> b $ do forall prop. (HasCallStack, Testable prop) => String -> prop -> Spec prop String "tierRefScriptFee is a linear function when growth is 1" forall a b. (a -> b) -> a -> b $ \(Positive Int sizeIncrement) Rational baseFee (NonNegative Int size) -> HasCallStack => Rational -> Int -> Rational -> Int -> Coin tierRefScriptFee Rational 1 Int sizeIncrement Rational baseFee Int size forall a. (Eq a, Show a) => a -> a -> Property === Integer -> Coin Coin (forall a b. (RealFrac a, Integral b) => a -> b floor (forall a b. (Integral a, Num b) => a -> b fromIntegral Int size forall a. Num a => a -> a -> a * Rational baseFee)) forall a. (HasCallStack, Example a) => String -> a -> SpecWith (Arg a) it String "tierRefScriptFee" forall a b. (a -> b) -> a -> b $ do let step :: Int step = Int 25600 forall a b. (a -> b) -> [a] -> [b] map (HasCallStack => Rational -> Int -> Rational -> Int -> Coin tierRefScriptFee Rational 1.5 Int step Rational 15) [Int 0, Int step .. Int 204800] forall a. (HasCallStack, Show a, Eq a) => a -> a -> Expectation `shouldBe` forall a b. (a -> b) -> [a] -> [b] map Integer -> Coin Coin [Integer 0, Integer 384000, Integer 960000, Integer 1824000, Integer 3120000, Integer 5064000, Integer 7980000, Integer 12354000, Integer 18915000]