Skip to content

Commit 3ddaa2d

Browse files
committed
re-use AccountLayout
1 parent 0cb5709 commit 3ddaa2d

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

sdk/pinocchio/src/sysvars/slot_hashes/test_std.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,17 @@ fn test_from_account_info_constructor() {
2525
#[allow(unused_assignments)]
2626
let mut acct_ptr: *mut Account = core::ptr::null_mut();
2727

28-
#[repr(C)]
29-
#[derive(Clone, Copy, Default)]
30-
struct FakeAccount {
31-
borrow_state: u8,
32-
is_signer: u8,
33-
is_writable: u8,
34-
executable: u8,
35-
resize_delta: i32,
36-
key: Pubkey,
37-
owner: Pubkey,
38-
lamports: u64,
39-
data_len: u64,
40-
}
41-
4228
unsafe {
43-
let header_size = core::mem::size_of::<FakeAccount>();
29+
let header_size = core::mem::size_of::<AccountLayout>();
4430
let total_size = header_size + data.len();
4531
let word_len = (total_size + 7) / 8;
4632
aligned_backing = std::vec![0u64; word_len];
4733
let base_ptr = aligned_backing.as_mut_ptr() as *mut u8;
4834

49-
let header_ptr = base_ptr as *mut FakeAccount;
35+
let header_ptr = base_ptr as *mut AccountLayout;
5036
ptr::write(
5137
header_ptr,
52-
FakeAccount {
38+
AccountLayout {
5339
borrow_state: crate::NON_DUP_MARKER,
5440
is_signer: 0,
5541
is_writable: 0,

sdk/pinocchio/src/sysvars/slot_hashes/test_utils.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ use std::vec::Vec;
1414
/// use of them in tests.
1515
#[repr(C)]
1616
#[derive(Clone, Copy)]
17-
struct AccountLayout {
18-
borrow_state: u8,
19-
is_signer: u8,
20-
is_writable: u8,
21-
executable: u8,
22-
resize_delta: i32,
23-
key: Pubkey,
24-
owner: Pubkey,
25-
lamports: u64,
26-
data_len: u64,
17+
pub struct AccountLayout {
18+
pub borrow_state: u8,
19+
pub is_signer: u8,
20+
pub is_writable: u8,
21+
pub executable: u8,
22+
pub resize_delta: i32,
23+
pub key: Pubkey,
24+
pub owner: Pubkey,
25+
pub lamports: u64,
26+
pub data_len: u64,
2727
}
2828

2929
/// Strategy that decides how much the slot number is decremented between

0 commit comments

Comments
 (0)