-
Notifications
You must be signed in to change notification settings - Fork 8
Implement Batch Verification #8
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
Changes from all commits
f1496ef
966d5ae
441fa4e
9a1487f
f142583
9f50c9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,5 @@ pub enum RegistryError { | |
| ExpertNotFound = 4, | ||
| AlreadyVerified = 5, | ||
| AlreadyBanned = 6, | ||
| ExpertVecMax = 7, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,8 @@ | |
| extern crate std; | ||
|
|
||
| use crate::{IdentityRegistryContract, IdentityRegistryContractClient}; | ||
| use soroban_sdk::{Env, testutils::Address as _, Symbol, Address, IntoVal, TryIntoVal}; | ||
| use crate::{storage, types::ExpertStatus}; | ||
| use soroban_sdk::{Env, testutils::Address as _, Symbol, Address, IntoVal, TryIntoVal, Vec, vec}; | ||
| use soroban_sdk::testutils::{AuthorizedFunction, AuthorizedInvocation, Events}; | ||
|
|
||
| #[test] | ||
|
|
@@ -24,6 +25,77 @@ fn test_initialization() { | |
| assert!(res_duplicate.is_err()); | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic] | ||
| fn test_batch_verification_no_admin() { | ||
| let env = Env::default(); | ||
|
|
||
| let contract_id = env.register_contract(None, IdentityRegistryContract); | ||
| let client = IdentityRegistryContractClient::new(&env, &contract_id); | ||
|
|
||
| let experts = vec![&env, Address::generate(&env), Address::generate(&env), Address::generate(&env)]; | ||
|
|
||
| client.batch_add_experts(&experts); | ||
| } | ||
|
Comment on lines
28
to
39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π§© Analysis chainπ Script executed: git ls-files contracts/identity-registry-contract/src/ | head -20Repository: LightForgeHub/SkillSphere-Contracts Length of output: 431 π Script executed: find contracts -name "test.rs" -o -name "lib.rs" | head -10Repository: LightForgeHub/SkillSphere-Contracts Length of output: 264 π Script executed: find . -type f -name "*.rs" | grep -E "(test|contract)" | head -20Repository: LightForgeHub/SkillSphere-Contracts Length of output: 687 π Script executed: cat -n contracts/identity-registry-contract/src/test.rs | head -80Repository: LightForgeHub/SkillSphere-Contracts Length of output: 3395 π Script executed: cat -n contracts/identity-registry-contract/src/contract.rs | head -100Repository: LightForgeHub/SkillSphere-Contracts Length of output: 487 π Script executed: cat -n contracts/identity-registry-contract/src/contract.rs | grep -A 30 "batch_add_experts"Repository: LightForgeHub/SkillSphere-Contracts Length of output: 61 π Script executed: cat -n contracts/identity-registry-contract/src/contract.rs | grep -A 30 "pub fn batch"Repository: LightForgeHub/SkillSphere-Contracts Length of output: 61 π Script executed: wc -l contracts/identity-registry-contract/src/contract.rsRepository: LightForgeHub/SkillSphere-Contracts Length of output: 134 π Script executed: cat -n contracts/identity-registry-contract/src/contract.rsRepository: LightForgeHub/SkillSphere-Contracts Length of output: 487 π Script executed: cat -n contracts/identity-registry-contract/src/lib.rsRepository: LightForgeHub/SkillSphere-Contracts Length of output: 1679 This test doesn't actually verify admin auth. The panic occurs from the Remove Suggested fix #[test]
#[should_panic]
fn test_batch_verification_no_admin() {
let env = Env::default();
- env.mock_all_auths();
let contract_id = env.register_contract(None, IdentityRegistryContract);
let client = IdentityRegistryContractClient::new(&env, &contract_id);
+ let admin = Address::generate(&env);
+ client.init(&admin);
+
let experts = vec![&env, Address::generate(&env), Address::generate(&env), Address::generate(&env)];
client.batch_add_experts(&experts);
}π€ Prompt for AI Agents |
||
|
|
||
| #[test] | ||
| fn test_batch_verification_check_status() { | ||
| let env = Env::default(); | ||
| env.mock_all_auths(); | ||
|
|
||
| let contract_id = env.register_contract(None, IdentityRegistryContract); | ||
| let client = IdentityRegistryContractClient::new(&env, &contract_id); | ||
|
|
||
| let admin = soroban_sdk::Address::generate(&env); | ||
| client.init(&admin); | ||
|
|
||
| let e1: Address = Address::generate(&env); | ||
| let e2 = Address::generate(&env); | ||
| let e3 = Address::generate(&env); | ||
| let e4 = Address::generate(&env); | ||
| let e5 = Address::generate(&env); | ||
|
|
||
| let experts = vec![&env, e1.clone(), e2.clone(), e3.clone(), e4.clone(), e5.clone()]; | ||
|
|
||
| client.batch_add_experts(&experts); | ||
|
|
||
| env.as_contract(&contract_id, ||{ | ||
| assert_eq!(storage::get_expert_status(&env, &e1), ExpertStatus::Verified); | ||
| assert_eq!(storage::get_expert_status(&env, &e2), ExpertStatus::Verified); | ||
| assert_eq!(storage::get_expert_status(&env, &e3), ExpertStatus::Verified); | ||
| assert_eq!(storage::get_expert_status(&env, &e4), ExpertStatus::Verified); | ||
| assert_eq!(storage::get_expert_status(&env, &e5), ExpertStatus::Verified); | ||
| }) | ||
| } | ||
|
|
||
| #[test] | ||
| #[should_panic(expected = "Error(Contract, #7)")] | ||
| fn test_batch_verification_max_vec() { | ||
| let env = Env::default(); | ||
| env.mock_all_auths(); | ||
|
|
||
| let contract_id = env.register_contract(None, IdentityRegistryContract); | ||
| let client = IdentityRegistryContractClient::new(&env, &contract_id); | ||
|
|
||
| let admin = soroban_sdk::Address::generate(&env); | ||
| client.init(&admin); | ||
|
|
||
| let e1 = Address::generate(&env); | ||
| let e2 = Address::generate(&env); | ||
| let e3 = Address::generate(&env); | ||
| let e4 = Address::generate(&env); | ||
|
|
||
| let experts = vec![&env, e1.clone(), e2.clone(), e3.clone(), e4.clone(), | ||
| e1.clone(), e2.clone(), e3.clone(), e4.clone(), | ||
| e1.clone(), e2.clone(), e3.clone(), e4.clone(), | ||
| e1.clone(), e2.clone(), e3.clone(), e4.clone(), | ||
| e1.clone(), e2.clone(), e3.clone(), e4.clone(), | ||
| e1.clone(), e2.clone(), e3.clone(), e4.clone() | ||
| ]; | ||
|
|
||
| client.batch_add_experts(&experts); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_add_expert() { | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let env = Env::default(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.