Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Daml test scrip usageForum ↗

Daml test scrip usage

App Development3 posts173 views1 likesLast activity Apr 2022
BR
brijg11OP
Apr 2022

HI
I am trying to filter out contracts using queryFilter inside a test script

  let
    cancelPredicate = (\swiftOutboundMsg -> case swiftOutboundMsg.swiftMessage of 
      MT548 mt548 -> mt548.status == CAND 
      other -> False)

  swiftTradeConfirmationMsgs <- queryFilter @SwiftOutboundMessage settlementAgent (\t -> (t.swiftMessageType == MT548_buy_t) && (cancelPredicate))

The above code executes with the following error:

h:/work/dtip/src/test/daml/Tests/Syndicate/SwiftReporting.daml:98:130: error:
    • Couldn't match expected type ‘Bool’ with actual type ‘r0 -> Bool’
    • Probable cause: ‘cancelPredicate’ is applied to too few arguments

Is there a better way to achieve this?

CO
cocreature
Apr 2022

cancelPredicate is a function that you need to apply to the swift message. Try something like

swiftTradeConfirmationMsgs <- queryFilter @SwiftOutboundMessage settlementAgent (\t -> (t.swiftMessageType == MT548_buy_t) && (cancelPredicate t))
BR
brijg11
Apr 2022

Thanks. this is cool

← Back to Discussions