Skip to content

Commit

Permalink
add test (squash)
Browse files Browse the repository at this point in the history
  • Loading branch information
tukan committed Nov 18, 2024
1 parent 7df4fbc commit 66f5901
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions executor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,70 @@ async fn parallel_transfers() -> Result<()> {
Ok(())
}

async fn find_holder(idx: u8, solana_api: SolanaApi, operator: &Pubkey) -> Result<Option<Account>> {
let seed = format!("holder{}", idx);
let pubkey =
Pubkey::create_with_seed(operator, &seed, &NEON_KEY).expect("create with seed failed");
let Some(account) = solana_api.get_account(&pubkey).await? else {
return Ok(None);
};
Ok(Some(account))
}

#[tokio::test]
#[serial]
async fn holder_recreate() -> Result<()> {
let ExecutorTestEnvironment {
executor,
neon_api,
solana_api,
..
} = ExecutorTestEnvironment::start().await?;

drop(executor);

let operator = Operator::read_from_file("tests/keys/operator.json").map(Arc::new)?;
let (executor, _task) = Executor::builder()
.neon_pubkey(NEON_KEY)
.operator(operator.clone())
.neon_api(neon_api.clone())
.solana_api(solana_api.clone())
.init_operator_balance(false)
.max_holders(MAX_HOLDERS)
.holder_size(HOLDER_SIZE)
.init_holders(true)
.prepare()
.start()
.await?;
executor.join_current_transactions().await;

let holder = find_holder(0, solana_api.clone(), &operator.pubkey()).await?;
let holder_len = holder.unwrap().data.len();
assert_eq!(holder_len, HOLDER_SIZE);

drop(executor);

let (executor, _task) = Executor::builder()
.neon_pubkey(NEON_KEY)
.operator(operator.clone())
.neon_api(neon_api.clone())
.solana_api(solana_api.clone())
.init_operator_balance(false)
.max_holders(MAX_HOLDERS)
.holder_size(HOLDER_SIZE + 100)
.init_holders(true)
.prepare()
.start()
.await?;
executor.join_current_transactions().await;

let holder = find_holder(0, solana_api.clone(), &operator.pubkey()).await?;
let holder_len = holder.unwrap().data.len();
assert_eq!(holder_len, HOLDER_SIZE + 100);

Ok(())
}

async fn get_balances(
rpc: &(impl Rpc + BuildConfigSimulator),
addr: &[Address],
Expand Down

0 comments on commit 66f5901

Please sign in to comment.