Skip to content

Commit

Permalink
MTG-1029 write tests on determining non-fungible token type by token …
Browse files Browse the repository at this point in the history
…supply and decimals options.
  • Loading branch information
andrii-kl committed Jan 29, 2025
1 parent 325257b commit 56f8b6c
Show file tree
Hide file tree
Showing 4 changed files with 391 additions and 75 deletions.
6 changes: 5 additions & 1 deletion integration_tests/src/general_scenario_tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::sync::Arc;

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

Expand Down
54 changes: 54 additions & 0 deletions integration_tests/src/regular_nft_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,57 @@ async fn test_requested_non_fungibles_are_non_fungibles() {

insta::assert_json_snapshot!(name, response);
}

//todo Fix in MTG-1278/on-chain-integration-tests-are-not-working-for-fungible-tokens
#[ignore]
#[tokio::test]
#[serial]
#[named]
async fn test_requested_fungibles_are_fungibles() {
let name = trim_test_name(function_name!());
let setup = TestSetup::new_with_options(
name.clone(),
TestSetupOptions { network: Some(Network::EclipseMainnet), clear_db: true },
)
.await;

let seeds: Vec<SeedEvent> = seed_accounts(["EcxjN4mea6Ah9WSqZhLtSJJCZcxY73Vaz6UVHFZZ5Ttz"]);
index_seed_events(&setup, seeds.iter().collect_vec()).await;

let seeds = seed_token_mints([
"DvpMQyF8sT6hPBewQf6VrVESw6L1zewPyNit1CSt1tDJ",
"9qA21TR9QTsQeR5sP6L2PytjgxXcVRSyqUY5vRcUogom",
"8WKGo1z9k3PjTsQw5GDQmvAbKwuRGtb4APkCneH8AVY1",
"7ZkXycbrAhVzeB9ngnjcCdjk5bxTJYzscSZMhRRBx3QB",
"75peBtH5MwfA5t9uhr51AYL7MR5DbPJ5xQ7wizzvowUH",
"87K3PtGNihT6dKjxULK25MVapZKXQWN4zXqC1BEshHKd",
]);

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

let request = r#"
{
"limit": 500,
"ownerAddress": "EcxjN4mea6Ah9WSqZhLtSJJCZcxY73Vaz6UVHFZZ5Ttz",
"tokenType": "fungible",
"options": {
"showCollectionMetadata": true,
"showGrandTotal": true,
"showInscription": true,
"showNativeBalance": true
}
}"#;

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

let request: SearchAssets = serde_json::from_str(request).unwrap();
let response = setup.das_api.search_assets(request, mutexed_tasks.clone()).await.unwrap();

response["items"].as_array().unwrap().iter().all(|i| {
let interface = i["interface"].as_str().unwrap();
assert_eq!(interface, "FungibleToken");
true
});

insta::assert_json_snapshot!(name, response);
}
27 changes: 16 additions & 11 deletions integration_tests/src/token_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ 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 nft_ingester::api::dapi::{
response::{AssetList, TokenAccountsList},
rpc_asset_models::Asset,
};
use serial_test::serial;
use tokio::{
sync::{broadcast, Mutex},
Expand Down Expand Up @@ -41,16 +44,18 @@ async fn test_fungible_token_mint_freeze_authority() {

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();
let asset: Asset =
serde_json::from_value::<Asset>(response_value.clone()).expect("Cannot parse 'Asset'.");

assert_eq!(asset.clone().id, "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v".to_string());
assert_eq!(
asset.clone().token_info.unwrap().mint_authority.unwrap(),
"BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG".to_string()
);
assert_eq!(
asset.clone().token_info.unwrap().freeze_authority.unwrap(),
"7dGbd2QZcCKcTndnHcTL8q7SMVXAkp688NTQYwrRCrar".to_string()
);

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()
// );
}
Loading

0 comments on commit 56f8b6c

Please sign in to comment.