Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
chore(test): test scenario for granting and revoking trusted manager …
Browse files Browse the repository at this point in the history
…permission
  • Loading branch information
yahortsaryk committed Jun 29, 2023
1 parent c31e4ab commit 26af454
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions bucket/ddc_bucket/tests/test_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,49 @@ fn cluster_list_ok() {
}


#[ink::test]
fn grant_and_revoke_trusted_manager_permission_ok() {
let mut contract = setup_contract();

let grantor = AccountId::from([0x92, 0xad, 0x47, 0xdf, 0xb9, 0x6b, 0x2b, 0x4a, 0xd5, 0xb0, 0xe3, 0x6d, 0x56, 0x33, 0x27, 0xfd, 0xcf, 0x9d, 0xee, 0x06, 0xf4, 0x0d, 0x41, 0x48, 0xe1, 0x6a, 0x5c, 0xaa, 0x6c, 0x0d, 0x17, 0x4b]);
set_balance(grantor, 1000 * TOKEN);

let grantee = AccountId::from([0x1a, 0xa6, 0x69, 0xb4, 0x23, 0xe4, 0x8b, 0xbd, 0xc4, 0x65, 0xe3, 0xee, 0x17, 0xfd, 0x5b, 0x6d, 0x6f, 0xae, 0x6f, 0xf1, 0x40, 0x52, 0x03, 0x65, 0x02, 0xe4, 0x50, 0xb5, 0x0b, 0x34, 0xe2, 0x7a]);
set_balance(grantee, 1000 * TOKEN);

let permission = Permission::ClusterManagerTrustedBy(grantor);

assert!(!contract.has_permission(grantee, permission));

set_caller(grantor);
contract.grant_trusted_manager_permission(grantee)?;

assert!(contract.has_permission(grantee, permission));

assert!(
matches!(get_events().pop().unwrap(), Event::PermissionGranted(ev) if ev ==
PermissionGranted {
account_id: grantee,
permission
})
);

set_caller(grantor);
contract.revoke_trusted_manager_permission(grantee)?;

assert!(!contract.has_permission(grantee, permission));

assert!(
matches!(get_events().pop().unwrap(), Event::PermissionRevoked(ev) if ev ==
PermissionRevoked {
account_id: grantee,
permission
})
);

}


#[ink::test]
fn cluster_distribute_cdn_revenue_ok() {
// todo: this test scenario must be revised as it does pure printing without any assertion
Expand Down

0 comments on commit 26af454

Please sign in to comment.