@@ -44,7 +44,6 @@ const revertOptions = {
4444const usdcDecimals = 6 ;
4545const chain_id = 111111 ;
4646const chain_id_bn = new anchor . BN ( chain_id ) ;
47- const maxPayloadSize = 745 ;
4847
4948async function mintSPLToken (
5049 conn : anchor . web3 . Connection ,
@@ -286,82 +285,6 @@ describe("Gateway", () => {
286285 }
287286 } ) ;
288287
289- it ( "Deposit 1_000_000 USDC with above max payload size should fail" , async ( ) => {
290- const pda_ata = await getOrCreateAssociatedTokenAccount (
291- conn ,
292- wallet ,
293- mint . publicKey ,
294- pdaAccount ,
295- true
296- ) ;
297- const tokenAccount = await getOrCreateAssociatedTokenAccount (
298- conn ,
299- wallet ,
300- mint . publicKey ,
301- wallet . publicKey
302- ) ;
303- try {
304- await gatewayProgram . methods
305- . depositSplTokenAndCall (
306- new anchor . BN ( 2_000_000 ) ,
307- Array . from ( address ) ,
308- Buffer . from ( Array ( maxPayloadSize + 1 ) . fill ( 1 ) ) ,
309- null
310- )
311- . accounts ( {
312- from : tokenAccount . address ,
313- to : pda_ata . address ,
314- mintAccount : mint . publicKey ,
315- } )
316- . preInstructions ( [
317- ComputeBudgetProgram . setComputeUnitLimit ( { units : 400000 } ) ,
318- ] )
319- . rpc ( { commitment : "processed" } ) ;
320- throw new Error ( "Expected error not thrown" ) ;
321- } catch ( err ) {
322- expect ( err ) . to . be . instanceof ( anchor . AnchorError ) ;
323- expect ( err . message ) . to . include ( "MemoLengthExceeded" ) ;
324- }
325- } ) ;
326-
327- it ( "Deposit 1_000_000 USDC with with max payload size" , async ( ) => {
328- const pda_ata = await getOrCreateAssociatedTokenAccount (
329- conn ,
330- wallet ,
331- mint . publicKey ,
332- pdaAccount ,
333- true
334- ) ;
335- const tokenAccount = await getOrCreateAssociatedTokenAccount (
336- conn ,
337- wallet ,
338- mint . publicKey ,
339- wallet . publicKey
340- ) ;
341- let acct = await spl . getAccount ( conn , pda_ata . address ) ;
342- const bal1 = acct . amount ;
343-
344- await gatewayProgram . methods
345- . depositSplTokenAndCall (
346- new anchor . BN ( 2_000_000 ) ,
347- Array . from ( address ) ,
348- Buffer . from ( Array ( maxPayloadSize ) . fill ( 1 ) ) ,
349- null
350- )
351- . accounts ( {
352- from : tokenAccount . address ,
353- to : pda_ata . address ,
354- mintAccount : mint . publicKey ,
355- } )
356- . preInstructions ( [
357- ComputeBudgetProgram . setComputeUnitLimit ( { units : 400000 } ) ,
358- ] )
359- . rpc ( { commitment : "processed" } ) ;
360- acct = await spl . getAccount ( conn , pda_ata . address ) ;
361- const bal2 = acct . amount ;
362- expect ( bal2 - bal1 ) . to . be . eq ( 2_000_000n ) ;
363- } ) ;
364-
365288 it ( "Deposit 1_000_000 USDC to Gateway" , async ( ) => {
366289 let pda_ata = await getOrCreateAssociatedTokenAccount (
367290 conn ,
@@ -541,7 +464,7 @@ describe("Gateway", () => {
541464 expect ( err ) . to . be . instanceof ( anchor . AnchorError ) ;
542465 expect ( err . message ) . to . include ( "NonceMismatch" ) ;
543466 const account4 = await spl . getAccount ( conn , pda_ata ) ;
544- expect ( account4 . amount ) . to . be . eq ( 4_500_000n ) ;
467+ expect ( account4 . amount ) . to . be . eq ( 2_500_000n ) ;
545468 }
546469
547470 try {
@@ -583,7 +506,7 @@ describe("Gateway", () => {
583506 expect ( err ) . to . be . instanceof ( anchor . AnchorError ) ;
584507 expect ( err . message ) . to . include ( "ConstraintAssociated" ) ;
585508 const account4 = await spl . getAccount ( conn , pda_ata ) ;
586- expect ( account4 . amount ) . to . be . eq ( 4_500_000n ) ;
509+ expect ( account4 . amount ) . to . be . eq ( 2_500_000n ) ;
587510 }
588511 } ) ;
589512
@@ -3694,23 +3617,6 @@ describe("Gateway", () => {
36943617 }
36953618 } ) ;
36963619
3697- it ( "Deposit and call with above max payload size should fail" , async ( ) => {
3698- try {
3699- await gatewayProgram . methods
3700- . depositAndCall (
3701- new anchor . BN ( 1_000_000_000 ) ,
3702- Array . from ( address ) ,
3703- Buffer . from ( Array ( maxPayloadSize + 1 ) . fill ( 1 ) ) ,
3704- revertOptions
3705- )
3706- . rpc ( ) ;
3707- throw new Error ( "Expected error not thrown" ) ;
3708- } catch ( err ) {
3709- expect ( err ) . to . be . instanceof ( anchor . AnchorError ) ;
3710- expect ( err . message ) . to . include ( "MemoLengthExceeded" ) ;
3711- }
3712- } ) ;
3713-
37143620 it ( "Call with empty address receiver should fail" , async ( ) => {
37153621 try {
37163622 await gatewayProgram . methods
@@ -3723,54 +3629,6 @@ describe("Gateway", () => {
37233629 }
37243630 } ) ;
37253631
3726- it ( "Call with above max payload size should fail" , async ( ) => {
3727- try {
3728- await gatewayProgram . methods
3729- . call (
3730- Array . from ( address ) ,
3731- Buffer . from ( Array ( maxPayloadSize + 1 ) . fill ( 1 ) ) ,
3732- revertOptions
3733- )
3734- . rpc ( ) ;
3735- throw new Error ( "Expected error not thrown" ) ;
3736- } catch ( err ) {
3737- expect ( err ) . to . be . instanceof ( anchor . AnchorError ) ;
3738- expect ( err . message ) . to . include ( "MemoLengthExceeded" ) ;
3739- }
3740- } ) ;
3741-
3742- it ( "Call with max payload size" , async ( ) => {
3743- const txsig = await gatewayProgram . methods
3744- . call (
3745- Array . from ( address ) ,
3746- Buffer . from ( Array ( maxPayloadSize ) . fill ( 1 ) ) ,
3747- revertOptions
3748- )
3749- . preInstructions ( [
3750- ComputeBudgetProgram . setComputeUnitLimit ( { units : 400000 } ) ,
3751- ] )
3752- . rpc ( { commitment : "processed" } ) ;
3753- await conn . getParsedTransaction ( txsig , "confirmed" ) ;
3754- } ) ;
3755-
3756- it ( "Deposit and call with max payload size" , async ( ) => {
3757- const bal1 = await conn . getBalance ( pdaAccount ) ;
3758- const txsig = await gatewayProgram . methods
3759- . depositAndCall (
3760- new anchor . BN ( 1_000_000_000 ) ,
3761- Array . from ( address ) ,
3762- Buffer . from ( Array ( maxPayloadSize ) . fill ( 1 ) ) ,
3763- revertOptions
3764- )
3765- . preInstructions ( [
3766- ComputeBudgetProgram . setComputeUnitLimit ( { units : 400000 } ) ,
3767- ] )
3768- . rpc ( { commitment : "processed" } ) ;
3769- await conn . getParsedTransaction ( txsig , "confirmed" ) ;
3770- const bal2 = await conn . getBalance ( pdaAccount ) ;
3771- expect ( bal2 - bal1 ) . to . be . gte ( 1_000_000_000 ) ;
3772- } ) ;
3773-
37743632 it ( "Deposit and call" , async ( ) => {
37753633 let bal1 = await conn . getBalance ( pdaAccount ) ;
37763634 const txsig = await gatewayProgram . methods
0 commit comments