1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! Wallet creation and management utilities.
use crateSolanaKiteError;
use LiteSVM;
use Keypair;
use Pubkey;
use Signer;
/// Creates a new wallet (keypair) and airdrops SOL to it.
///
/// This function generates a new keypair and funds it with the specified amount
/// of lamports via an airdrop in the LiteSVM test environment.
///
/// # Arguments
///
/// * `litesvm` - Mutable reference to the LiteSVM instance
/// * `airdrop_amount` - Amount of lamports to airdrop to the new wallet
///
/// # Returns
///
/// Returns the newly created and funded keypair.
///
/// # Errors
///
/// This function will return an error if the airdrop fails.
///
/// # Example
///
/// ```rust
/// use solana_kite::create_wallet;
/// use litesvm::LiteSVM;
///
/// let mut litesvm = LiteSVM::new();
/// let wallet = create_wallet(&mut litesvm, 1_000_000_000)?; // 1 SOL
/// # Ok::<(), solana_kite::SolanaKiteError>(())
/// ```
/// Creates multiple wallets with the same airdrop amount.
///
/// This is a convenience function for creating multiple funded wallets at once,
/// useful for testing scenarios that require multiple participants.
///
/// # Arguments
///
/// * `litesvm` - Mutable reference to the LiteSVM instance
/// * `count` - Number of wallets to create
/// * `airdrop_amount` - Amount of lamports to airdrop to each wallet
///
/// # Returns
///
/// Returns a vector of newly created and funded keypairs.
///
/// # Errors
///
/// This function will return an error if any airdrop fails.
///
/// # Example
///
/// ```rust
/// use solana_kite::create_wallets;
/// use litesvm::LiteSVM;
///
/// let mut litesvm = LiteSVM::new();
/// let wallets = create_wallets(&mut litesvm, 3, 1_000_000_000)?; // 3 wallets with 1 SOL each
/// assert_eq!(wallets.len(), 3);
/// # Ok::<(), solana_kite::SolanaKiteError>(())
/// ```
/// Returns the SOL balance of an account in lamports.
///
/// Returns 0 if the account does not exist.
///
/// # Example
///
/// ```rust
/// use solana_kite::{create_wallet, get_sol_balance};
/// use litesvm::LiteSVM;
/// use solana_signer::Signer;
///
/// let mut litesvm = LiteSVM::new();
/// let wallet = create_wallet(&mut litesvm, 1_000_000_000).unwrap();
/// let balance = get_sol_balance(&litesvm, &wallet.pubkey());
/// assert_eq!(balance, 1_000_000_000);
/// ```
/// Asserts that an account has the expected SOL balance in lamports.
///
/// Convenience wrapper around [`get_sol_balance`] for test assertions.
///
/// # Panics
///
/// Panics if the actual balance doesn't match `expected_lamports`, with the provided message.
///
/// # Example
///
/// ```rust
/// use solana_kite::{create_wallet, assert_sol_balance};
/// use litesvm::LiteSVM;
/// use solana_signer::Signer;
///
/// let mut litesvm = LiteSVM::new();
/// let wallet = create_wallet(&mut litesvm, 1_000_000_000).unwrap();
/// assert_sol_balance(&litesvm, &wallet.pubkey(), 1_000_000_000, "Should have 1 SOL");
/// ```
/// Verifies that an account is closed (either doesn't exist or has empty data).
///
/// # Arguments
///
/// * `litesvm` - The LiteSVM instance to query
/// * `account` - The account address to check
/// * `message` - Error message to display if the account is not closed
///
/// # Panics
///
/// Panics if the account exists and has non-empty data, with the provided message.
///
/// # Example
///
/// ```rust
/// use solana_kite::check_account_is_closed;
/// use litesvm::LiteSVM;
/// use solana_pubkey::Pubkey;
///
/// let litesvm = LiteSVM::new();
/// let account = Pubkey::new_unique();
/// check_account_is_closed(&litesvm, &account, "Account should be closed");
/// ```