@@ -51,11 +51,11 @@ fun test_getPositionsByIDs() {
5151 let details0 = getPositionDetails (pid : 0 , beFailed : false )
5252 let details1 = getPositionDetails (pid : 1 , beFailed : false )
5353
54- Test .assertEqual (details0 .health , details [0 ].health )
55- Test .assertEqual (details0 .balances .length , details [0 ].balances .length )
54+ Test .assertEqual (details0 .health , details [0 ]! .health )
55+ Test .assertEqual (details0 .balances .length , details [0 ]! .balances .length )
5656
57- Test .assertEqual (details1 .health , details [1 ].health )
58- Test .assertEqual (details1 .balances .length , details [1 ].balances .length )
57+ Test .assertEqual (details1 .health , details [1 ]! .health )
58+ Test .assertEqual (details1 .balances .length , details [1 ]! .balances .length )
5959
6060 // --- Empty input returns empty array ---
6161 let emptyDetails = getPositionsByIDs (positionIDs : [])
@@ -64,21 +64,26 @@ fun test_getPositionsByIDs() {
6464 // --- Single ID works ---
6565 let singleDetails = getPositionsByIDs (positionIDs : [UInt64 (0 )])
6666 Test .assertEqual (1 , singleDetails .length )
67- Test .assertEqual (details0 .health , singleDetails [0 ].health )
67+ Test .assertEqual (details0 .health , singleDetails [0 ]! .health )
6868
6969 // --- Closed positions are silently skipped ---
7070 // Close position 1, then request both IDs — should only return position 0
7171 closePosition (user : user , positionID : 1 )
7272 let afterClose = getPositionsByIDs (positionIDs : [UInt64 (0 ), UInt64 (1 )])
73- Test .assertEqual (1 , afterClose .length )
74- Test .assertEqual (details0 .health , afterClose [0 ].health )
73+ Test .assertEqual (2 , afterClose .length )
74+ Test .assertEqual (details0 .health , afterClose [0 ]! .health )
75+ Test .assertEqual (afterClose [1 ], nil )
7576
7677 // --- All IDs closed/invalid returns empty array ---
7778 closePosition (user : user , positionID : 0 )
7879 let allClosed = getPositionsByIDs (positionIDs : [UInt64 (0 ), UInt64 (1 )])
79- Test .assertEqual (0 , allClosed .length )
80+ Test .assertEqual (2 , allClosed .length )
81+ Test .assertEqual (allClosed [0 ], nil )
82+ Test .assertEqual (allClosed [1 ], nil )
8083
8184 // --- Non-existent IDs are skipped ---
8285 let nonExistent = getPositionsByIDs (positionIDs : [UInt64 (999 ), UInt64 (1000 )])
83- Test .assertEqual (0 , nonExistent .length )
86+ Test .assertEqual (2 , nonExistent .length )
87+ Test .assertEqual (nonExistent [0 ], nil )
88+ Test .assertEqual (nonExistent [1 ], nil )
8489}
0 commit comments