Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added passage of time in the local pact server #1082

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
blocktime <- (((*) 1000000) <$> systemSeconds <$> getSystemTime)
blocktime <- (*) 1_000_000 . systemSeconds <$> getSystemTime

This needs to be paired with {-# LANGUAGE NumericUnderscores #-} up top.


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