Skip to content

Commit 4d59532

Browse files
Address comments
1 parent e3becb6 commit 4d59532

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/BotPlutusInterface/Contract.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ handlePABReq contractEnv req = do
135135
ChainIndexQueryReq query ->
136136
ChainIndexQueryResp <$> queryChainIndex @w query
137137
BalanceTxReq unbalancedTx ->
138-
BalanceTxResp <$> balanceTxStep @w contractEnv unbalancedTx
138+
BalanceTxResp <$> balanceTx @w contractEnv unbalancedTx
139139
WriteBalancedTxReq tx ->
140140
WriteBalancedTxResp <$> writeBalancedTx @w contractEnv tx
141141
AwaitSlotReq s -> AwaitSlotResp <$> awaitSlot @w contractEnv s
@@ -162,14 +162,14 @@ handlePABReq contractEnv req = do
162162
printLog @w Debug $ show resp
163163
pure resp
164164

165-
-- | This is not identical to the real balancing, we only do a pre-balance at this stage
166-
balanceTxStep ::
165+
-- | This will FULLY balance a transaction
166+
balanceTx ::
167167
forall (w :: Type) (effs :: [Type -> Type]).
168168
Member (PABEffect w) effs =>
169169
ContractEnvironment w ->
170170
UnbalancedTx ->
171171
Eff effs BalanceTxResponse
172-
balanceTxStep contractEnv unbalancedTx = do
172+
balanceTx contractEnv unbalancedTx = do
173173
eitherPreBalancedTx <-
174174
PreBalance.balanceTxIO @w
175175
contractEnv.cePABConfig

test/Spec/BotPlutusInterface/Contract.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Cardano.Api (NetworkId (Mainnet))
88
import Control.Lens (ix, (&), (.~), (^.), (^?))
99
import Data.Aeson (ToJSON)
1010
import Data.Aeson.Extras (encodeByteString)
11+
import Data.Char (isSpace)
1112
import Data.Default (def)
1213
import Data.Function (on)
1314
import Data.Kind (Type)
@@ -892,7 +893,7 @@ assertCommandHistory state =
892893
( \(idx, expectedCmd) ->
893894
assertCommandEqual
894895
("command at index " ++ show idx ++ " was incorrect:")
895-
(Text.replace "\n" " " expectedCmd)
896+
expectedCmd
896897
(fromMaybe "" $ state ^? commandHistory . ix idx)
897898
)
898899

@@ -908,8 +909,8 @@ commandEqual _ "" = False
908909
commandEqual expected actual = maybe False (on commandEqual dropToSpace postExp) mPostAct
909910
where
910911
(preExp, postExp) = Text.breakOn "?" expected
911-
mPostAct = Text.stripPrefix preExp actual
912-
dropToSpace = Text.dropWhile (/= ' ')
912+
mPostAct = Text.stripPrefix (Text.replace "\n" " " preExp) actual
913+
dropToSpace = Text.dropWhile (not . isSpace)
913914

914915
assertCommandCalled :: forall (w :: Type). MockContractState w -> Text -> Assertion
915916
assertCommandCalled state expectedCmd =

0 commit comments

Comments
 (0)