Skip to content

Commit

Permalink
added passage of time in the local pact server (#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
qooboodoop authored Dec 9, 2022
1 parent f5066a3 commit 581242e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions pact.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ library
, vector >= 0.11.0.0 && < 0.13
, vector-algorithms >= 0.7
, vector-space >= 0.10.4 && < 0.17
, time

-- GHCJS
if impl(ghcjs)
Expand Down
8 changes: 5 additions & 3 deletions src-ghc/Pact/Server/PactService.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import Pact.Types.Server
import Pact.Types.Pretty (viaShow)
import Pact.Types.PactValue (PactValue)
import Pact.Types.SPV
import Data.Time.Clock.System


initPactService
Expand Down Expand Up @@ -94,14 +95,15 @@ applyCmd _ _ _ _ _ _ _ _ _ _ cmd (ProcFail s) =
Nothing
(cmdToRequestKey cmd)
(PactError TxFailure def def . viaShow $ s)
applyCmd logger conf dbv gasModel bh bt pbh spv exConfig exMode _ (ProcSucc cmd) = do
applyCmd logger conf dbv gasModel bh _ pbh spv exConfig exMode _ (ProcSucc cmd) = do
blocktime <- (((*) 1000000) <$> systemSeconds <$> getSystemTime)

let payload = _cmdPayload cmd
gasEnv = GasEnv (_pmGasLimit pubMeta) (_pmGasPrice pubMeta) gasModel
pd = PublicData pubMeta bh bt pbh
pd = PublicData pubMeta bh blocktime pbh
pubMeta = _pMeta payload
nid = _pNetworkId payload


res <- catchesPactError $ runCommand
(CommandEnv conf exMode dbv logger gasEnv pd spv nid exConfig)
(runPayload cmd)
Expand Down

0 comments on commit 581242e

Please sign in to comment.