Skip to content

Commit

Permalink
Format rust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bitzoic committed Nov 24, 2023
1 parent ed25429 commit ceb0d77
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 28 deletions.
6 changes: 3 additions & 3 deletions tests/src/admin/tests/functions/add_admin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::admin::tests::utils::{
abi_calls::{is_admin, add_admin, set_ownership},
abi_calls::{add_admin, is_admin, set_ownership},
test_helpers::setup,
};
use fuels::types::Identity;
Expand Down Expand Up @@ -35,7 +35,7 @@ mod success {

set_admin(&owner.contract, admin1_identity.clone()).await;
set_admin(&owner.contract, admin2_identity.clone()).await;

assert!(is_admin(&owner.contract, admin1_identity.clone()).await);
assert!(is_admin(&owner.contract, admin2_identity.clone()).await);
}
Expand All @@ -53,7 +53,7 @@ mod reverts {
let owner_identity = Identity::Address(owner.wallet.address().into());
let admin1_identity = Identity::Address(admin1.wallet.address().into());
set_ownership(&owner.contract, owner_identity.clone()).await;

set_admin(&admin1.contract, admin1_identity.clone()).await;
}
}
4 changes: 2 additions & 2 deletions tests/src/admin/tests/functions/is_admin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::admin::tests::utils::{
abi_calls::{is_admin, add_admin, set_ownership},
abi_calls::{add_admin, is_admin, set_ownership},
test_helpers::setup,
};
use fuels::types::Identity;
Expand Down Expand Up @@ -35,7 +35,7 @@ mod success {

set_admin(&owner.contract, admin1_identity.clone()).await;
set_admin(&owner.contract, admin2_identity.clone()).await;

assert!(is_admin(&owner.contract, admin1_identity.clone()).await);
assert!(is_admin(&owner.contract, admin2_identity.clone()).await);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/src/admin/tests/functions/only_admin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::admin::tests::utils::{
abi_calls::{only_admin, add_admin, set_ownership},
abi_calls::{add_admin, only_admin, set_ownership},
test_helpers::setup,
};
use fuels::types::Identity;
Expand Down
2 changes: 1 addition & 1 deletion tests/src/admin/tests/functions/only_owner_or_admin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::admin::tests::utils::{
abi_calls::{only_owner_or_admin, add_admin, set_ownership},
abi_calls::{add_admin, only_owner_or_admin, set_ownership},
test_helpers::setup,
};
use fuels::types::Identity;
Expand Down
4 changes: 2 additions & 2 deletions tests/src/admin/tests/functions/remove_admin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::admin::tests::utils::{
abi_calls::{is_admin, add_admin, remove_admin, set_ownership},
abi_calls::{add_admin, is_admin, remove_admin, set_ownership},
test_helpers::setup,
};
use fuels::types::Identity;
Expand Down Expand Up @@ -39,4 +39,4 @@ mod reverts {

remove_admin(&admin1.contract, admin1_identity.clone()).await;
}
}
}
25 changes: 6 additions & 19 deletions tests/src/admin/tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ pub mod abi_calls {
.unwrap()
}

pub async fn is_admin(
contract: &AdminLib<WalletUnlocked>,
admin: Identity,
) -> bool {
pub async fn is_admin(contract: &AdminLib<WalletUnlocked>, admin: Identity) -> bool {
contract
.methods()
.is_admin(admin)
Expand All @@ -59,20 +56,11 @@ pub mod abi_calls {
.value
}

pub async fn only_admin(
contract: &AdminLib<WalletUnlocked>,
) -> FuelCallResponse<()> {
contract
.methods()
.only_admin()
.call()
.await
.unwrap()
pub async fn only_admin(contract: &AdminLib<WalletUnlocked>) -> FuelCallResponse<()> {
contract.methods().only_admin().call().await.unwrap()
}

pub async fn only_owner_or_admin(
contract: &AdminLib<WalletUnlocked>,
) -> FuelCallResponse<()> {
pub async fn only_owner_or_admin(contract: &AdminLib<WalletUnlocked>) -> FuelCallResponse<()> {
contract
.methods()
.only_owner_or_admin()
Expand Down Expand Up @@ -119,9 +107,8 @@ pub mod test_helpers {
let wallet3 = wallets.pop().unwrap();
let wallet4 = wallets.pop().unwrap();

let storage_configuration = StorageConfiguration::load_from(
"src/admin/out/debug/admin_test-storage_slots.json",
);
let storage_configuration =
StorageConfiguration::load_from("src/admin/out/debug/admin_test-storage_slots.json");
let id = Contract::load_from(
"src/admin/out/debug/admin_test.bin",
LoadConfiguration::default().set_storage_configuration(storage_configuration.unwrap()),
Expand Down

0 comments on commit ceb0d77

Please sign in to comment.