diff --git a/CHANGELOG.md b/CHANGELOG.md index d17a8209..067fb88a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This format is based on [Keep A Changelog](https://keepachangelog.com/en/1.0.0). - Ability to set custom file where relay node log can be saved after tests run - Ability to set to set custom port for `chain-idex` - Ability to set custom directory for cluster data files + - Ability to set budget multiplier on estimated budget for rare case of incorrect estimation - Default cluster data files delivered via `data-files` package property - Contract execution result returns current contract state for failure cases too - Implementing tasty integration diff --git a/flake.lock b/flake.lock index 189ab5eb..b883baa8 100644 --- a/flake.lock +++ b/flake.lock @@ -79,17 +79,17 @@ "servant-purescript": "servant-purescript" }, "locked": { - "lastModified": 1654632652, - "narHash": "sha256-S4X9lXT2t6dt3c1yc89hJViMiSDmrdYjCCbFNKwZnos=", + "lastModified": 1654259683, + "narHash": "sha256-dWcSVPEttHG5sTbp1IAI8OnpV/4zcTL7p2NIdarGjbg=", "owner": "mlabs-haskell", "repo": "bot-plutus-interface", - "rev": "12b54288155f2a3f4e19b81484adf646e9737ff7", + "rev": "dc7b54a067744faabf90a5fc67ca4068caaec78c", "type": "github" }, "original": { "owner": "mlabs-haskell", "repo": "bot-plutus-interface", - "rev": "12b54288155f2a3f4e19b81484adf646e9737ff7", + "rev": "dc7b54a067744faabf90a5fc67ca4068caaec78c", "type": "github" } }, diff --git a/flake.nix b/flake.nix index b24de24f..ddec839a 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,7 @@ flake = false; }; bot-plutus-interface.url = - "github:mlabs-haskell/bot-plutus-interface?rev=12b54288155f2a3f4e19b81484adf646e9737ff7"; + "github:mlabs-haskell/bot-plutus-interface?rev=dc7b54a067744faabf90a5fc67ca4068caaec78c"; }; outputs = diff --git a/src/Test/Plutip/Config.hs b/src/Test/Plutip/Config.hs index dc3a8496..4b9174a8 100644 --- a/src/Test/Plutip/Config.hs +++ b/src/Test/Plutip/Config.hs @@ -16,8 +16,10 @@ data PlutipConfig = PlutipConfig relayNodeLogs :: Maybe FilePath , -- | in case of `Nothing` port from `Plutus.ChainIndex.Config.defaultConfig` is used chainIndexPort :: Maybe Natural + , -- | Multiplier on all BPI transaction budgets + budgetMultiplier :: Rational } deriving stock (Generic) instance Default PlutipConfig where - def = PlutipConfig Nothing Nothing Nothing + def = PlutipConfig Nothing Nothing Nothing 1 diff --git a/src/Test/Plutip/Internal/BotPlutusInterface/Run.hs b/src/Test/Plutip/Internal/BotPlutusInterface/Run.hs index a7920adb..3b0442dc 100644 --- a/src/Test/Plutip/Internal/BotPlutusInterface/Run.hs +++ b/src/Test/Plutip/Internal/BotPlutusInterface/Run.hs @@ -13,6 +13,7 @@ import BotPlutusInterface.Types ( LogLevel (Error), PABConfig ( PABConfig, + pcBudgetMultiplier, pcChainIndexUrl, pcCliLocation, pcDryRun, @@ -52,7 +53,7 @@ import Plutus.PAB.Core.ContractInstance.STM (Activity (Active)) import Test.Plutip.Internal.BotPlutusInterface.Setup qualified as BIS import Test.Plutip.Internal.BotPlutusInterface.Wallet (BpiWallet (walletPkh)) import Test.Plutip.Internal.Types ( - ClusterEnv (chainIndexUrl, networkId), + ClusterEnv (bpiBudgetMultiplier, chainIndexUrl, networkId), ExecutionResult (ExecutionResult), FailureReason (CaughtException, ContractExecutionError), ) @@ -111,6 +112,7 @@ runContract cEnv bpiWallet contract = do , pcMetadataDir = Text.pack $ BIS.metadataDir cEnv , pcCollectStats = True , pcCollectLogs = True + , pcBudgetMultiplier = bpiBudgetMultiplier cEnv } runContract' :: ContractEnvironment w -> m (ExecutionResult w e a) diff --git a/src/Test/Plutip/Internal/LocalCluster.hs b/src/Test/Plutip/Internal/LocalCluster.hs index 45e3c37f..4ca05338 100644 --- a/src/Test/Plutip/Internal/LocalCluster.hs +++ b/src/Test/Plutip/Internal/LocalCluster.hs @@ -40,6 +40,7 @@ import Test.Plutip.Internal.BotPlutusInterface.Setup qualified as BotSetup import Test.Plutip.Internal.Types ( ClusterEnv ( ClusterEnv, + bpiBudgetMultiplier, chainIndexUrl, networkId, runningNode, @@ -56,7 +57,7 @@ import UnliftIO.STM (TVar, atomically, newTVarIO, readTVar, retrySTM, writeTVar) import Data.Foldable (for_) import GHC.Stack.Types (HasCallStack) import Paths_plutip (getDataFileName) -import Test.Plutip.Config (PlutipConfig (chainIndexPort, clusterDataDir, relayNodeLogs)) +import Test.Plutip.Config (PlutipConfig (budgetMultiplier, chainIndexPort, clusterDataDir, relayNodeLogs)) import Text.Printf (printf) -- | Starting a cluster with a setup action @@ -129,6 +130,7 @@ withPlutusInterface conf action = do , networkId = CAPI.Mainnet , supportDir = dir , tracer = trCluster + , bpiBudgetMultiplier = budgetMultiplier conf } BotSetup.runSetup cEnv -- run preparations to use `bot-plutus-interface` diff --git a/src/Test/Plutip/Internal/Types.hs b/src/Test/Plutip/Internal/Types.hs index d38579be..619fc74f 100644 --- a/src/Test/Plutip/Internal/Types.hs +++ b/src/Test/Plutip/Internal/Types.hs @@ -31,11 +31,12 @@ data ClusterEnv = ClusterEnv -- files created by `cardano-cli`, `chain-index` and `bot-plutus-interface` supportDir :: FilePath , tracer :: Trace IO Text -- not really used anywhere now + , bpiBudgetMultiplier :: Rational } -- | Helper function to get socket path from nodeSocket :: ClusterEnv -> CardanoNodeConn -nodeSocket (ClusterEnv (RunningNode sp _ _) _ _ _ _) = sp +nodeSocket (ClusterEnv (RunningNode sp _ _) _ _ _ _ _) = sp -- | Result of `Contract` execution. Returns contract observable state -- and either `Contract` return value, or error of type `FailureReason`.