@@ -121,6 +121,7 @@ describe("Bankrun - Folio redeeming", () => {
121121 expectedFolioTokenBalanceChange : BN ;
122122 expectedTokenBalanceChanges : BN [ ] ;
123123 minimumOutForTokenAmounts : { mint : PublicKey ; minimumOut : BN } [ ] ;
124+ user_pending_basket_not_initalized : boolean ;
124125 } = {
125126 alreadyIncludedTokens : [ ] ,
126127 tokens : [ ] ,
@@ -140,6 +141,7 @@ describe("Bankrun - Folio redeeming", () => {
140141 expectedFolioTokenBalanceChange : new BN ( 0 ) ,
141142 expectedTokenBalanceChanges : Array ( MINTS . length ) . fill ( new BN ( 0 ) ) ,
142143 minimumOutForTokenAmounts : [ ] ,
144+ user_pending_basket_not_initalized : false ,
143145 } ;
144146
145147 const TEST_CASES_BURN_FOLIO_TOKEN = [
@@ -261,6 +263,28 @@ describe("Bankrun - Folio redeeming", () => {
261263 new BN ( 1_000_000_000 ) ,
262264 ] ,
263265 } ,
266+
267+ {
268+ desc : "(users burns max amount of shares, even when his alreadyIncludedTokens is empty)" ,
269+ expectedError : null ,
270+ folioBasketTokens : [
271+ new FolioTokenAmount ( MINTS [ 0 ] . publicKey , new BN ( 1_000 ) . mul ( D9 ) ) ,
272+ new FolioTokenAmount ( MINTS [ 1 ] . publicKey , new BN ( 1_000 ) . mul ( D9 ) ) ,
273+ ] ,
274+ alreadyIncludedTokens : [ ] ,
275+ user_pending_basket_not_initalized : true ,
276+ tokens : [
277+ { mint : MINTS [ 0 ] . publicKey , amount : new BN ( 0 ) } ,
278+ { mint : MINTS [ 1 ] . publicKey , amount : new BN ( 0 ) } ,
279+ ] ,
280+ initialUserShares : new BN ( 1_000_000_000 ) ,
281+ shares : new BN ( 1_000_000_000 ) ,
282+ expectedFolioTokenBalanceChange : new BN ( 1_000_000_000 ) ,
283+ expectedTokenBalanceChanges : [
284+ new BN ( 1_000_000_000 ) ,
285+ new BN ( 1_000_000_000 ) ,
286+ ] ,
287+ } ,
264288 ] ;
265289
266290 const TEST_CASES_REDEEM_FROM_PENDING_BASKET = [
@@ -551,6 +575,7 @@ describe("Bankrun - Folio redeeming", () => {
551575 customFolioTokenMint,
552576 customFolioFeeConfig,
553577 minimumOutForTokenAmounts,
578+ user_pending_basket_not_initalized,
554579 } = {
555580 ...DEFAULT_PARAMS ,
556581 ...restOfParams ,
@@ -575,13 +600,15 @@ describe("Bankrun - Folio redeeming", () => {
575600 customFolioFeeConfig
576601 ) ;
577602
578- await createAndSetUserPendingBasket (
579- context ,
580- programFolio ,
581- folioPDA ,
582- userKeypair . publicKey ,
583- alreadyIncludedTokens
584- ) ;
603+ if ( ! user_pending_basket_not_initalized ) {
604+ await createAndSetUserPendingBasket (
605+ context ,
606+ programFolio ,
607+ folioPDA ,
608+ userKeypair . publicKey ,
609+ alreadyIncludedTokens
610+ ) ;
611+ }
585612
586613 await travelFutureSlot ( context ) ;
587614
0 commit comments