Skip to content

Commit 10e7961

Browse files
authored
Merge pull request #404 from andrii-kl/test/MTG-1225_showzerobalance-false
test: MTG-1225_MTG-1276 test searchAssets by owner with ShowZeroBalance: false
2 parents 61841e0 + 8308df1 commit 10e7961

File tree

114 files changed

+3177
-226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+3177
-226
lines changed

integration_tests/src/account_update_tests.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::sync::Arc;
1+
use std::{collections::HashMap, sync::Arc};
22

33
use borsh::BorshSerialize;
44
use entities::api_req_params::{GetAsset, Options};
@@ -116,7 +116,11 @@ async fn test_account_updates() {
116116
let name = trim_test_name(function_name!());
117117
let setup = TestSetup::new_with_options(
118118
name.clone(),
119-
TestSetupOptions { network: None, clear_db: true },
119+
TestSetupOptions {
120+
network: None,
121+
clear_db: true,
122+
well_known_fungible_accounts: HashMap::new(),
123+
},
120124
)
121125
.await;
122126
let mint = Pubkey::try_from("843gdpsTE4DoJz3ZoBsEjAqT8UgAcyF5YojygGgGZE1f").unwrap();

integration_tests/src/cnft_tests.rs

+81-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{str::FromStr, sync::Arc};
1+
use std::{collections::HashMap, str::FromStr, sync::Arc};
22

33
use entities::api_req_params::{GetAsset, Options, SearchAssets};
44
use function_name::named;
@@ -44,7 +44,11 @@ async fn test_asset_decompress() {
4444
let name = trim_test_name(function_name!());
4545
let setup = TestSetup::new_with_options(
4646
name.clone(),
47-
TestSetupOptions { network: None, clear_db: true },
47+
TestSetupOptions {
48+
network: None,
49+
clear_db: true,
50+
well_known_fungible_accounts: HashMap::new(),
51+
},
4852
)
4953
.await;
5054
let asset_id = "Az9QTysJj1LW1F7zkYF21HgBj3FRpq3zpxTFdPnAJYm8";
@@ -79,7 +83,11 @@ async fn test_cnft_scenario_mint_update_metadata() {
7983
let name = trim_test_name(function_name!());
8084
let setup = TestSetup::new_with_options(
8185
name.clone(),
82-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
86+
TestSetupOptions {
87+
network: Some(Network::Devnet),
88+
clear_db: true,
89+
well_known_fungible_accounts: HashMap::new(),
90+
},
8391
)
8492
.await;
8593

@@ -109,7 +117,11 @@ async fn test_cnft_scenario_mint_update_metadata_remove_creators() {
109117
let name = trim_test_name(function_name!());
110118
let setup = TestSetup::new_with_options(
111119
name.clone(),
112-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
120+
TestSetupOptions {
121+
network: Some(Network::Devnet),
122+
clear_db: true,
123+
well_known_fungible_accounts: HashMap::new(),
124+
},
113125
)
114126
.await;
115127

@@ -141,7 +153,11 @@ async fn test_cnft_owners_table() {
141153
let name = trim_test_name(function_name!());
142154
let setup = TestSetup::new_with_options(
143155
name.clone(),
144-
TestSetupOptions { network: None, clear_db: true },
156+
TestSetupOptions {
157+
network: None,
158+
clear_db: true,
159+
well_known_fungible_accounts: HashMap::new(),
160+
},
145161
)
146162
.await;
147163

@@ -189,7 +205,11 @@ async fn test_mint_no_json_uri() {
189205
let name = trim_test_name(function_name!());
190206
let setup = TestSetup::new_with_options(
191207
name.clone(),
192-
TestSetupOptions { network: None, clear_db: true },
208+
TestSetupOptions {
209+
network: None,
210+
clear_db: true,
211+
well_known_fungible_accounts: HashMap::new(),
212+
},
193213
)
194214
.await;
195215
let seeds = vec![seed_txn(
@@ -212,7 +232,11 @@ async fn test_mint_delegate_transfer() {
212232
let name = trim_test_name(function_name!());
213233
let setup = TestSetup::new_with_options(
214234
name.clone(),
215-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
235+
TestSetupOptions {
236+
network: Some(Network::Devnet),
237+
clear_db: true,
238+
well_known_fungible_accounts: HashMap::new(),
239+
},
216240
)
217241
.await;
218242

@@ -241,7 +265,11 @@ async fn test_mint_redeem_cancel_redeem() {
241265
let name = trim_test_name(function_name!());
242266
let setup = TestSetup::new_with_options(
243267
name.clone(),
244-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
268+
TestSetupOptions {
269+
network: Some(Network::Devnet),
270+
clear_db: true,
271+
well_known_fungible_accounts: HashMap::new(),
272+
},
245273
)
246274
.await;
247275

@@ -270,7 +298,11 @@ async fn test_mint_redeem() {
270298
let name = trim_test_name(function_name!());
271299
let setup = TestSetup::new_with_options(
272300
name.clone(),
273-
TestSetupOptions { network: None, clear_db: true },
301+
TestSetupOptions {
302+
network: None,
303+
clear_db: true,
304+
well_known_fungible_accounts: HashMap::new(),
305+
},
274306
)
275307
.await;
276308

@@ -304,7 +336,11 @@ async fn test_mint_transfer_burn() {
304336
let name = trim_test_name(function_name!());
305337
let setup = TestSetup::new_with_options(
306338
name.clone(),
307-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
339+
TestSetupOptions {
340+
network: Some(Network::Devnet),
341+
clear_db: true,
342+
well_known_fungible_accounts: HashMap::new(),
343+
},
308344
)
309345
.await;
310346

@@ -333,7 +369,11 @@ async fn test_mint_transfer_noop() {
333369
let name = trim_test_name(function_name!());
334370
let setup = TestSetup::new_with_options(
335371
name.clone(),
336-
TestSetupOptions { network: None, clear_db: true },
372+
TestSetupOptions {
373+
network: None,
374+
clear_db: true,
375+
well_known_fungible_accounts: HashMap::new(),
376+
},
337377
)
338378
.await;
339379

@@ -362,7 +402,11 @@ async fn test_mint_transfer_transfer() {
362402
let name = trim_test_name(function_name!());
363403
let setup = TestSetup::new_with_options(
364404
name.clone(),
365-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
405+
TestSetupOptions {
406+
network: Some(Network::Devnet),
407+
clear_db: true,
408+
well_known_fungible_accounts: HashMap::new(),
409+
},
366410
)
367411
.await;
368412

@@ -391,7 +435,11 @@ async fn test_mint_verify_creator() {
391435
let name = trim_test_name(function_name!());
392436
let setup = TestSetup::new_with_options(
393437
name.clone(),
394-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
438+
TestSetupOptions {
439+
network: Some(Network::Devnet),
440+
clear_db: true,
441+
well_known_fungible_accounts: HashMap::new(),
442+
},
395443
)
396444
.await;
397445

@@ -419,7 +467,11 @@ async fn test_mint_verify_collection() {
419467
let name = trim_test_name(function_name!());
420468
let setup = TestSetup::new_with_options(
421469
name.clone(),
422-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
470+
TestSetupOptions {
471+
network: Some(Network::Devnet),
472+
clear_db: true,
473+
well_known_fungible_accounts: HashMap::new(),
474+
},
423475
)
424476
.await;
425477

@@ -447,7 +499,11 @@ async fn test_mint_transfer_mpl_programs() {
447499
let name = trim_test_name(function_name!());
448500
let setup = TestSetup::new_with_options(
449501
name.clone(),
450-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
502+
TestSetupOptions {
503+
network: Some(Network::Devnet),
504+
clear_db: true,
505+
well_known_fungible_accounts: HashMap::new(),
506+
},
451507
)
452508
.await;
453509

@@ -476,7 +532,11 @@ async fn test_mint_to_collection_unverify_collection() {
476532
let name = trim_test_name(function_name!());
477533
let setup = TestSetup::new_with_options(
478534
name.clone(),
479-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
535+
TestSetupOptions {
536+
network: Some(Network::Devnet),
537+
clear_db: true,
538+
well_known_fungible_accounts: HashMap::new(),
539+
},
480540
)
481541
.await;
482542

@@ -509,7 +569,11 @@ async fn test_mint_verify_collection_unverify_collection() {
509569
let name = trim_test_name(function_name!());
510570
let setup = TestSetup::new_with_options(
511571
name.clone(),
512-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
572+
TestSetupOptions {
573+
network: Some(Network::Devnet),
574+
clear_db: true,
575+
well_known_fungible_accounts: HashMap::new(),
576+
},
513577
)
514578
.await;
515579

integration_tests/src/common.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ const SYNCHRONIZER_DUMP_PATH: &str = "./rocks_dump";
7070
const POSTGRE_MIGRATIONS_PATH: &str = "../migrations";
7171
const POSTGRE_BASE_DUMP_PATH: &str = "/aura/integration_tests/";
7272

73+
pub fn well_known_fungible_tokens() -> HashMap<String, String> {
74+
let mut map = HashMap::new();
75+
map.insert("HxhWkVpk5NS4Ltg5nij2G671CKXFRKPK8vy271Ub4uEK".to_string(), "Hxro".to_string());
76+
map.insert("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v".to_string(), "USDC".to_string());
77+
map.insert("METAewgxyPbgwsseH8T16a39CQ5VyVxZi9zXiDPY18m".to_string(), "MPLX".to_string());
78+
map
79+
}
80+
7381
pub struct TestSetup {
7482
pub name: String,
7583
pub client: Arc<RpcClient>,
@@ -140,6 +148,7 @@ impl TestSetup {
140148
client.clone(),
141149
mutexed_tasks.clone(),
142150
None,
151+
opts.well_known_fungible_accounts,
143152
)
144153
.await
145154
.unwrap();
@@ -214,10 +223,11 @@ impl TestSetup {
214223
}
215224
}
216225

217-
#[derive(Clone, Copy, Default)]
226+
#[derive(Clone, Default)]
218227
pub struct TestSetupOptions {
219228
pub network: Option<Network>,
220229
pub clear_db: bool,
230+
pub well_known_fungible_accounts: HashMap<String, String>,
221231
}
222232

223233
pub async fn get_transaction(
@@ -673,9 +683,7 @@ async fn index_account_with_ordered_slot(setup: &TestSetup, account: Pubkey) {
673683
}
674684

675685
async fn index_token_mint(setup: &TestSetup, mint: Pubkey) {
676-
let token_account = cached_fetch_largest_token_account_id(&setup.client, mint).await;
677686
index_account(setup, mint).await;
678-
index_account(setup, token_account).await;
679687

680688
// If we used different slots for accounts, then it becomes harder to test updates of related
681689
// accounts because we need to factor the fact that some updates can be disregarded because
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
�Sn2���7Lٲ�@��[�zHXw\�WA�MR

integration_tests/src/general_scenario_tests.rs

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::sync::Arc;
1+
use std::{collections::HashMap, sync::Arc};
22

33
use entities::{
44
api_req_params::{GetAsset, GetAssetsByOwner, SearchAssets},
@@ -11,8 +11,8 @@ use serial_test::serial;
1111
use tokio::{sync::Mutex, task::JoinSet};
1212

1313
use crate::common::{
14-
index_seed_events, seed_accounts, seed_nfts, trim_test_name, Network, SeedEvent, TestSetup,
15-
TestSetupOptions,
14+
index_seed_events, seed_accounts, seed_nfts, trim_test_name, well_known_fungible_tokens,
15+
Network, SeedEvent, TestSetup, TestSetupOptions,
1616
};
1717

1818
#[tokio::test]
@@ -22,7 +22,11 @@ async fn test_asset_parsing() {
2222
let name = trim_test_name(function_name!());
2323
let setup = TestSetup::new_with_options(
2424
name.clone(),
25-
TestSetupOptions { network: None, clear_db: true },
25+
TestSetupOptions {
26+
network: None,
27+
clear_db: true,
28+
well_known_fungible_accounts: HashMap::new(),
29+
},
2630
)
2731
.await;
2832

@@ -50,7 +54,11 @@ async fn test_get_different_assets_by_owner() {
5054
let name = trim_test_name(function_name!());
5155
let setup = TestSetup::new_with_options(
5256
name.clone(),
53-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
57+
TestSetupOptions {
58+
network: Some(Network::Devnet),
59+
clear_db: true,
60+
well_known_fungible_accounts: HashMap::new(),
61+
},
5462
)
5563
.await;
5664

@@ -114,7 +122,11 @@ async fn test_process_previously_unparseable_account() {
114122
let name = trim_test_name(function_name!());
115123
let setup = TestSetup::new_with_options(
116124
name.clone(),
117-
TestSetupOptions { network: Some(Network::Devnet), clear_db: true },
125+
TestSetupOptions {
126+
network: Some(Network::Devnet),
127+
clear_db: true,
128+
well_known_fungible_accounts: HashMap::new(),
129+
},
118130
)
119131
.await;
120132

0 commit comments

Comments
 (0)