Skip to content

Commit

Permalink
Added a possibility to do integration tests using Eclipse && Added te…
Browse files Browse the repository at this point in the history
…st for the case when fungible tokens are returned while only NFTs are requested
  • Loading branch information
kstepanovdev committed Jan 27, 2025
1 parent 0e29a10 commit a31e304
Show file tree
Hide file tree
Showing 20 changed files with 520 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,6 @@ jobs:
DATABASE_TEST_URL: "postgres://postgres:[email protected]:5432/postgres"
DEVNET_RPC_URL: ${{ secrets.SOLANA_DEVNET_RPC_URL }}
MAINNET_RPC_URL: ${{ secrets.SOLANA_MAINNET_RPC_URL }}
ECLIPSE_DEVNET_RPC_URL: ${{ secrets.SOLANA_ECLIPSE_DEVNET_RPC_URL }}
ECLIPSE_MAINNET_RPC_URL: ${{ secrets.SOLANA_ECLIPSE_MAINNET_RPC_URL }}
run: cargo test --features integration_tests -- --nocapture
4 changes: 2 additions & 2 deletions integration_tests/src/account_update_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async fn test_account_updates() {

setup.clean_up_data_bases().await;

index_nft(&setup, mint).await;
index_nft_accounts(&setup, get_nft_accounts(&setup, mint).await).await;

let response =
setup.das_api.get_asset(request.clone(), mutexed_tasks.clone()).await.unwrap();
Expand Down Expand Up @@ -217,7 +217,7 @@ async fn test_account_updates() {
for named_update in named_updates.clone() {
setup.clean_up_data_bases().await;

index_nft(&setup, mint).await;
index_nft_accounts(&setup, get_nft_accounts(&setup, mint).await).await;

let other_named_updates = named_updates
.clone()
Expand Down
10 changes: 5 additions & 5 deletions integration_tests/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ impl TestSetup {
let rpc_url = match opts.network.unwrap_or_default() {
Network::Mainnet => std::env::var("MAINNET_RPC_URL").unwrap(),
Network::Devnet => std::env::var("DEVNET_RPC_URL").unwrap(),
Network::EclipseMainnet => std::env::var("ECLIPSE_MAINNET_RPC_URL").unwrap(),
Network::EclipseDevnet => std::env::var("ECLIPSE_DEVNET_RPC_URL").unwrap(),
};
let client = Arc::new(RpcClient::new(rpc_url.to_string()));

Expand Down Expand Up @@ -537,6 +539,8 @@ pub enum Network {
#[default]
Mainnet,
Devnet,
EclipseMainnet,
EclipseDevnet,
}

#[derive(Clone, Copy, Debug)]
Expand All @@ -553,7 +557,7 @@ pub async fn index_seed_events(setup: &TestSetup, events: Vec<&SeedEvent>) {
index_and_sync_account_with_ordered_slot(setup, *account).await;
},
SeedEvent::Nft(mint) => {
index_nft(setup, *mint).await;
index_nft_accounts(setup, get_nft_accounts(setup, *mint).await).await;
},
SeedEvent::Signature(sig) => {
index_transaction(setup, *sig).await;
Expand Down Expand Up @@ -688,10 +692,6 @@ async fn index_token_mint(setup: &TestSetup, mint: Pubkey) {
}
}

pub async fn index_nft(setup: &TestSetup, mint: Pubkey) {
index_nft_accounts(setup, get_nft_accounts(setup, mint).await).await;
}

pub async fn index_nft_accounts(setup: &TestSetup, nft_accounts: NftAccounts) {
for account in [nft_accounts.mint, nft_accounts.metadata, nft_accounts.token] {
index_account(setup, account).await;
Expand Down
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.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-�����do�ƲIރ��@�4��z%�x
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
� �d�b��GOu�Cޥ;�*Ү�kұe�L��
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��kT�SV���1�T�VVج�!��'6�NG0�
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Gh�C��Eـ��;���l�卣�S�}q���
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8�����%v1�YJ *�/h�͛�!���<��
48 changes: 48 additions & 0 deletions integration_tests/src/regular_nft_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,51 @@ async fn get_asset_nft_token_22_with_metadata() {

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

#[tokio::test]
#[serial]
#[named]
async fn test_requested_non_fungibles_are_non_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 = seed_token_mints([
"DvpMQyF8sT6hPBewQf6VrVESw6L1zewPyNit1CSt1tDJ",
"9qA21TR9QTsQeR5sP6L2PytjgxXcVRSyqUY5vRcUogom",
"8WKGo1z9k3PjTsQw5GDQmvAbKwuRGtb4APkCneH8AVY1",
"7ZkXycbrAhVzeB9ngnjcCdjk5bxTJYzscSZMhRRBx3QB",
"75peBtH5MwfA5t9uhr51AYL7MR5DbPJ5xQ7wizzvowUH",
]);

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

let request = r#"
{
"limit": 500,
"ownerAddress": "EcxjN4mea6Ah9WSqZhLtSJJCZcxY73Vaz6UVHFZZ5Ttz",
"tokenType": "nonFungible",
"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, "V1_NFT");
true
});

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

0 comments on commit a31e304

Please sign in to comment.