Skip to content

Commit

Permalink
MTG-1028 Add integration tests for freeze authorities & delegate auth…
Browse files Browse the repository at this point in the history
…orities

- add integration test with onchain data
  • Loading branch information
andrii-kl committed Jan 28, 2025
1 parent 39a0b25 commit 9d737cf
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 2 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
������� u\C��J]ٞ� �kU%78��
1 change: 1 addition & 0 deletions integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ mod general_scenario_tests;
mod mpl_core_tests;
mod regular_nft_tests;
mod synchronizer_tests;
mod token_tests;
11 changes: 9 additions & 2 deletions integration_tests/src/regular_nft_tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
use std::sync::Arc;

use entities::api_req_params::{GetAsset, GetAssetBatch, GetAssetsByGroup, SearchAssets};
use entities::{
api_req_params::{GetAsset, GetAssetBatch, GetAssetsByGroup, SearchAssets},
enums::AssetType,
};
use function_name::named;
use itertools::Itertools;
use nft_ingester::api::dapi::response::AssetList;
use rocks_db::storage_traits::AssetIndexReader;
use serial_test::serial;
use tokio::{sync::Mutex, task::JoinSet};
use tokio::{
sync::{broadcast, Mutex},
task::JoinSet,
};

use super::common::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
source: integration_tests/src/token_tests.rs
assertion_line: 38
expression: response
snapshot_kind: text
---
{
"interface": "Custom",
"id": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "",
"files": [],
"metadata": {
"name": "USD Coin",
"symbol": "USDC"
},
"links": {}
},
"authorities": [
{
"address": "2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9",
"scopes": [
"full"
]
}
],
"compression": {
"eligible": false,
"compressed": false,
"data_hash": "",
"creator_hash": "",
"asset_hash": "",
"tree": "",
"seq": 0,
"leaf_id": 0
},
"grouping": [],
"royalty": {
"royalty_model": "creators",
"target": null,
"percent": 0.0,
"basis_points": 0,
"primary_sale_happened": false,
"locked": false
},
"creators": [],
"ownership": {
"frozen": false,
"delegated": false,
"delegate": null,
"ownership_model": "token",
"owner": ""
},
"supply": {
"print_max_supply": 0,
"print_current_supply": 0,
"edition_nonce": 252
},
"mutable": true,
"burnt": false,
"lamports": 5616720,
"executable": false,
"metadata_owner": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
"rent_epoch": 18446744073709551615,
"token_info": {
"supply": 9342137502207180,
"decimals": 6,
"token_program": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"mint_authority": "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG",
"freeze_authority": "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar"
}
}
56 changes: 56 additions & 0 deletions integration_tests/src/token_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use std::sync::Arc;

use entities::{api_req_params::GetAsset, enums::AssetType};
use function_name::named;
use itertools::Itertools;
use nft_ingester::api::dapi::response::{AssetList, TokenAccountsList};
use serial_test::serial;
use tokio::{
sync::{broadcast, Mutex},
task::JoinSet,
};

use crate::common::{
index_seed_events, seed_token_mints, trim_test_name, Network, SeedEvent, TestSetup,
TestSetupOptions,
};

#[tokio::test]
#[serial]
#[named]
async fn test_fungible_token_mint_freeze_authority() {
let name = trim_test_name(function_name!());
let setup = TestSetup::new_with_options(
name.clone(),
TestSetupOptions { network: Some(Network::Mainnet), clear_db: true },
)
.await;

// USDC token
let seeds: Vec<SeedEvent> = seed_token_mints(&["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"]);

index_seed_events(&setup, seeds.iter().collect_vec()).await;

let request = r#"
{
"id": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
}
"#;

let mutexed_tasks = Arc::new(Mutex::new(JoinSet::new()));

let request: GetAsset = serde_json::from_str(request).unwrap();
let response_value = setup.das_api.get_asset(request, mutexed_tasks.clone()).await.unwrap();
let res: AssetList = serde_json::from_value(response_value.clone()).unwrap();

insta::assert_json_snapshot!(name, response_value.clone());

// assert_eq!(
// res.items[0].clone().token_info.unwrap().mint_authority.unwrap(),
// "BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG".to_string()
// );
// assert_eq!(
// res.items[0].clone().token_info.unwrap().freeze_authority.unwrap(),
// "7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar".to_string()
// );
}

0 comments on commit 9d737cf

Please sign in to comment.