@@ -1420,7 +1420,7 @@ describe('unpublish...order()', () => {
14201420} ) ;
14211421
14221422describe ( 'estimateMatchOrders()' , ( ) => {
1423- test ( 'estimates the total cost' , async ( ) => {
1423+ test ( 'estimates the total cost and volume ' , async ( ) => {
14241424 const noVoucherTestChain = TEST_CHAINS [ 'custom-token-chain' ] ;
14251425 const options = {
14261426 resultProxyURL : 'https://result-proxy.iex.ec' ,
@@ -1467,6 +1467,8 @@ describe('estimateMatchOrders()', () => {
14671467 expect ( res . sponsored ) . toEqual ( new BN ( 0 ) ) ;
14681468 expect ( res . total ) . toBeInstanceOf ( BN ) ;
14691469 expect ( res . total ) . toEqual ( new BN ( 35 ) ) ;
1470+ expect ( res . volume ) . toBeInstanceOf ( BN ) ;
1471+ expect ( res . volume ) . toEqual ( new BN ( 5 ) ) ;
14701472 } ) ;
14711473
14721474 describe ( 'with useVoucher' , ( ) => {
@@ -1475,6 +1477,7 @@ describe('estimateMatchOrders()', () => {
14751477 let datasetorderTemplate ;
14761478 let workerpoolorderTemplate ;
14771479 let voucherTypeId ;
1480+ let matchableVolume ;
14781481 let expectedTotal ;
14791482
14801483 beforeAll ( async ( ) => {
@@ -1493,7 +1496,7 @@ describe('estimateMatchOrders()', () => {
14931496 { volume : 5 , workerpoolprice : 1 } ,
14941497 ) ;
14951498
1496- const matchableVolume = new BN ( 5 ) ; // min volume among orders
1499+ matchableVolume = new BN ( 5 ) ; // min volume among orders
14971500 expectedTotal = new BN ( 5 + 1 + 1 ) . mul ( matchableVolume ) ; // volume * orders unit prices
14981501
14991502 voucherTypeId = await createVoucherType ( iexecTestChain ) ( {
@@ -1581,6 +1584,8 @@ describe('estimateMatchOrders()', () => {
15811584 expect ( res . sponsored ) . toEqual ( new BN ( 0 ) ) ;
15821585 expect ( res . total ) . toBeInstanceOf ( BN ) ;
15831586 expect ( res . total ) . toEqual ( new BN ( 35 ) ) ;
1587+ expect ( res . volume ) . toBeInstanceOf ( BN ) ;
1588+ expect ( res . volume ) . toEqual ( new BN ( 5 ) ) ;
15841589 } ) ;
15851590
15861591 test ( 'should have sponsored amount as 0 when useVoucher is false' , async ( ) => {
@@ -1613,6 +1618,8 @@ describe('estimateMatchOrders()', () => {
16131618 expect ( res . sponsored ) . toEqual ( new BN ( 0 ) ) ;
16141619 expect ( res . total ) . toBeInstanceOf ( BN ) ;
16151620 expect ( res . total ) . toEqual ( expectedTotal ) ;
1621+ expect ( res . volume ) . toBeInstanceOf ( BN ) ;
1622+ expect ( res . volume ) . toEqual ( matchableVolume ) ;
16161623 } ) ;
16171624
16181625 test ( 'should return total cost and sponsored amount when using voucher' , async ( ) => {
@@ -1647,6 +1654,8 @@ describe('estimateMatchOrders()', () => {
16471654 expect ( res . sponsored ) . toEqual ( expectedTotal ) ;
16481655 expect ( res . total ) . toBeInstanceOf ( BN ) ;
16491656 expect ( res . total ) . toEqual ( expectedTotal ) ;
1657+ expect ( res . volume ) . toBeInstanceOf ( BN ) ;
1658+ expect ( res . volume ) . toEqual ( matchableVolume ) ;
16501659 } ) ;
16511660
16521661 test ( 'should return sponsored amount equal to voucher balance when voucher value is less than total cost' , async ( ) => {
@@ -1684,6 +1693,8 @@ describe('estimateMatchOrders()', () => {
16841693 expect ( res . sponsored ) . toEqual ( new BN ( voucherInfo . balance ) ) ;
16851694 expect ( res . total ) . toBeInstanceOf ( BN ) ;
16861695 expect ( res . total ) . toEqual ( expectedTotal ) ;
1696+ expect ( res . volume ) . toBeInstanceOf ( BN ) ;
1697+ expect ( res . volume ) . toEqual ( matchableVolume ) ;
16871698 } ) ;
16881699
16891700 test ( 'should have sponsored amount as 0 when voucher expired' , async ( ) => {
@@ -1718,6 +1729,8 @@ describe('estimateMatchOrders()', () => {
17181729 expect ( res . sponsored ) . toEqual ( new BN ( 0 ) ) ;
17191730 expect ( res . total ) . toBeInstanceOf ( BN ) ;
17201731 expect ( res . total ) . toEqual ( expectedTotal ) ;
1732+ expect ( res . volume ) . toBeInstanceOf ( BN ) ;
1733+ expect ( res . volume ) . toEqual ( matchableVolume ) ;
17211734 } ) ;
17221735
17231736 describe ( 'with custom voucherAddress option' , ( ) => {
@@ -1763,6 +1776,8 @@ describe('estimateMatchOrders()', () => {
17631776 expect ( res . sponsored ) . toEqual ( expectedTotal ) ;
17641777 expect ( res . total ) . toBeInstanceOf ( BN ) ;
17651778 expect ( res . total ) . toEqual ( expectedTotal ) ;
1779+ expect ( res . volume ) . toBeInstanceOf ( BN ) ;
1780+ expect ( res . volume ) . toEqual ( matchableVolume ) ;
17661781 } ) ;
17671782
17681783 test ( 'should throw if specified voucherAddress is not a voucher' , async ( ) => {
0 commit comments