@@ -298,6 +298,33 @@ describe('Iota Transfer Builder', () => {
298298 should . equal ( tx . type , TransactionType . Send ) ;
299299 tx . paymentObjects ?. length . should . equal ( 2 ) ;
300300 } ) ;
301+
302+ it ( 'should accept empty payment objects array and use gas objects for payment in non-sponsor mode' , async function ( ) {
303+ const builder = factory
304+ . getTransferBuilder ( )
305+ . sender ( testData . sender . address )
306+ . recipients ( testData . recipients )
307+ . paymentObjects ( [ ] )
308+ . gasData ( testData . gasData ) ;
309+
310+ const tx = ( await builder . build ( ) ) as TransferTransaction ;
311+ should . equal ( tx . type , TransactionType . Send ) ;
312+ should . equal ( tx . isSimulateTx , false ) ;
313+ should . equal ( tx . sender , testData . sender . address ) ;
314+ await assertValidRawTransaction ( tx ) ;
315+ } ) ;
316+
317+ it ( 'should fail tx building in case of empty payment objects in sponsor mode' , async function ( ) {
318+ const builder = factory
319+ . getTransferBuilder ( )
320+ . sender ( testData . sender . address )
321+ . gasSponsor ( testData . gasSponsor . address )
322+ . recipients ( testData . recipients )
323+ . paymentObjects ( [ ] )
324+ . gasData ( testData . gasData ) ;
325+
326+ await builder . build ( ) . should . be . rejectedWith ( / P a y m e n t o b j e c t s a r e r e q u i r e d w h e n u s i n g a g a s s p o n s o r / ) ;
327+ } ) ;
301328 } ) ;
302329
303330 describe ( 'Validation Errors' , ( ) => {
@@ -380,9 +407,9 @@ describe('Iota Transfer Builder', () => {
380407 await builder . build ( ) . should . be . rejected ( ) ;
381408 } ) ;
382409
383- it ( 'should fail for empty payment objects' , function ( ) {
410+ it ( 'should allow empty payment objects' , function ( ) {
384411 const builder = createBasicTransferBuilder ( ) ;
385- should ( ( ) => builder . paymentObjects ( [ ] ) ) . throwError ( 'No Objects provided for payment' ) ;
412+ should . doesNotThrow ( ( ) => builder . paymentObjects ( [ ] ) ) ;
386413 } ) ;
387414
388415 it ( 'should fail without payment objects when using gas sponsor' , async function ( ) {
0 commit comments