Skip to content

Commit

Permalink
Remove the version argument from advanceAllChains
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundnoble committed Dec 18, 2024
1 parent 9e19bd6 commit ab1788c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
13 changes: 6 additions & 7 deletions test/unit/Chainweb/Test/Pact5/CutFixture.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,18 @@ mkFixture v pactServiceConfig baseRdb = do
, _fixtureMempools = OnChains $ fst <$> perChain
, _fixturePactQueues = OnChains $ snd <$> perChain
}
_ <- liftIO $ advanceAllChains v fixture
_ <- liftIO $ advanceAllChains fixture
return fixture

-- | Advance all chains by one block, filling that block with whatever is in
-- their mempools at the time.
--
advanceAllChains
:: HasCallStack
=> ChainwebVersion
-> Fixture
=> Fixture
-> IO (Cut, ChainMap (Vector (CommandResult Pact5.Hash Text)))
advanceAllChains v Fixture{..} = do
advanceAllChains Fixture{..} = do
let v = _chainwebVersion _fixtureCutDb
latestCut <- liftIO $ _fixtureCutDb ^. cut
let blockHeights = fmap (view blockHeight) $ latestCut ^. cutMap
let latestBlockHeight = maximum blockHeights
Expand All @@ -149,10 +149,9 @@ advanceAllChains v Fixture{..} = do

advanceAllChains_
:: HasCallStack
=> ChainwebVersion
-> Fixture
=> Fixture
-> IO ()
advanceAllChains_ v f = void $ advanceAllChains v f
advanceAllChains_ f = void $ advanceAllChains f

withTestCutDb :: (Logger logger)
=> logger
Expand Down
12 changes: 6 additions & 6 deletions test/unit/Chainweb/Test/Pact5/RemotePactTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pollingConfirmationDepthTest baseRdb = runResourceT $ do
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 0)) >>= \response -> do
assertEqual "there are no command results at depth 0" response HashMap.empty

CutFixture.advanceAllChains_ v (fixture ^. cutFixture)
CutFixture.advanceAllChains_ (fixture ^. cutFixture)

pollingWithDepth v cid clientEnv rks Nothing >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
Expand All @@ -180,7 +180,7 @@ pollingConfirmationDepthTest baseRdb = runResourceT $ do
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 1)) >>= \response -> do
assertEqual "results are not visible at depth 1" 0 (HashMap.size response)

CutFixture.advanceAllChains_ v (fixture ^. cutFixture)
CutFixture.advanceAllChains_ (fixture ^. cutFixture)

pollingWithDepth v cid clientEnv rks Nothing >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
Expand All @@ -191,7 +191,7 @@ pollingConfirmationDepthTest baseRdb = runResourceT $ do
pollingWithDepth v cid clientEnv rks (Just (ConfirmationDepth 2)) >>= \response -> do
assertEqual "results are not visible at depth 2" 0 (HashMap.size response)

CutFixture.advanceAllChains_ v (fixture ^. cutFixture)
CutFixture.advanceAllChains_ (fixture ^. cutFixture)

pollingWithDepth v cid clientEnv rks Nothing >>= \response -> do
assertEqual "results are visible at depth 0" 2 (HashMap.size response)
Expand Down Expand Up @@ -236,12 +236,12 @@ spvTest baseRdb = runResourceT $ do
$ defaultCmd

sendReqKey <- fmap NE.head $ sending v srcChain clientEnv (NE.singleton send)
(sendCut, _) <- CutFixture.advanceAllChains v (fixture ^. cutFixture)
(sendCut, _) <- CutFixture.advanceAllChains (fixture ^. cutFixture)
sendCr <- fmap (HashMap.! sendReqKey) $ pollingWithDepth v srcChain clientEnv (NE.singleton sendReqKey) (Just (ConfirmationDepth 0))
let cont = fromMaybe (error "missing continuation") (_crContinuation sendCr)

_ <- replicateM_ 10 $ do
CutFixture.advanceAllChains v (fixture ^. cutFixture)
CutFixture.advanceAllChains (fixture ^. cutFixture)
let sendHeight = sendCut ^?! ixg srcChain . blockHeight
spvProof <- createTransactionOutputProof_ (fixture ^. cutFixture . CutFixture.fixtureWebBlockHeaderDb) (fixture ^. cutFixture . CutFixture.fixturePayloadDb) targetChain srcChain sendHeight 0
let contMsg = ContMsg
Expand All @@ -264,7 +264,7 @@ spvTest baseRdb = runResourceT $ do
$ set cbGasLimit (GasLimit (Gas 1_000))
$ defaultCmd
recvReqKey <- fmap NE.head $ sending v targetChain clientEnv (NE.singleton recv)
_ <- CutFixture.advanceAllChains v (fixture ^. cutFixture)
_ <- CutFixture.advanceAllChains (fixture ^. cutFixture)
recvCr <- fmap (HashMap.! recvReqKey) $ polling v targetChain clientEnv (NE.singleton recvReqKey)
recvCr
& P.allTrue
Expand Down

0 comments on commit ab1788c

Please sign in to comment.