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-979 Fix collection verification check for API requests #329

Open
wants to merge 10 commits into
base: new-main
Choose a base branch
from
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 @@
fɳ�h�v�*��/�����5�u��S;-y�F�
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��kh K� ��Hdתn&���r�jh��]�+B
77 changes: 77 additions & 0 deletions integration_tests/src/general_scenario_tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use crate::common::index_seed_events;
use crate::common::seed_accounts;
use crate::common::seed_nfts;
use crate::common::trim_test_name;
use crate::common::Network;
use crate::common::SeedEvent;
use crate::common::TestSetup;
use crate::common::TestSetupOptions;
use entities::api_req_params::GetAsset;
use entities::api_req_params::GetAssetsByOwner;
use function_name::named;
use itertools::Itertools;
use serial_test::serial;
Expand Down Expand Up @@ -46,3 +49,77 @@ async fn test_asset_parsing() {
.unwrap();
insta::assert_json_snapshot!(name, response);
}

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

let seeds: Vec<SeedEvent> = seed_nfts([
"91tabY8dzm3HfSgDujeyEfT6p94sV39iW2T8R9u5CMMo", // NFT without collection
"9prAPyPdbd75U5uLvACjPpyfSp7EbHPwPdtxZihYetjh", // NFT with unverified collection
]);

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

let seeds: Vec<SeedEvent> = seed_accounts([
"J9skkg9hzZFzNkQ55sQy6R4uozqfkQ8MRMmnCV7hgq5q", // Core collection
"CRqexZSPcuiYGJuTM68tC48bhC4ZSRK9Gk178wcopo42", // Core asset
]);

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

let request = r#"
{
"ownerAddress": "3VvLDXqJbw3heyRwFxv8MmurPznmDVUJS9gPMX2BDqfM",
"sortBy": {
"sortBy": "updated",
"sortDirection": "asc"
},
"page": 1,
"limit": 50
}
"#;

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

let request: GetAssetsByOwner = serde_json::from_str(request).unwrap();
let response = setup
.das_api
.get_assets_by_owner(request, mutexed_tasks.clone())
.await
.unwrap();
insta::assert_json_snapshot!(name.clone(), response);

let request = r#"
{
"ownerAddress": "3VvLDXqJbw3heyRwFxv8MmurPznmDVUJS9gPMX2BDqfM",
"sortBy": {
"sortBy": "updated",
"sortDirection": "asc"
},
"options": {
"showUnverifiedCollections": true
},
"page": 1,
"limit": 50
}
"#;

let request: GetAssetsByOwner = serde_json::from_str(request).unwrap();
let response = setup
.das_api
.get_assets_by_owner(request, mutexed_tasks.clone())
.await
.unwrap();
insta::assert_json_snapshot!(format!("{}_show_unverif_coll", name), response);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
---
source: integration_tests/src/general_scenario_tests.rs
assertion_line: 101
expression: response
snapshot_kind: text
---
{
"total": 3,
"limit": 50,
"page": 1,
"items": [
{
"interface": "MplCoreAsset",
"id": "CRqexZSPcuiYGJuTM68tC48bhC4ZSRK9Gk178wcopo42",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "https://test.link",
"files": [],
"metadata": {
"name": "Test core asset",
"symbol": ""
},
"links": {}
},
"authorities": [
{
"address": "3VvLDXqJbw3heyRwFxv8MmurPznmDVUJS9gPMX2BDqfM",
"scopes": [
"full"
]
}
],
"compression": {
"eligible": false,
"compressed": false,
"data_hash": "",
"creator_hash": "",
"asset_hash": "",
"tree": "",
"seq": 0,
"leaf_id": 0
},
"grouping": [
{
"group_key": "collection",
"group_value": "J9skkg9hzZFzNkQ55sQy6R4uozqfkQ8MRMmnCV7hgq5q",
"verified": true
}
],
"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": "single",
"owner": "3VvLDXqJbw3heyRwFxv8MmurPznmDVUJS9gPMX2BDqfM"
},
"supply": null,
"mutable": true,
"burnt": false,
"lamports": 3135600,
"executable": false,
"rent_epoch": 18446744073709551615,
"plugins": {},
"mpl_core_info": {
"plugins_json_version": 1
},
"external_plugins": []
},
{
"interface": "MplCoreCollection",
"id": "J9skkg9hzZFzNkQ55sQy6R4uozqfkQ8MRMmnCV7hgq5q",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "http://collection.link",
"files": [],
"metadata": {
"name": "Test core collection",
"symbol": ""
},
"links": {}
},
"authorities": [
{
"address": "3VvLDXqJbw3heyRwFxv8MmurPznmDVUJS9gPMX2BDqfM",
"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": "single",
"owner": "3VvLDXqJbw3heyRwFxv8MmurPznmDVUJS9gPMX2BDqfM"
},
"supply": null,
"mutable": true,
"burnt": false,
"lamports": 1524240,
"executable": false,
"rent_epoch": 18446744073709551615,
"plugins": {},
"mpl_core_info": {
"num_minted": 1,
"current_size": 1,
"plugins_json_version": 1
},
"external_plugins": []
},
{
"interface": "V1_NFT",
"id": "91tabY8dzm3HfSgDujeyEfT6p94sV39iW2T8R9u5CMMo",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "https://nft",
"files": [],
"metadata": {
"name": "Test regular NFT",
"symbol": "REG_NFT",
"token_standard": "NonFungible"
},
"links": {}
},
"authorities": [
{
"address": "3VvLDXqJbw3heyRwFxv8MmurPznmDVUJS9gPMX2BDqfM",
"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": "single",
"owner": "3VvLDXqJbw3heyRwFxv8MmurPznmDVUJS9gPMX2BDqfM"
},
"supply": {
"print_max_supply": 0,
"print_current_supply": 0,
"edition_nonce": 252
},
"mutable": true,
"burnt": false,
"lamports": 15115600,
"executable": false,
"metadata_owner": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
"rent_epoch": 18446744073709551615,
"token_info": {
"supply": 1,
"decimals": 0,
"token_program": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"mint_authority": "EKadZQBg35Kst9qzkm7fLXzGPFeCQMaAhuiYttVzgYv8",
"freeze_authority": "EKadZQBg35Kst9qzkm7fLXzGPFeCQMaAhuiYttVzgYv8"
}
}
]
}
Loading