Skip to content
Snippets Groups Projects
Unverified Commit d7ba9ffd authored by Jean-Paul Calderone's avatar Jean-Paul Calderone
Browse files

Test concurrent payment too, just to be sure

Still not testing the web code path but ... types and stuff!@
parent 5e98b666
No related branches found
No related tags found
1 merge request!46Fix "cannot start a transaction within a transaction" during concurrent redemption
...@@ -125,6 +125,19 @@ makeVoucherPaymentTests label makeDatabase = ...@@ -125,6 +125,19 @@ makeVoucherPaymentTests label makeDatabase =
assertEqual "double-paying for a voucher" (Left AlreadyPaid) payResult assertEqual "double-paying for a voucher" (Left AlreadyPaid) payResult
redeemResult <- redeemVoucher conn voucher fingerprint redeemResult <- redeemVoucher conn voucher fingerprint
assertEqual "redeeming double-paid voucher" (Right ()) redeemResult assertEqual "redeeming double-paid voucher" (Right ()) redeemResult
, testCase "concurrent payment" $ do
connect <- makeDatabase
connA <- connect
connB <- connect
let payment = payForVoucher connA voucher paySuccessfully
let anotherPayment = payForVoucher connB anotherVoucher paySuccessfully
result <- withAsync payment $ \p1 -> do
withAsync anotherPayment $ \p2 -> do
waitBoth p1 p2
assertEqual "Both payments should succeed" ((), ()) result
, testCase "concurrent redemption" $ do , testCase "concurrent redemption" $ do
connect <- makeDatabase connect <- makeDatabase
connA <- connect connA <- connect
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment