@@ -12,6 +12,7 @@ import {
1212 pipe ,
1313} from "@solana/kit" ;
1414import {
15+ ASSOCIATED_TOKEN_PROGRAM_ID ,
1516 ExtensionType ,
1617 NATIVE_MINT ,
1718 TOKEN_2022_PROGRAM_ID ,
@@ -163,9 +164,13 @@ describe("svm_spoke.deposit", () => {
163164 . accounts ( calledDepositAccounts )
164165 . instruction ( ) ;
165166 const depositTx = new Transaction ( ) . add ( approveIx , depositIx ) ;
166- return sendAndConfirmTransaction ( connection , depositTx , [ payer , depositor ] ) ;
167+ return sendAndConfirmTransaction ( connection , depositTx , [ depositor ] ) ;
167168 } ;
168169
170+ before ( async ( ) => {
171+ await connection . requestAirdrop ( depositor . publicKey , 10_000_000_000 ) ; // 10 SOL
172+ } ) ;
173+
169174 beforeEach ( async ( ) => {
170175 ( { state, seed } = await initializeState ( ) ) ;
171176
@@ -730,6 +735,44 @@ describe("svm_spoke.deposit", () => {
730735 ) ;
731736 } ) ;
732737
738+ it ( "Deposits tokens to a new vault" , async ( ) => {
739+ // Create new input token without creating a new vault for it.
740+ await setupInputToken ( ) ;
741+ const inputTokenAccount = await provider . connection . getAccountInfo ( inputToken ) ;
742+ if ( inputTokenAccount === null ) throw new Error ( "Input mint account not found" ) ;
743+ vault = getAssociatedTokenAddressSync (
744+ inputToken ,
745+ state ,
746+ true ,
747+ inputTokenAccount . owner ,
748+ ASSOCIATED_TOKEN_PROGRAM_ID
749+ ) ;
750+
751+ // Update global variables using the new input token.
752+ depositData . inputToken = inputToken ;
753+ depositAccounts . depositorTokenAccount = depositorTA ;
754+ depositAccounts . vault = vault ;
755+ depositAccounts . mint = inputToken ;
756+
757+ // Verify there is no vault account before the deposit.
758+ assert . isNull ( await provider . connection . getAccountInfo ( vault ) , "Vault should not exist before the deposit" ) ;
759+
760+ // Execute the deposit call
761+ await approvedDeposit ( depositData ) ;
762+
763+ // Verify tokens leave the depositor's account
764+ const depositorAccount = await getAccount ( connection , depositorTA ) ;
765+ assertSE (
766+ depositorAccount . amount ,
767+ seedBalance - depositData . inputAmount . toNumber ( ) ,
768+ "Depositor's balance should be reduced by the deposited amount"
769+ ) ;
770+
771+ // Verify tokens are credited into the new vault
772+ const vaultAccount = await getAccount ( connection , vault ) ;
773+ assertSE ( vaultAccount . amount , depositData . inputAmount , "Vault balance should equal the deposited amount" ) ;
774+ } ) ;
775+
733776 describe ( "codama client and solana kit" , ( ) => {
734777 it ( "Deposit with with solana kit and codama client" , async ( ) => {
735778 // typescript is not happy with the depositData object
0 commit comments