@@ -388,7 +388,7 @@ export async function multisig(): Promise<void> {
388
388
}
389
389
}
390
390
391
- export async function closeAccount ( ) : Promise < void > {
391
+ export async function failOnCloseAccount ( ) : Promise < void > {
392
392
const connection = await getConnection ( ) ;
393
393
const owner = new Account ( ) ;
394
394
const close = await testToken . createAccount ( owner . publicKey ) ;
@@ -401,6 +401,7 @@ export async function closeAccount(): Promise<void> {
401
401
throw new Error ( 'Account not found' ) ;
402
402
}
403
403
404
+ // Initialize destination account to isolate source of failure
404
405
const balanceNeeded =
405
406
await connection . getMinimumBalanceForRentExemption ( 0 ) ;
406
407
const dest = await newAccountWithLamports ( connection , balanceNeeded ) ;
@@ -412,14 +413,11 @@ export async function closeAccount(): Promise<void> {
412
413
throw new Error ( 'Account not found' ) ;
413
414
}
414
415
415
- await testToken . closeAccount ( close , dest . publicKey , owner , [ ] ) ;
416
+ assert ( didThrow ( testToken . closeAccount , [ close , dest . publicKey , owner , [ ] ] ) ) ;
417
+
416
418
info = await connection . getAccountInfo ( close ) ;
417
419
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 ) ;
423
421
} else {
424
422
throw new Error ( 'Account not found' ) ;
425
423
}
0 commit comments