Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

token 2022 test: refactor transfer hook test to use new offchain helper #6110

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions token/program-2022-test/tests/transfer_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ use {
processor::Processor,
},
spl_token_client::token::{ExtensionInitializationParams, TokenError as TokenClientError},
spl_transfer_hook_interface::get_extra_account_metas_address,
spl_transfer_hook_interface::{
get_extra_account_metas_address, offchain::add_extra_account_metas_for_execute,
},
std::{convert::TryInto, sync::Arc},
};

Expand Down Expand Up @@ -627,7 +629,6 @@ async fn success_downgrade_writable_and_signer_accounts() {
.unwrap();
}

#[allow(deprecated)]
#[tokio::test]
async fn success_transfers_using_onchain_helper() {
let authority = Pubkey::new_unique();
Expand Down Expand Up @@ -704,8 +705,14 @@ async fn success_transfers_using_onchain_helper() {

let mut instruction = Instruction::new_with_bytes(swap_program_id, &[], account_metas);

offchain::resolve_extra_transfer_account_metas(
add_extra_account_metas_for_execute(
&mut instruction,
&program_id,
&source_a_account,
&mint_a,
&destination_a_account,
&authority_a.pubkey(),
amount,
|address| {
token_a.get_account(address).map_ok_or_else(
|e| match e {
Expand All @@ -715,12 +722,17 @@ async fn success_transfers_using_onchain_helper() {
|acc| Ok(Some(acc.data)),
)
},
&mint_a,
)
.await
.unwrap();
offchain::resolve_extra_transfer_account_metas(
add_extra_account_metas_for_execute(
&mut instruction,
&program_id,
&source_b_account,
&mint_b,
&destination_b_account,
&authority_b.pubkey(),
amount,
|address| {
token_a.get_account(address).map_ok_or_else(
|e| match e {
Expand All @@ -730,7 +742,6 @@ async fn success_transfers_using_onchain_helper() {
|acc| Ok(Some(acc.data)),
)
},
&mint_b,
)
.await
.unwrap();
Expand Down