#[test]
fn test_create_user_pda() {
let wallet = solana_sdk::signer::keypair::Keypair::new();
I want to use this wallet as a payer, how do I make an airdrop in a test?
Attempt to debit an account but found no record of a prior credit
For those who need this functionality, the only solution that actually worked for me was to spawning a new process executing solana airdrop
command inside a test:
Command::new("solana")
.arg("airdrop")
.arg("--commitment")
.arg("finalized")
.arg("1")
.arg(format!("{}", wallet_pubkey.to_string()))
.spawn()
.unwrap()
.wait()
.unwrap();
--commitment finalized
will take more time than normally, but it's essential - otherwise we move on before the account is created.
For whatever reason, calling airdrop
via RPC client with the same commitment config didn't actually wait for the transaction to finalize.
airdrop
with the RPC client returns a signature -- you then need to call confirm_transaction
with that signature.