@@ -349,6 +349,24 @@ contract("{Set}", (accounts) => {
349
349
assertTokenBalance ( setToken , new BigNumber ( 0 ) , testAccount ) ;
350
350
} ) ;
351
351
352
+ it ( `should work with sequential redeems` , async ( ) => {
353
+ const halfAmount = standardQuantityIssued . div ( new BigNumber ( 2 ) ) ;
354
+ await setToken . redeem ( halfAmount , TX_DEFAULTS ) ;
355
+
356
+ const [ component1 , component2 ] = components ;
357
+ const [ quantity1 , quantity2 ] = quantitiesToTransfer ;
358
+
359
+ assertTokenBalance ( component1 , initialTokens . sub ( quantity1 . div ( 2 ) ) , testAccount ) ;
360
+ assertTokenBalance ( component2 , initialTokens . sub ( quantity2 . div ( 2 ) ) , testAccount ) ;
361
+ assertTokenBalance ( setToken , standardQuantityIssued . div ( 2 ) , testAccount ) ;
362
+
363
+ await setToken . redeem ( halfAmount , TX_DEFAULTS ) ;
364
+
365
+ assertTokenBalance ( component1 , initialTokens , testAccount ) ;
366
+ assertTokenBalance ( component2 , initialTokens , testAccount ) ;
367
+ assertTokenBalance ( setToken , new BigNumber ( 0 ) , testAccount ) ;
368
+ } ) ;
369
+
352
370
it ( `should throw if the user does not have sufficient balance` , async ( ) => {
353
371
const largeAmount = initialTokens . mul ( initialTokens ) ;
354
372
await expectRevertError ( setToken . redeem ( largeAmount , TX_DEFAULTS ) ) ;
@@ -496,29 +514,29 @@ contract("{Set}", (accounts) => {
496
514
} ) ;
497
515
498
516
describe ( "Redeem Excluded" , async ( ) => {
499
- let componentExcluded : any ;
500
- let componentAddressExcluded : Address ;
517
+ describe ( `of Standard Set with a single component partial redeemed` , ( ) => {
518
+ let componentExcluded : any ;
519
+ let componentAddressExcluded : Address [ ] ;
501
520
502
- describe ( `of Standard Set` , ( ) => {
503
521
beforeEach ( async ( ) => {
504
522
await deployStandardSetAndIssue ( 3 , standardQuantityIssued ) ;
505
523
componentExcluded = components [ 0 ] ;
506
- componentAddressExcluded = componentAddresses [ 0 ] ;
524
+ componentAddressExcluded = [ componentAddresses [ 0 ] ] ;
507
525
508
- await setToken . partialRedeem ( standardQuantityIssued , [ componentAddressExcluded ] , TX_DEFAULTS ) ;
526
+ await setToken . partialRedeem ( standardQuantityIssued , componentAddressExcluded , TX_DEFAULTS ) ;
509
527
} ) ;
510
528
511
529
it ( "should work" , async ( ) => {
512
530
const redeemExcludedReceipt = await setToken . redeemExcluded (
513
- [ componentAddressExcluded ] ,
531
+ componentAddressExcluded ,
514
532
[ quantitiesToTransfer [ 0 ] ] ,
515
533
TX_DEFAULTS ,
516
534
) ;
517
535
518
536
const { logs } = redeemExcludedReceipt ;
519
537
const formattedLogs = _ . map ( logs , ( log ) => extractLogEventAndArgs ( log ) ) ;
520
538
const expectedLogs = getExpectedRedeemExcludedLogs (
521
- [ componentAddressExcluded ] ,
539
+ componentAddressExcluded ,
522
540
[ quantitiesToTransfer [ 0 ] ] ,
523
541
setToken . address ,
524
542
testAccount ,
@@ -541,5 +559,50 @@ contract("{Set}", (accounts) => {
541
559
) ) ;
542
560
} ) ;
543
561
} ) ;
562
+
563
+ describe ( `of Standard Set with a multiple components partial redeemed` , ( ) => {
564
+ let componentsExcluded : any [ ] ;
565
+ let componentAddressesExcluded : Address [ ] ;
566
+
567
+ beforeEach ( async ( ) => {
568
+ await deployStandardSetAndIssue ( 3 , standardQuantityIssued ) ;
569
+ componentsExcluded = [ components [ 0 ] , components [ 1 ] ] ;
570
+ componentAddressesExcluded = [ componentAddresses [ 0 ] , componentAddresses [ 1 ] ] ;
571
+
572
+ await setToken . partialRedeem ( standardQuantityIssued , componentAddressesExcluded , TX_DEFAULTS ) ;
573
+ } ) ;
574
+
575
+ it ( "should work when redeem excluding multiple tokens" , async ( ) => {
576
+ const redeemExcludedReceipt = await setToken . redeemExcluded (
577
+ componentAddressesExcluded ,
578
+ [ quantitiesToTransfer [ 0 ] , quantitiesToTransfer [ 1 ] ] ,
579
+ TX_DEFAULTS ,
580
+ ) ;
581
+
582
+ const { logs } = redeemExcludedReceipt ;
583
+ const formattedLogs = _ . map ( logs , ( log ) => extractLogEventAndArgs ( log ) ) ;
584
+ const expectedLogs = getExpectedRedeemExcludedLogs (
585
+ componentAddressesExcluded ,
586
+ [ quantitiesToTransfer [ 0 ] , quantitiesToTransfer [ 1 ] ] ,
587
+ setToken . address ,
588
+ testAccount ,
589
+ ) ;
590
+
591
+ expect ( JSON . stringify ( formattedLogs ) ) . to . equal ( JSON . stringify ( expectedLogs ) ) ;
592
+ const [ excludedBalance1ofOwner ] = await setToken . unredeemedComponents (
593
+ componentAddressesExcluded [ 0 ] ,
594
+ testAccount ,
595
+ ) ;
596
+ expect ( excludedBalance1ofOwner ) . to . be . bignumber . equal ( 0 ) ;
597
+ assertTokenBalance ( componentsExcluded [ 0 ] , initialTokens , testAccount ) ;
598
+
599
+ const [ excludedBalance2ofOwner ] = await setToken . unredeemedComponents (
600
+ componentAddressesExcluded [ 1 ] ,
601
+ testAccount ,
602
+ ) ;
603
+ expect ( excludedBalance2ofOwner ) . to . be . bignumber . equal ( 0 ) ;
604
+ assertTokenBalance ( componentsExcluded [ 1 ] , initialTokens , testAccount ) ;
605
+ } ) ;
606
+ } ) ;
544
607
} ) ;
545
608
} ) ;
0 commit comments