Skip to content

Commit

Permalink
fixes the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gangov committed Sep 18, 2024
1 parent 018c4de commit a63d829
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
4 changes: 2 additions & 2 deletions contracts/deployer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl CollectionsDeployer {
let _: Val = env.invoke_contract(&deployed_collection, &init_fn, init_fn_args);

save_collection_with_generic_key(&env, name.clone());
save_collection_with_admin_address_as_key(&env, admin, collection_addres, name);
save_collection_with_admin_address_as_key(&env, admin, deployed_collection.clone(), name);

deployed_collection
}
Expand Down Expand Up @@ -113,7 +113,7 @@ impl CollectionsDeployer {
// ---------- Storage types ----------

#[contracttype]
#[derive(Clone)]
#[derive(Clone, Debug)]
pub struct CollectionByCreatorResponse {
collection: Address,
name: String,
Expand Down
32 changes: 24 additions & 8 deletions contracts/deployer/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{CollectionsDeployer, CollectionsDeployerClient};
use crate::{CollectionByCreatorResponse, CollectionsDeployer, CollectionsDeployerClient};
#[cfg(test)]
use soroban_sdk::{testutils::Address as _, vec, Address, BytesN, Env, String};

Expand Down Expand Up @@ -33,12 +33,12 @@ fn test_deploy_collection_from_contract() {
let name = String::from_str(&env, "Stellar Kitties");
let symbol = String::from_str(&env, "STK");

client.deploy_new_collection(&salt, &creator, &name, &symbol);
let collection = client.deploy_new_collection(&salt, &creator, &name, &symbol);

assert_eq!(client.query_all_collections(), vec![&env, name.clone()]);
assert_eq!(
client.query_collection_by_creator(&creator),
vec![&env, name]
vec![&env, CollectionByCreatorResponse { collection, name }]
);
}

Expand Down Expand Up @@ -71,19 +71,19 @@ fn test_deploy_multiple_collections() {
let third_collection_name = String::from_str(&env, "Horror of Cthulhu");
let third_collection_symbol = String::from_str(&env, "HoC");

client.deploy_new_collection(
let first = client.deploy_new_collection(
&first_salt,
&creator,
&first_collection_name,
&first_collection_symbol,
);
client.deploy_new_collection(
let second = client.deploy_new_collection(
&second_salt,
&creator,
&second_collection_name,
&second_collection_symbol,
);
client.deploy_new_collection(
let third = client.deploy_new_collection(
&third_salt,
&bob,
&third_collection_name,
Expand All @@ -102,12 +102,28 @@ fn test_deploy_multiple_collections() {

assert_eq!(
client.query_collection_by_creator(&creator),
vec![&env, first_collection_name, second_collection_name]
vec![
&env,
CollectionByCreatorResponse {
collection: first,
name: first_collection_name,
},
CollectionByCreatorResponse {
collection: second,
name: second_collection_name,
},
]
);

assert_eq!(
client.query_collection_by_creator(&bob),
vec![&env, third_collection_name]
vec![
&env,
CollectionByCreatorResponse {
collection: third,
name: third_collection_name
}
]
);
}

Expand Down

0 comments on commit a63d829

Please sign in to comment.