Skip to content
CCPEDIAby Unity Nodes
App Development

Daml test scrip usage

3 posts194 views1 likesLast activity Apr 2022

  1. brijg11OP

    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?

  2. cocreature

    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))
    
  3. brijg11 1

    Thanks. this is cool