Skip to content

Commit

Permalink
Merge pull request #2076 from kadena-io/push-wwtkwwsprmqu
Browse files Browse the repository at this point in the history
Clean up pollingConfirmationDepthTest a bit more
  • Loading branch information
edmundnoble authored Dec 19, 2024
2 parents b8a87a0 + 9030468 commit 75431e6
Showing 1 changed file with 55 additions and 41 deletions.
96 changes: 55 additions & 41 deletions test/unit/Chainweb/Test/Pact5/RemotePactTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
, LambdaCase
, NumericUnderscores
, OverloadedStrings
, PatternSynonyms
, PackageImports
, ScopedTypeVariables
, TypeApplications
Expand All @@ -20,6 +21,8 @@

-- temporary
{-# options_ghc -Wwarn -fno-warn-name-shadowing -fno-warn-unused-top-binds #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# OPTIONS_GHC -Wno-partial-type-signatures #-}

module Chainweb.Test.Pact5.RemotePactTest
( tests
Expand Down Expand Up @@ -168,48 +171,71 @@ pollingConfirmationDepthTest baseRdb = runResourceT $ do
fixture <- mkFixture v baseRdb
let clientEnv = fixture ^. serviceClientEnv

let trivialTx :: ChainId -> Word -> CmdBuilder
trivialTx cid n = defaultCmd
{ _cbRPC = mkExec' (sshow n)
, _cbSigners =
[ mkEd25519Signer' sender00 []
]
, _cbSender = "sender00"
, _cbChainId = cid
, _cbGasPrice = GasPrice 0.1
, _cbGasLimit = GasLimit (Gas 1_000)
}

liftIO $ do
cmd1 <- buildTextCmd v (trivialTx cid 42)
cmd2 <- buildTextCmd v (trivialTx cid 43)
rks <- sending v cid clientEnv (cmd1 NE.:| [cmd2])
let rks = Pact5.cmdToRequestKey cmd1 NE.:| [Pact5.cmdToRequestKey cmd2]

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, macos-latest, true)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, macos-latest, true)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.10.1, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.10.1, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.6.6, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.6.6, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, true)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 189 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, true)

Not in scope: ‘Pact5.cmdToRequestKey’

let expectSuccessful :: (HasCallStack, _) => P.Prop (HashMap RequestKey (CommandResult _ _))

Check failure on line 191 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, macos-latest, true)

Not in scope: type constructor or class ‘HasCallStack’

Check failure on line 191 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, false)

Not in scope: type constructor or class ‘HasCallStack’

Check failure on line 191 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.10.1, 3.12, ubuntu-22.04, false)

Not in scope: type constructor or class ‘HasCallStack’

Check failure on line 191 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.6.6, 3.12, ubuntu-22.04, false)

Not in scope: type constructor or class ‘HasCallStack’

Check failure on line 191 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, true)

Not in scope: type constructor or class ‘HasCallStack’
expectSuccessful = P.propful ? HM.fromList

Check failure on line 192 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, macos-latest, true)

Not in scope: ‘HM.fromList’

Check failure on line 192 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, false)

Not in scope: ‘HM.fromList’

Check failure on line 192 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.10.1, 3.12, ubuntu-22.04, false)

Not in scope: ‘HM.fromList’

Check failure on line 192 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.6.6, 3.12, ubuntu-22.04, false)

Not in scope: ‘HM.fromList’

Check failure on line 192 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, true)

Not in scope: ‘HM.fromList’
[ (Pact5.cmdToRequestKey cmd1, P.fun _crResult ? P.equals (PactResultOk (PInteger 42)))

Check failure on line 193 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, macos-latest, true)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 193 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 193 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.10.1, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 193 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.6.6, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 193 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, true)

Not in scope: ‘Pact5.cmdToRequestKey’
, (Pact5.cmdToRequestKey cmd2, P.fun _crResult ? P.equals (PactResultOk (PInteger 43)))

Check failure on line 194 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, macos-latest, true)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 194 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 194 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.10.1, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 194 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.6.6, 3.12, ubuntu-22.04, false)

Not in scope: ‘Pact5.cmdToRequestKey’

Check failure on line 194 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, true)

Not in scope: ‘Pact5.cmdToRequestKey’
]
let expectEmpty :: (HasCallStack, _) => _

Check failure on line 196 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, macos-latest, true)

Not in scope: type constructor or class ‘HasCallStack’

Check failure on line 196 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, false)

Not in scope: type constructor or class ‘HasCallStack’

Check failure on line 196 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.10.1, 3.12, ubuntu-22.04, false)

Not in scope: type constructor or class ‘HasCallStack’

Check failure on line 196 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.6.6, 3.12, ubuntu-22.04, false)

Not in scope: type constructor or class ‘HasCallStack’

Check failure on line 196 in test/unit/Chainweb/Test/Pact5/RemotePactTest.hs

View workflow job for this annotation

GitHub Actions / Build (9.8.2, 3.12, ubuntu-22.04, true)

Not in scope: type constructor or class ‘HasCallStack’
expectEmpty = P.equals HashMap.empty

pollingWithDepth v cid clientEnv rks Nothing >>= \response -> do
assertEqual "there are no command results at depth 0" response HashMap.empty
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0)) >>= \response -> do
assertEqual "there are no command results at depth 0" response HashMap.empty
sending v cid clientEnv (cmd1 NE.:| [cmd2])
>>= P.equals rks

pollingWithDepth v cid clientEnv rks Nothing
>>= expectEmpty
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0))
>>= expectEmpty

CutFixture.advanceAllChains_ (fixture ^. cutFixture)

pollingWithDepth v cid clientEnv rks Nothing >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0)) >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 1)) >>= \response -> do
assertEqual "results are not visible at depth 1" 0 (HashMap.size response)
pollingWithDepth v cid clientEnv rks Nothing
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0))
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 1))
>>= expectEmpty

CutFixture.advanceAllChains_ (fixture ^. cutFixture)

pollingWithDepth v cid clientEnv rks Nothing >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0)) >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 1)) >>= \response -> do
assertEqual "results are visible at depth 1" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 2)) >>= \response -> do
assertEqual "results are not visible at depth 2" 0 (HashMap.size response)
pollingWithDepth v cid clientEnv rks Nothing
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0))
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 1))
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 2))
>>= expectEmpty

CutFixture.advanceAllChains_ (fixture ^. cutFixture)

pollingWithDepth v cid clientEnv rks Nothing >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0)) >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 1)) >>= \response -> do
assertEqual "results are visible at depth 1" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 2)) >>= \response -> do
assertEqual "results are visible at depth 2" 2 (HashMap.size response)
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 3)) >>= \response -> do
assertEqual "results are not visible at depth 3" 0 (HashMap.size response)
pollingWithDepth v cid clientEnv rks Nothing
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0))
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 1))
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 2))
>>= expectSuccessful
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 3))
>>= expectEmpty

return ()

Expand Down Expand Up @@ -546,18 +572,6 @@ toPact4Command cmd4 = case Aeson.eitherDecodeStrictText (J.encodeText cmd4) of
Left err -> error $ "toPact4Command: decode failed: " ++ err
Right cmd5 -> cmd5

trivialTx :: ChainId -> Word -> CmdBuilder
trivialTx cid n = defaultCmd
{ _cbRPC = mkExec' (sshow n)
, _cbSigners =
[ mkEd25519Signer' sender00 []
]
, _cbSender = "sender00"
, _cbChainId = cid
, _cbGasPrice = GasPrice 0.1
, _cbGasLimit = GasLimit (Gas 1_000)
}

_successfulTx :: P.Prop (CommandResult log err)
_successfulTx = P.fun _crResult ? P.match _PactResultOk P.succeed

Expand Down

0 comments on commit 75431e6

Please sign in to comment.