forked from anza-xyz/agave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Program-Test: Spport adding genesis accounts (anza-xyz#1418)
- Loading branch information
1 parent
1a37631
commit 6631e5f
Showing
2 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use { | ||
solana_program_test::ProgramTest, | ||
solana_sdk::{account::Account, pubkey::Pubkey}, | ||
}; | ||
|
||
#[tokio::test] | ||
async fn genesis_accounts() { | ||
let my_genesis_accounts = [ | ||
( | ||
Pubkey::new_unique(), | ||
Account::new(1, 0, &solana_sdk::system_program::id()), | ||
), | ||
( | ||
Pubkey::new_unique(), | ||
Account::new(1, 0, &solana_sdk::config::program::id()), | ||
), | ||
( | ||
Pubkey::new_unique(), | ||
Account::new(1, 0, &solana_sdk::feature::id()), | ||
), | ||
( | ||
Pubkey::new_unique(), | ||
Account::new(1, 0, &solana_sdk::stake::program::id()), | ||
), | ||
]; | ||
|
||
let mut program_test = ProgramTest::default(); | ||
|
||
for (pubkey, account) in my_genesis_accounts.iter() { | ||
program_test.add_genesis_account(*pubkey, account.clone()); | ||
} | ||
|
||
let mut context = program_test.start_with_context().await; | ||
|
||
// Verify the accounts are present. | ||
for (pubkey, account) in my_genesis_accounts.iter() { | ||
let fetched_account = context | ||
.banks_client | ||
.get_account(*pubkey) | ||
.await | ||
.unwrap() | ||
.unwrap(); | ||
assert_eq!(fetched_account, *account); | ||
} | ||
} |