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

MTG-1029 write tests on determining non-fungible token type by token … #395

Merged
Merged
Show file tree
Hide file tree
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
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
Loading