File tree 1 file changed +41
-0
lines changed
1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,47 @@ describe('nomatching OrderBook', () => {
210
210
expect ( ( ) => orderBook [ 'removeOwnOrder' ] ( remainingOrder ! . id , order . pairId , 1 ) ) . to . throw ;
211
211
} ) ;
212
212
213
+ describe ( 'stampOwnOrder' , ( ) => {
214
+ const ownOrder = ( ) => {
215
+ return {
216
+ pairId : 'LTC/BTC' ,
217
+ price : 0.008 ,
218
+ quantity : 0.00001 ,
219
+ isBuy : false ,
220
+ localId : '' ,
221
+ hold : 0 ,
222
+ } ;
223
+ } ;
224
+
225
+ it ( 'has the same id and localId when localId not provided' , async ( ) => {
226
+ const stampedOrder = orderBook [ 'stampOwnOrder' ] ( ownOrder ( ) ) ;
227
+ expect ( stampedOrder . id ) . to . equal ( stampedOrder . localId ) ;
228
+ } ) ;
229
+
230
+ it ( 'does not have the same id and localId when localId provided' , async ( ) => {
231
+ const ownOrderWithLocalId = {
232
+ ...ownOrder ( ) ,
233
+ localId : uuidv1 ( ) ,
234
+ } ;
235
+ const stampedOrder = orderBook [ 'stampOwnOrder' ] ( ownOrderWithLocalId ) ;
236
+ expect ( stampedOrder . id ) . to . not . equal ( stampedOrder . localId ) ;
237
+ } ) ;
238
+
239
+ it ( 'throws an error when duplicate localId exists' , async ( ) => {
240
+ const ownOrderWithLocalId = {
241
+ ...ownOrder ( ) ,
242
+ localId : uuidv1 ( ) ,
243
+ } ;
244
+ orderBook [ 'localIdMap' ] . set ( ownOrderWithLocalId . localId , {
245
+ id : ownOrderWithLocalId . localId ,
246
+ pairId : ownOrderWithLocalId . pairId ,
247
+ } ) ;
248
+ expect ( ( ) => orderBook [ 'stampOwnOrder' ] ( ownOrderWithLocalId ) )
249
+ . to . throw ( `order with local id ${ ownOrderWithLocalId . localId } already exists` ) ;
250
+ } ) ;
251
+
252
+ } ) ;
253
+
213
254
after ( async ( ) => {
214
255
await db . close ( ) ;
215
256
} ) ;
You can’t perform that action at this time.
0 commit comments