Skip to content

Commit

Permalink
Update marlowe-contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
edsko committed Jul 11, 2022
1 parent 88bac28 commit dabf7e6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion marlowe-contracts/test/Spec/Marlowe/Analysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tests = testGroup "Marlowe Contract"
, testCase "Option test" optionTest
]

hasWarnings :: Maybe C.Contract -> IO Bool
hasWarnings :: Maybe (C.Contract Token) -> IO Bool
hasWarnings (Just contract) = do
result <- warningsTrace contract
case result of
Expand Down
34 changes: 17 additions & 17 deletions marlowe-contracts/test/Spec/Marlowe/Contracts.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ tokSymbol = ""
tok :: Token
tok = Token tokSymbol tokName

tokValueOf :: Integer -> C.Money
tokValueOf = singleton tokSymbol tokName
tokValueOf :: Integer -> C.Money Token
tokValueOf = C.moneyFromValue . singleton tokSymbol tokName

assertTotalPayments :: Party -> [C.Payment] -> C.Money -> Assertion
assertTotalPayments :: Party -> [C.Payment Token] -> C.Money Token -> Assertion
assertTotalPayments p t x = assertBool "total payments to party" (totalPayments t == x)
where
totalPayments = mconcat . map (\(C.Payment _ _ a) -> a) . filter (\(C.Payment _ a _) -> a == C.Party p)
Expand All @@ -65,7 +65,7 @@ assertNoWarnings :: [a] -> Assertion
assertNoWarnings [] = pure ()
assertNoWarnings t = assertBool "Assert no warnings" $ null t

assertClose :: C.Contract -> Assertion
assertClose :: C.Contract Token -> Assertion
assertClose = assertBool "Contract is in Close" . (C.Close==)

assertNoFailedTransactions :: C.TransactionError -> Assertion
Expand Down Expand Up @@ -95,7 +95,7 @@ zeroCouponBondTest =
C.TransactionOutput {..} -> do
assertClose txOutContract
assertNoWarnings txOutWarnings
assertTotalPayments w1Pk txOutPayments (lovelaceValueOf 90_000_000)
assertTotalPayments w1Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 90_000_000)
C.Error err ->
assertNoFailedTransactions err

Expand Down Expand Up @@ -124,7 +124,7 @@ couponBondTest =
C.TransactionOutput {..} -> do
assertClose txOutContract
assertNoWarnings txOutWarnings
assertTotalPayments w1Pk txOutPayments (lovelaceValueOf 92_000_000)
assertTotalPayments w1Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 92_000_000)
C.Error err ->
assertNoFailedTransactions err

Expand All @@ -148,8 +148,8 @@ swapContractTest =
C.TransactionOutput {..} -> do
assertClose txOutContract
assertNoWarnings txOutWarnings
assertTotalPayments w1Pk txOutPayments (lovelaceValueOf 10_000_000 <> tokValueOf 30)
assertTotalPayments w2Pk txOutPayments (lovelaceValueOf 10_000_000 <> tokValueOf 30)
assertTotalPayments w1Pk txOutPayments (C.moneyFromValue (lovelaceValueOf 10_000_000) <> tokValueOf 30)
assertTotalPayments w2Pk txOutPayments (C.moneyFromValue (lovelaceValueOf 10_000_000) <> tokValueOf 30)
C.Error err ->
assertNoFailedTransactions err

Expand Down Expand Up @@ -215,7 +215,7 @@ americanCallOptionExercisedTest =
assertClose txOutContract
assertNoWarnings txOutWarnings
assertTotalPayments w1Pk txOutPayments (tokValueOf 30)
assertTotalPayments w2Pk txOutPayments (lovelaceValueOf 10_000_000)
assertTotalPayments w2Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 10_000_000)
C.Error err ->
assertNoFailedTransactions err

Expand Down Expand Up @@ -281,7 +281,7 @@ europeanCallOptionExercisedTest =
assertClose txOutContract
assertNoWarnings txOutWarnings
assertTotalPayments w1Pk txOutPayments (tokValueOf 30)
assertTotalPayments w2Pk txOutPayments (lovelaceValueOf 10_000_000)
assertTotalPayments w2Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 10_000_000)
C.Error err ->
assertNoFailedTransactions err

Expand Down Expand Up @@ -319,8 +319,8 @@ futureNoChange =
C.TransactionOutput {..} -> do
assertClose txOutContract
assertNoWarnings $ filter nonZeroPay txOutWarnings
assertTotalPayments w1Pk txOutPayments (lovelaceValueOf 8_000_000)
assertTotalPayments w2Pk txOutPayments (lovelaceValueOf 8_000_000)
assertTotalPayments w1Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 8_000_000)
assertTotalPayments w2Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 8_000_000)
C.Error err ->
assertNoFailedTransactions err
where
Expand Down Expand Up @@ -355,8 +355,8 @@ futureNoMarginCall =
C.TransactionOutput {..} -> do
assertClose txOutContract
assertNoWarnings txOutWarnings
assertTotalPayments w1Pk txOutPayments (lovelaceValueOf 1_333_333)
assertTotalPayments w2Pk txOutPayments (lovelaceValueOf 14_666_667)
assertTotalPayments w1Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 1_333_333)
assertTotalPayments w2Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 14_666_667)
C.Error err ->
assertNoFailedTransactions err

Expand Down Expand Up @@ -395,8 +395,8 @@ futureWithMarginCall =
C.TransactionOutput {..} -> do
assertClose txOutContract
assertNoWarnings txOutWarnings
assertTotalPayments w1Pk txOutPayments (lovelaceValueOf 61_333_333)
assertTotalPayments w2Pk txOutPayments (lovelaceValueOf 14_666_667)
assertTotalPayments w1Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 61_333_333)
assertTotalPayments w2Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 14_666_667)
C.Error err ->
assertNoFailedTransactions err

Expand Down Expand Up @@ -458,6 +458,6 @@ reverseConvertibleTest =
C.TransactionOutput {..} -> do
assertClose txOutContract
assertNoWarnings txOutWarnings
assertTotalPayments w1Pk txOutPayments (lovelaceValueOf 10_000_000)
assertTotalPayments w1Pk txOutPayments (C.moneyFromValue $ lovelaceValueOf 10_000_000)
C.Error err ->
assertNoFailedTransactions err

0 comments on commit dabf7e6

Please sign in to comment.