@@ -355,6 +355,41 @@ describe('BlendProtocol - Operations Tests', () => {
355355 blendProtocol . supply ( testAddress , testPrivateKey , invalidAsset , '1000000' )
356356 ) . rejects . toThrow ( 'Invalid asset' ) ;
357357 } ) ;
358+
359+ it ( 'should return pending transaction when privateKey is not provided' , async ( ) => {
360+ // Mock transaction builder
361+ const mockTx = {
362+ toXDR : jest . fn ( ( ) => 'mocked-xdr' )
363+ } ;
364+ ( TransactionBuilder as jest . MockedClass < typeof TransactionBuilder > ) . mockImplementation (
365+ ( ) =>
366+ ( {
367+ addOperation : jest . fn ( ) . mockReturnThis ( ) ,
368+ setTimeout : jest . fn ( ) . mockReturnThis ( ) ,
369+ build : jest . fn ( ( ) => mockTx )
370+ } as any )
371+ ) ;
372+
373+ // Mock simulation success
374+ const mockSimulation = {
375+ result : { mock : 'result' }
376+ } ;
377+ mockSorobanServer . simulateTransaction = jest
378+ . fn ( )
379+ . mockResolvedValue ( mockSimulation ) ;
380+ ( rpc . Api . isSimulationError as jest . Mock ) . mockReturnValue ( false ) ;
381+
382+ // Mock prepareTransaction
383+ const mockPreparedTx = {
384+ toXDR : jest . fn ( ( ) => 'prepared-xdr' )
385+ } ;
386+ mockSorobanServer . prepareTransaction = jest . fn ( ) . mockResolvedValue ( mockPreparedTx ) ;
387+
388+ const result = await blendProtocol . supply ( testAddress , null as any , testAsset , '1000000' ) ;
389+
390+ expect ( result . status ) . toBe ( 'pending' ) ;
391+ expect ( mockSorobanServer . prepareTransaction ) . toHaveBeenCalled ( ) ;
392+ } ) ;
358393 } ) ;
359394
360395 // ========================================
@@ -550,6 +585,41 @@ describe('BlendProtocol - Operations Tests', () => {
550585 blendProtocol . withdraw ( testAddress , testPrivateKey , invalidAsset , '500000' )
551586 ) . rejects . toThrow ( 'Invalid asset' ) ;
552587 } ) ;
588+
589+ it ( 'should return pending transaction when privateKey is not provided' , async ( ) => {
590+ // Mock transaction builder
591+ const mockTx = {
592+ toXDR : jest . fn ( ( ) => 'mocked-xdr' )
593+ } ;
594+ ( TransactionBuilder as jest . MockedClass < typeof TransactionBuilder > ) . mockImplementation (
595+ ( ) =>
596+ ( {
597+ addOperation : jest . fn ( ) . mockReturnThis ( ) ,
598+ setTimeout : jest . fn ( ) . mockReturnThis ( ) ,
599+ build : jest . fn ( ( ) => mockTx )
600+ } as any )
601+ ) ;
602+
603+ // Mock simulation success
604+ const mockSimulation = {
605+ result : { mock : 'result' }
606+ } ;
607+ mockSorobanServer . simulateTransaction = jest
608+ . fn ( )
609+ . mockResolvedValue ( mockSimulation ) ;
610+ ( rpc . Api . isSimulationError as jest . Mock ) . mockReturnValue ( false ) ;
611+
612+ // Mock prepareTransaction
613+ const mockPreparedTx = {
614+ toXDR : jest . fn ( ( ) => 'prepared-xdr' )
615+ } ;
616+ mockSorobanServer . prepareTransaction = jest . fn ( ) . mockResolvedValue ( mockPreparedTx ) ;
617+
618+ const result = await blendProtocol . withdraw ( testAddress , null as any , testAsset , '500000' ) ;
619+
620+ expect ( result . status ) . toBe ( 'pending' ) ;
621+ expect ( mockSorobanServer . prepareTransaction ) . toHaveBeenCalled ( ) ;
622+ } ) ;
553623 } ) ;
554624
555625 // ========================================
@@ -682,6 +752,41 @@ describe('BlendProtocol - Operations Tests', () => {
682752 blendProtocol . borrow ( testAddress , testPrivateKey , invalidAsset , '250000' )
683753 ) . rejects . toThrow ( 'Invalid asset' ) ;
684754 } ) ;
755+
756+ it ( 'should return pending transaction when privateKey is not provided' , async ( ) => {
757+ // Mock transaction builder
758+ const mockTx = {
759+ toXDR : jest . fn ( ( ) => 'mocked-xdr' )
760+ } ;
761+ ( TransactionBuilder as jest . MockedClass < typeof TransactionBuilder > ) . mockImplementation (
762+ ( ) =>
763+ ( {
764+ addOperation : jest . fn ( ) . mockReturnThis ( ) ,
765+ setTimeout : jest . fn ( ) . mockReturnThis ( ) ,
766+ build : jest . fn ( ( ) => mockTx )
767+ } as any )
768+ ) ;
769+
770+ // Mock simulation success
771+ const mockSimulation = {
772+ result : { mock : 'result' }
773+ } ;
774+ mockSorobanServer . simulateTransaction = jest
775+ . fn ( )
776+ . mockResolvedValue ( mockSimulation ) ;
777+ ( rpc . Api . isSimulationError as jest . Mock ) . mockReturnValue ( false ) ;
778+
779+ // Mock prepareTransaction
780+ const mockPreparedTx = {
781+ toXDR : jest . fn ( ( ) => 'prepared-xdr' )
782+ } ;
783+ mockSorobanServer . prepareTransaction = jest . fn ( ) . mockResolvedValue ( mockPreparedTx ) ;
784+
785+ const result = await blendProtocol . borrow ( testAddress , null as any , testAsset , '250000' ) ;
786+
787+ expect ( result . status ) . toBe ( 'pending' ) ;
788+ expect ( mockSorobanServer . prepareTransaction ) . toHaveBeenCalled ( ) ;
789+ } ) ;
685790 } ) ;
686791
687792 // ========================================
@@ -814,6 +919,41 @@ describe('BlendProtocol - Operations Tests', () => {
814919 blendProtocol . repay ( testAddress , testPrivateKey , invalidAsset , '250000' )
815920 ) . rejects . toThrow ( 'Invalid asset' ) ;
816921 } ) ;
922+
923+ it ( 'should return pending transaction when privateKey is not provided' , async ( ) => {
924+ // Mock transaction builder
925+ const mockTx = {
926+ toXDR : jest . fn ( ( ) => 'mocked-xdr' )
927+ } ;
928+ ( TransactionBuilder as jest . MockedClass < typeof TransactionBuilder > ) . mockImplementation (
929+ ( ) =>
930+ ( {
931+ addOperation : jest . fn ( ) . mockReturnThis ( ) ,
932+ setTimeout : jest . fn ( ) . mockReturnThis ( ) ,
933+ build : jest . fn ( ( ) => mockTx )
934+ } as any )
935+ ) ;
936+
937+ // Mock simulation success
938+ const mockSimulation = {
939+ result : { mock : 'result' }
940+ } ;
941+ mockSorobanServer . simulateTransaction = jest
942+ . fn ( )
943+ . mockResolvedValue ( mockSimulation ) ;
944+ ( rpc . Api . isSimulationError as jest . Mock ) . mockReturnValue ( false ) ;
945+
946+ // Mock prepareTransaction
947+ const mockPreparedTx = {
948+ toXDR : jest . fn ( ( ) => 'prepared-xdr' )
949+ } ;
950+ mockSorobanServer . prepareTransaction = jest . fn ( ) . mockResolvedValue ( mockPreparedTx ) ;
951+
952+ const result = await blendProtocol . repay ( testAddress , null as any , testAsset , '250000' ) ;
953+
954+ expect ( result . status ) . toBe ( 'pending' ) ;
955+ expect ( mockSorobanServer . prepareTransaction ) . toHaveBeenCalled ( ) ;
956+ } ) ;
817957 } ) ;
818958
819959 // ========================================
0 commit comments