@@ -211,6 +211,28 @@ describe("Gateway", () => {
211211
212212 // create a fake USDC token account
213213 await mintSPLToken ( conn , wallet , mint_fake ) ;
214+
215+ // 2. create token account to receive mint
216+ let fakeMintTokenAccount = await spl . getOrCreateAssociatedTokenAccount (
217+ conn ,
218+ wallet ,
219+ mint_fake . publicKey ,
220+ wallet . publicKey
221+ ) ;
222+ // 3. mint some tokens
223+ const mintFakeToTransaction = new anchor . web3 . Transaction ( ) . add (
224+ spl . createMintToInstruction (
225+ mint_fake . publicKey ,
226+ fakeMintTokenAccount . address ,
227+ wallet . publicKey ,
228+ 10_000_000
229+ )
230+ ) ;
231+ await anchor . web3 . sendAndConfirmTransaction (
232+ anchor . getProvider ( ) . connection ,
233+ mintFakeToTransaction ,
234+ [ wallet ]
235+ ) ;
214236 } ) ;
215237
216238 it ( "Whitelist USDC SPL token" , async ( ) => {
@@ -371,6 +393,38 @@ describe("Gateway", () => {
371393 expect ( bal1 - bal0 ) . to . be . eq ( 2_000_000n ) ;
372394 } ) ;
373395
396+ it ( "Deposit 1_000_000 fake spl to Gateway fails" , async ( ) => {
397+ let fake_pda_ata = await getOrCreateAssociatedTokenAccount (
398+ conn ,
399+ wallet ,
400+ mint_fake . publicKey ,
401+ pdaAccount ,
402+ true
403+ ) ;
404+
405+ let fake_tokenAccount = await getOrCreateAssociatedTokenAccount (
406+ conn ,
407+ wallet ,
408+ mint_fake . publicKey ,
409+ wallet . publicKey ,
410+ true
411+ ) ;
412+ try {
413+ await gatewayProgram . methods
414+ . depositSplToken ( new anchor . BN ( 1_000_000 ) , Array . from ( address ) )
415+ . accounts ( {
416+ from : fake_tokenAccount . address ,
417+ to : fake_pda_ata . address ,
418+ mintAccount : mint . publicKey ,
419+ } )
420+ . rpc ( ) ;
421+ throw new Error ( "Expected error not thrown" ) ;
422+ } catch ( err ) {
423+ expect ( err ) . to . be . instanceof ( anchor . AnchorError ) ;
424+ expect ( err . message ) . to . include ( "ConstraintRaw." ) ;
425+ }
426+ } ) ;
427+
374428 it ( "Deposit non-whitelisted SPL tokens should fail" , async ( ) => {
375429 let seeds = [ Buffer . from ( "meta" , "utf-8" ) ] ;
376430 [ pdaAccount ] = anchor . web3 . PublicKey . findProgramAddressSync (
0 commit comments