Skip to content

Commit

Permalink
adds a test where 2 users deploy 3 collections
Browse files Browse the repository at this point in the history
  • Loading branch information
gangov committed Aug 16, 2024
1 parent 18d27a8 commit aa096c5
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions contracts/deployer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,57 @@ fn test_deploy_collection_from_contract() {
);
}

#[test]
fn test_deploy_multiple_collections() {
let env = Env::default();
env.mock_all_auths();

let client =
CollectionsDeployerClient::new(&env, &env.register_contract(None, CollectionsDeployer));

// Upload the Wasm to be deployed from the deployer contract.
// This can also be called from within a contract if needed.
let wasm_hash = env.deployer().upload_contract_wasm(collections::WASM);

client.initialize(&wasm_hash);

let creator = Address::generate(&env);
let bob = Address::generate(&env);

let first_salt = BytesN::from_array(&env, &[0; 32]);
let first_collection_name = String::from_str(&env, "Stellar Kitties");

let second_salt = BytesN::from_array(&env, &[5; 32]);
let second_collection_name = String::from_str(&env, "Stellar Puppers");

let third_salt = BytesN::from_array(&env, &[10; 32]);
let third_collection_name = String::from_str(&env, "Horror of Cthulhu");

client.deploy_new_collection(&first_salt, &creator, &first_collection_name);
client.deploy_new_collection(&second_salt, &creator, &second_collection_name);
client.deploy_new_collection(&third_salt, &bob, &third_collection_name);

assert_eq!(
client.query_all_collections(),
vec![
&env,
first_collection_name.clone(),
second_collection_name.clone(),
third_collection_name.clone()
]
);

assert_eq!(
client.query_collection_by_creator(&creator),
vec![&env, first_collection_name, second_collection_name]
);

assert_eq!(
client.query_collection_by_creator(&bob),
vec![&env, third_collection_name]
);
}

#[test]
#[ignore = "once we rebase from main"]
#[should_panic(
Expand Down

0 comments on commit aa096c5

Please sign in to comment.