@@ -388,7 +388,7 @@ export async function multisig(): Promise<void> {
388388 }
389389}
390390
391- export async function closeAccount ( ) : Promise < void > {
391+ export async function failOnCloseAccount ( ) : Promise < void > {
392392 const connection = await getConnection ( ) ;
393393 const owner = new Account ( ) ;
394394 const close = await testToken . createAccount ( owner . publicKey ) ;
@@ -401,6 +401,7 @@ export async function closeAccount(): Promise<void> {
401401 throw new Error ( 'Account not found' ) ;
402402 }
403403
404+ // Initialize destination account to isolate source of failure
404405 const balanceNeeded =
405406 await connection . getMinimumBalanceForRentExemption ( 0 ) ;
406407 const dest = await newAccountWithLamports ( connection , balanceNeeded ) ;
@@ -412,14 +413,11 @@ export async function closeAccount(): Promise<void> {
412413 throw new Error ( 'Account not found' ) ;
413414 }
414415
415- await testToken . closeAccount ( close , dest . publicKey , owner , [ ] ) ;
416+ assert ( didThrow ( testToken . closeAccount , [ close , dest . publicKey , owner , [ ] ] ) ) ;
417+
416418 info = await connection . getAccountInfo ( close ) ;
417419 if ( info != null ) {
418- throw new Error ( 'Account not closed' ) ;
419- }
420- info = await connection . getAccountInfo ( dest . publicKey ) ;
421- if ( info != null ) {
422- assert ( info . lamports == balanceNeeded + close_balance ) ;
420+ assert ( info . lamports == close_balance ) ;
423421 } else {
424422 throw new Error ( 'Account not found' ) ;
425423 }
0 commit comments