Skip to content

Commit 062ef2b

Browse files
authored
Fixed CloseAccount error (#84)
`src` and `dst` got mixed up with the lamports. And I added a check that the `src` account has no lamports after. Interestingly since the property for overflow is `u64::MAX < src_init_lamports + dst_init_lamports` which and the only other operation is addition, the switch actually hasn't affected anything due to comutativity.
1 parent c57d573 commit 062ef2b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

p-token/src/entrypoint-runtime-verification.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,8 @@ pub fn test_process_close_account(accounts: &[AccountInfo; 3]) -> ProgramResult
11591159
let src_initialised = get_account(&accounts[0]).is_initialized();
11601160
let src_data_len = accounts[0].data_len();
11611161
let src_init_amount = get_account(&accounts[0]).amount();
1162-
let dst_init_lamports = accounts[0].lamports();
1163-
let src_init_lamports = accounts[1].lamports();
1162+
let src_init_lamports = accounts[0].lamports();
1163+
let dst_init_lamports = accounts[1].lamports();
11641164
let src_is_native = get_account(&accounts[0]).is_native();
11651165
let src_owned_sys_inc = get_account(&accounts[0]).is_owned_by_system_program_or_incinerator();
11661166
let authority = get_account(&accounts[0])
@@ -1213,6 +1213,7 @@ pub fn test_process_close_account(accounts: &[AccountInfo; 3]) -> ProgramResult
12131213
}
12141214

12151215
// Validate owner falls through to here if no error
1216+
assert_eq!(accounts[0].lamports(), 0);
12161217
assert_eq!(
12171218
accounts[1].lamports(),
12181219
dst_init_lamports + src_init_lamports

0 commit comments

Comments
 (0)