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-999 Add new 2 test cases for cNFT #328

Merged
merged 1 commit into from
Nov 29, 2024
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
185 changes: 172 additions & 13 deletions integration_tests/src/cnft_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub async fn run_get_asset_scenario_test(
asset_id: &str,
seeds: Vec<SeedEvent>,
order: Order,
options: Options,
) {
let seed_permutations: Vec<Vec<&SeedEvent>> = match order {
Order::AllPermutations => seeds.iter().permutations(seeds.len()).collect::<Vec<_>>(),
Expand All @@ -30,7 +31,7 @@ pub async fn run_get_asset_scenario_test(
index_seed_events(setup, events).await;
let request = GetAsset {
id: asset_id.to_string(),
options: Options::default(),
options: options.clone(),
};

let response = setup
Expand Down Expand Up @@ -70,7 +71,14 @@ async fn test_asset_decompress() {
seed_nft("Az9QTysJj1LW1F7zkYF21HgBj3FRpq3zpxTFdPnAJYm8"),
];

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand All @@ -96,7 +104,14 @@ async fn test_cnft_scenario_mint_update_metadata() {
seed_txn("3bsL5zmLKvhN9Je4snTKxjFSpmXEEg2cvMHm2rCNgaEYkNXBqJTA4N7QmvBSWPiNUQPtzJSYzpQYX92NowV3L7vN"),
];

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand Down Expand Up @@ -124,7 +139,14 @@ async fn test_cnft_scenario_mint_update_metadata_remove_creators() {
seed_txn("41YW187sn6Z2dXfqz6zSbnPtQoE826cCSgTLnMLKa9rH1xrCqAXBQNwKnzjGc9wjU5RtMCqKhy2eMN2TjuYC8veB"),
];

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand Down Expand Up @@ -202,6 +224,7 @@ async fn test_mint_no_json_uri() {
"DFRJ4PwAze1mMQccRmdyc46yQpEVd4FPiwtAVgzGCs7g",
seeds,
Order::Forward,
Options::default(),
)
.await;
}
Expand All @@ -228,7 +251,14 @@ async fn test_mint_delegate_transfer() {
"5Q8TAMMkMTHEM2BHyD2fp2sVdYKByFeATzM2mHF6Xbbar33WaeuygPKGYCWiDEt3MZU1mUrq1ePnT9o4Pa318p8w",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand All @@ -253,7 +283,14 @@ async fn test_mint_redeem_cancel_redeem() {
"32FpSe6r9jnFNjjvbx2PPQdZqs5KpMoF6yawiRW1F6ctu1kmx2B4sLDBGjsthVQtmnhaJVrqdtmUP893FwXCbqY5",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand Down Expand Up @@ -283,7 +320,14 @@ async fn test_mint_redeem() {
// "3Ct9n9hv5PWEYbsrgDdUDqegzsnX2n5jYRxkq5YafFAueup8mTYmN4nHhNCaEwVyVAVqNssr4fizdg9wRavT7ydE",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand All @@ -308,7 +352,14 @@ async fn test_mint_transfer_burn() {
"KHNhLijkAMeKeKm6kpbk3go6q9uMF3zmfCoYSBgERe8qJDW8q5ANpnkyBuyVkychXCeWzRY8i5EtKfeGaDDU23w",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand All @@ -333,7 +384,14 @@ async fn test_mint_transfer_noop() {
"5bNyZfmxLVP9cKc6GjvozExrSt4F1QFt4PP992pQwT8FFHdWsX3ZFNvwurfU2xpDYtQ7qAUxVahGCraXMevRH8p1",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand All @@ -358,7 +416,14 @@ async fn test_mint_transfer_transfer() {
"34xjcNf3rZFKz381hKpFLqxpojaDgXEpCqH5qcpTXLaJnDbtqRz35wiuMF1cAgvJGLzYYrwaMvCK1D7LxYsdpMU1",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand All @@ -382,7 +447,14 @@ async fn test_mint_verify_creator() {
"4xrw5UwQSxxPzVxge6fbtmgLNsT2amaGrwpZFE95peRbnHGpxWtS2fF7whXW2xma4i2KDXdneztJZCAtgGZKTw11",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand All @@ -406,7 +478,14 @@ async fn test_mint_verify_collection() {
"5ZKjPxm3WAZzuqqkCDjgKpm9b5XjB9cuvv68JvXxWThvJaJxcMJgpSbYs4gDA9dGJyeLzsgNtnS6oubANF1KbBmt",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
Expand All @@ -431,5 +510,85 @@ async fn test_mint_transfer_mpl_programs() {
"T571TWE76frw6mWxYoHDrTdxYq7hJSyCtVEG4qmemPPtsc1CCKdknn9rTMAVcdeukLfwB1G97LZLH8eHLvuByoA",
]);

run_get_asset_scenario_test(&setup, asset_id, seeds, Order::AllPermutations).await;
run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options::default(),
)
.await;
}

#[tokio::test]
#[serial]
#[named]
async fn test_mint_to_collection_unverify_collection() {
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 asset_id = "2gEbvG3Cb6JRaGWAx5e85Bf5z4u37EURBeyPBqXDzZoY";

let seeds: Vec<SeedEvent> = seed_txns([
"tzXASugk8578bmtA3JAFQLEfcVQp3Np3rU9fyFas2Svk8nyBHXJnf7PdqebGNsSTwx6CEWpDCP5oLoCDcmbP35B",
"7nK9a2DSDZ4Gh6DatmxGJmuLiDEswaY9bYSSPTtQppk7PtLKXYE84jWzm7AC4G1fpa831GaXuXcn5n5ybWqB4e5",
]);

run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options {
show_unverified_collections: true,
show_collection_metadata: false,
show_inscription: false,
show_fungible: false,
},
)
.await;
}

#[tokio::test]
#[serial]
#[named]
async fn test_mint_verify_collection_unverify_collection() {
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 asset_id = "BiHHJ1gKV4exTjPe7PE6aydgMVqRUzzz8aeWYCGhZJ4s";

let seeds: Vec<SeedEvent> = seed_txns([
"5uWXt8JAhuP2XQ2nYJTq8Ndp34fdG3vmJ7DJnb3bE6iyrZZ6jeuN9w5jZvKrduMDu4zKyQU7A3JtswhKxE3hjKBk",
"4hQQsDKgDx5PpZR7nGvxKsLSvX4J7voaiJC3ag7dPuu4HY5kbvaqD2gyeHbdja1f22ypmzouRNpuo6sbyGDSSgya",
"5k71fZRpRagY45ZYu13Q8C3Bmw6KFPBkRmbBx2NuYk7roVtvM8P16WouCZtnkhRCyKyQHSgHKyTY92t9aq2tyLdd",
]);

run_get_asset_scenario_test(
&setup,
asset_id,
seeds,
Order::AllPermutations,
Options {
show_unverified_collections: true,
show_collection_metadata: false,
show_inscription: false,
show_fungible: false,
},
)
.await;
}
2 changes: 1 addition & 1 deletion integration_tests/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use tokio::{
};
use usecase::proofs::MaybeProofChecker;

use tracing::{error, info};
use serde::de::DeserializeOwned;
use solana_account_decoder::{UiAccount, UiAccountEncoding};
use solana_client::{
Expand All @@ -51,6 +50,7 @@ use solana_sdk::{
};
use solana_transaction_status::{EncodedConfirmedTransactionWithStatusMeta, UiTransactionEncoding};
use std::{fmt, time::Duration};
use tracing::{error, info};

use std::path::PathBuf;

Expand Down
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,80 @@
---
source: integration_tests/src/cnft_tests.rs
assertion_line: 41
expression: response
snapshot_kind: text
---
{
"interface": "V1_NFT",
"id": "2gEbvG3Cb6JRaGWAx5e85Bf5z4u37EURBeyPBqXDzZoY",
"content": {
"$schema": "https://schema.metaplex.com/nft1.0.json",
"json_uri": "https://metaplex.com",
"files": [],
"metadata": {
"name": "test",
"symbol": "TST",
"token_standard": "NonFungible"
},
"links": {}
},
"authorities": [
{
"address": "AR6is91KeUbiYrSCrHAQfBk3J2jApxefAiWMm55nD9o5",
"scopes": [
"full"
]
}
],
"compression": {
"eligible": false,
"compressed": true,
"data_hash": "8M8DpVvA1aGNMV6xMViDyEF9oS89VKqbWsxBfUNkGGQ9",
"creator_hash": "4q4TdVGLUpKPvHqZT57xM66gZyAjViQdPPsZKoHPRZni",
"asset_hash": "2MYeWSm5mv3FXUyTDeD247uCfEMzpDRaU2ZYMMhRDjga",
"tree": "ChxiXfVhkP7LYminiaFJRLQmRigRmLPw3iduEAvjpz3L",
"seq": 2,
"leaf_id": 0
},
"grouping": [
{
"group_key": "collection",
"group_value": "DdyrHTfN4wskbqTm3NDbAvRDsqiewzkuMboMRYJmNG6A",
"verified": false
}
],
"royalty": {
"royalty_model": "creators",
"target": null,
"percent": 0.0,
"basis_points": 0,
"primary_sale_happened": false,
"locked": false
},
"creators": [
{
"address": "Fq4HDXfutKjEZ7zZP2JmKboSm2ZsYsKEJ7BLQAfrpNcc",
"share": 55,
"verified": false
},
{
"address": "CxPipfKpggvxG5ne5SD23c2JFz3TMNqrN1Vjr1vj8NFK",
"share": 45,
"verified": false
}
],
"ownership": {
"frozen": false,
"delegated": false,
"delegate": null,
"ownership_model": "single",
"owner": "Fq4HDXfutKjEZ7zZP2JmKboSm2ZsYsKEJ7BLQAfrpNcc"
},
"supply": {
"print_max_supply": 0,
"print_current_supply": 0,
"edition_nonce": 0
},
"mutable": false,
"burnt": false
}
Loading