@@ -495,6 +495,55 @@ contract('Depot', async function(accounts) {
495
495
) ;
496
496
} ) ;
497
497
498
+ it ( 'is less than one deposit (and that the queue is correctly updated)' , async function ( ) {
499
+ const synthsToDeposit = toUnit ( '500' ) ;
500
+ const ethToSend = toUnit ( '0.5' ) ;
501
+
502
+ // Send the synths to the Token Depot.
503
+ await synth . transferSenderPaysFee ( depot . address , synthsToDeposit , {
504
+ from : depositor ,
505
+ } ) ;
506
+
507
+ const depositStartIndex = await depot . depositStartIndex ( ) ;
508
+ const depositEndIndex = await depot . depositEndIndex ( ) ;
509
+
510
+ // Assert that there is now one deposit in the queue.
511
+ assert . equal ( depositStartIndex , 0 ) ;
512
+ assert . equal ( depositEndIndex , 1 ) ;
513
+
514
+ // And assert that our total has increased by the right amount.
515
+ const totalSellableDeposits = await depot . totalSellableDeposits ( ) ;
516
+ assert . bnEqual ( totalSellableDeposits , synthsToDeposit ) ;
517
+
518
+ assert . bnEqual ( await depot . totalSellableDeposits ( ) , ( await depot . deposits ( 0 ) ) . amount ) ;
519
+
520
+ // Now purchase some.
521
+ const txn = await depot . exchangeEtherForSynths ( {
522
+ from : purchaser ,
523
+ value : ethToSend ,
524
+ } ) ;
525
+
526
+ // Exchange("ETH", msg.value, "sUSD", fulfilled);
527
+ const exchangeEvent = txn . logs . find ( log => log . event === 'Exchange' ) ;
528
+ assert . eventEqual ( exchangeEvent , 'Exchange' , {
529
+ fromCurrency : 'ETH' ,
530
+ fromAmount : ethToSend ,
531
+ toCurrency : 'sUSD' ,
532
+ toAmount : synthsToDeposit . div ( web3 . utils . toBN ( '2' ) ) ,
533
+ } ) ;
534
+
535
+ // We should have one deposit in the queue with half the amount
536
+ assert . equal ( await depot . depositStartIndex ( ) , 0 ) ;
537
+ assert . equal ( await depot . depositEndIndex ( ) , 1 ) ;
538
+
539
+ assert . bnEqual ( await depot . totalSellableDeposits ( ) , ( await depot . deposits ( 0 ) ) . amount ) ;
540
+
541
+ assert . bnEqual (
542
+ await depot . totalSellableDeposits ( ) ,
543
+ synthsToDeposit . div ( web3 . utils . toBN ( '2' ) )
544
+ ) ;
545
+ } ) ;
546
+
498
547
it ( 'exceeds one deposit (and that the queue is correctly updated)' , async function ( ) {
499
548
const synthsToDeposit = web3 . utils . toWei ( '600' ) ;
500
549
const totalSynthsDeposit = web3 . utils . toWei ( '1200' ) ;
0 commit comments