From 1f1e0b53807f4c45f736c13a5e7d8e9dfa363073 Mon Sep 17 00:00:00 2001 From: Mukul Kolpe Date: Wed, 22 Jan 2025 06:56:53 +0530 Subject: [PATCH] test: standardize test function names across codebase --- contracts/src/access/control.rs | 48 ++--- contracts/src/access/ownable.rs | 14 +- contracts/src/access/ownable_two_step.rs | 26 +-- contracts/src/finance/vesting_wallet.rs | 16 +- .../src/token/erc1155/extensions/burnable.rs | 20 +-- .../token/erc1155/extensions/metadata_uri.rs | 4 +- .../src/token/erc1155/extensions/supply.rs | 20 +-- .../token/erc1155/extensions/uri_storage.rs | 22 +-- contracts/src/token/erc1155/mod.rs | 94 +++++----- .../src/token/erc20/extensions/burnable.rs | 12 +- .../src/token/erc20/extensions/capped.rs | 2 +- .../src/token/erc20/extensions/flash_mint.rs | 16 +- .../src/token/erc20/extensions/metadata.rs | 2 +- contracts/src/token/erc20/mod.rs | 40 ++--- contracts/src/token/erc20/utils/safe_erc20.rs | 12 +- .../src/token/erc721/extensions/burnable.rs | 12 +- .../token/erc721/extensions/consecutive.rs | 48 ++--- .../src/token/erc721/extensions/enumerable.rs | 24 +-- .../src/token/erc721/extensions/metadata.rs | 4 +- .../token/erc721/extensions/uri_storage.rs | 4 +- contracts/src/token/erc721/mod.rs | 166 ++++++++---------- contracts/src/utils/cryptography/ecdsa.rs | 6 +- contracts/src/utils/cryptography/eip712.rs | 4 +- contracts/src/utils/math/alloy.rs | 4 +- contracts/src/utils/nonces.rs | 8 +- contracts/src/utils/pausable.rs | 18 +- contracts/src/utils/structs/bitmap.rs | 6 +- .../src/utils/structs/checkpoints/mod.rs | 16 +- .../access-control/tests/access_control.rs | 42 ++--- examples/ecdsa/tests/ecdsa.rs | 20 +-- .../tests/erc1155-metadata-uri.rs | 16 +- .../erc1155-supply/tests/erc1155-supply.rs | 61 ++++--- examples/erc1155/tests/erc1155.rs | 144 ++++++++------- .../tests/erc20-flash-mint.rs | 42 +++-- examples/erc20-permit/tests/erc20permit.rs | 35 ++-- examples/erc20/tests/erc20.rs | 69 ++++---- .../tests/erc721-consecutive.rs | 19 +- examples/erc721-metadata/tests/erc721.rs | 18 +- examples/erc721/tests/erc721.rs | 166 ++++++++++-------- .../tests/ownable_two_step.rs | 16 +- examples/ownable/tests/ownable.rs | 19 +- examples/poseidon/tests/poseidon.rs | 2 +- .../safe-erc20/tests/address_with_no_code.rs | 10 +- examples/safe-erc20/tests/erc20.rs | 28 +-- .../tests/erc20_that_always_returns_false.rs | 13 +- .../tests/erc20_that_does_not_return.rs | 28 +-- .../tests/usdt_approval_behavior.rs | 9 +- .../vesting-wallet/tests/vesting-wallet.rs | 54 ++++-- lib/crypto/src/bigint.rs | 6 +- lib/crypto/src/bits.rs | 2 +- lib/crypto/src/field/fp.rs | 20 +-- lib/crypto/src/hash.rs | 4 +- lib/crypto/src/merkle.rs | 20 +-- lib/crypto/src/poseidon2/instance/babybear.rs | 2 +- lib/crypto/src/poseidon2/instance/bls12.rs | 2 +- lib/crypto/src/poseidon2/instance/bn256.rs | 2 +- .../src/poseidon2/instance/goldilocks.rs | 2 +- lib/crypto/src/poseidon2/instance/pallas.rs | 2 +- lib/crypto/src/poseidon2/instance/vesta.rs | 2 +- 59 files changed, 805 insertions(+), 738 deletions(-) diff --git a/contracts/src/access/control.rs b/contracts/src/access/control.rs index 6942a1d7a..3ef6447ae 100644 --- a/contracts/src/access/control.rs +++ b/contracts/src/access/control.rs @@ -412,26 +412,26 @@ mod tests { } #[motsu::test] - fn default_role_is_default_admin(contract: AccessControl) { + fn default_admin_role_success(contract: AccessControl) { let role_admin = contract.get_role_admin(ROLE.into()); assert_eq!(role_admin, AccessControl::DEFAULT_ADMIN_ROLE); } #[motsu::test] - fn default_admin_roles_admin_is_itself(contract: AccessControl) { + fn default_admin_role_admin_success(contract: AccessControl) { const DEFAULT_ADMIN_ROLE: [u8; 32] = AccessControl::DEFAULT_ADMIN_ROLE; let role_admin = contract.get_role_admin(DEFAULT_ADMIN_ROLE.into()); assert_eq!(role_admin, DEFAULT_ADMIN_ROLE); } #[motsu::test] - fn non_admin_cannot_grant_role_to_others(contract: AccessControl) { + fn grant_role_reverts_when_not_admin(contract: AccessControl) { let err = contract.grant_role(ROLE.into(), ALICE).unwrap_err(); assert!(matches!(err, Error::UnauthorizedAccount(_))); } #[motsu::test] - fn accounts_can_be_granted_roles_multiple_times(contract: AccessControl) { + fn grant_role_success_with_multiple_grants(contract: AccessControl) { _grant_role_to_msg_sender(contract, AccessControl::DEFAULT_ADMIN_ROLE); contract.grant_role(ROLE.into(), ALICE).unwrap(); @@ -441,7 +441,7 @@ mod tests { } #[motsu::test] - fn not_granted_roles_can_be_revoked(contract: AccessControl) { + fn revoke_role_success_with_ungranted_role(contract: AccessControl) { _grant_role_to_msg_sender(contract, AccessControl::DEFAULT_ADMIN_ROLE); let has_role = contract.has_role(ROLE.into(), ALICE); @@ -452,7 +452,7 @@ mod tests { } #[motsu::test] - fn admin_can_revoke_role(contract: AccessControl) { + fn revoke_role_success(contract: AccessControl) { _grant_role_to_msg_sender(contract, AccessControl::DEFAULT_ADMIN_ROLE); contract._roles.setter(ROLE.into()).has_role.insert(ALICE, true); @@ -464,7 +464,7 @@ mod tests { } #[motsu::test] - fn non_admin_cannot_revoke_role(contract: AccessControl) { + fn revoke_role_reverts_when_not_admin(contract: AccessControl) { contract._roles.setter(ROLE.into()).has_role.insert(ALICE, true); let has_role = contract.has_role(ROLE.into(), ALICE); @@ -474,7 +474,7 @@ mod tests { } #[motsu::test] - fn roles_can_be_revoked_multiple_times(contract: AccessControl) { + fn revoke_role_success_with_multiple_revokes(contract: AccessControl) { _grant_role_to_msg_sender(contract, AccessControl::DEFAULT_ADMIN_ROLE); contract.revoke_role(ROLE.into(), ALICE).unwrap(); @@ -484,7 +484,7 @@ mod tests { } #[motsu::test] - fn bearer_can_renounce_role(contract: AccessControl) { + fn renounce_role_success(contract: AccessControl) { _grant_role_to_msg_sender(contract, ROLE); let has_role = contract.has_role(ROLE.into(), msg::sender()); @@ -495,14 +495,14 @@ mod tests { } #[motsu::test] - fn only_sender_can_renounce(contract: AccessControl) { + fn renounce_role_reverts_when_not_sender(contract: AccessControl) { _grant_role_to_msg_sender(contract, ROLE); let err = contract.renounce_role(ROLE.into(), ALICE).unwrap_err(); assert!(matches!(err, Error::BadConfirmation(_))); } #[motsu::test] - fn roles_can_be_renounced_multiple_times(contract: AccessControl) { + fn renounce_role_success_with_multiple_renounces(contract: AccessControl) { _grant_role_to_msg_sender(contract, ROLE); let sender = msg::sender(); @@ -513,7 +513,7 @@ mod tests { } #[motsu::test] - fn a_roles_admin_role_can_change(contract: AccessControl) { + fn set_role_admin_success(contract: AccessControl) { contract._set_role_admin(ROLE.into(), OTHER_ROLE.into()); _grant_role_to_msg_sender(contract, OTHER_ROLE); @@ -522,7 +522,7 @@ mod tests { } #[motsu::test] - fn the_new_admin_can_grant_roles(contract: AccessControl) { + fn role_admin_change_success_with_new_grant(contract: AccessControl) { contract._set_role_admin(ROLE.into(), OTHER_ROLE.into()); _grant_role_to_msg_sender(contract, OTHER_ROLE); @@ -532,7 +532,7 @@ mod tests { } #[motsu::test] - fn the_new_admin_can_revoke_roles(contract: AccessControl) { + fn role_admin_change_success_with_new_revoke(contract: AccessControl) { contract._set_role_admin(ROLE.into(), OTHER_ROLE.into()); _grant_role_to_msg_sender(contract, OTHER_ROLE); @@ -543,7 +543,9 @@ mod tests { } #[motsu::test] - fn previous_admins_no_longer_grant_roles(contract: AccessControl) { + fn role_admin_change_reverts_when_old_admin_grants( + contract: AccessControl, + ) { _grant_role_to_msg_sender(contract, ROLE); contract._set_role_admin(ROLE.into(), OTHER_ROLE.into()); @@ -552,7 +554,9 @@ mod tests { } #[motsu::test] - fn previous_admins_no_longer_revoke_roles(contract: AccessControl) { + fn role_admin_change_reverts_when_old_admin_revokes( + contract: AccessControl, + ) { _grant_role_to_msg_sender(contract, ROLE); contract._set_role_admin(ROLE.into(), OTHER_ROLE.into()); @@ -561,13 +565,13 @@ mod tests { } #[motsu::test] - fn does_not_revert_if_sender_has_role(contract: AccessControl) { + fn check_role_success(contract: AccessControl) { _grant_role_to_msg_sender(contract, ROLE); contract._check_role(ROLE.into(), msg::sender()).unwrap(); } #[motsu::test] - fn reverts_if_sender_doesnt_have_role(contract: AccessControl) { + fn check_role_reverts_when_no_role(contract: AccessControl) { let err = contract._check_role(ROLE.into(), msg::sender()).unwrap_err(); assert!(matches!(err, Error::UnauthorizedAccount(_))); let err = @@ -576,27 +580,27 @@ mod tests { } #[motsu::test] - fn internal_grant_role_true_if_no_role(contract: AccessControl) { + fn internal_grant_role_success_when_no_role(contract: AccessControl) { let role_granted = contract._grant_role(ROLE.into(), ALICE); assert!(role_granted); } #[motsu::test] - fn internal_grant_role_false_if_role(contract: AccessControl) { + fn internal_grant_role_success_when_has_role(contract: AccessControl) { contract._roles.setter(ROLE.into()).has_role.insert(ALICE, true); let role_granted = contract._grant_role(ROLE.into(), ALICE); assert!(!role_granted); } #[motsu::test] - fn internal_revoke_role_true_if_role(contract: AccessControl) { + fn internal_revoke_role_success_when_has_role(contract: AccessControl) { contract._roles.setter(ROLE.into()).has_role.insert(ALICE, true); let role_revoked = contract._revoke_role(ROLE.into(), ALICE); assert!(role_revoked); } #[motsu::test] - fn internal_revoke_role_false_if_no_role(contract: AccessControl) { + fn internal_revoke_role_success_when_no_role(contract: AccessControl) { let role_revoked = contract._revoke_role(ROLE.into(), ALICE); assert!(!role_revoked); } diff --git a/contracts/src/access/ownable.rs b/contracts/src/access/ownable.rs index 2ad282c53..5a2c96dbc 100644 --- a/contracts/src/access/ownable.rs +++ b/contracts/src/access/ownable.rs @@ -211,14 +211,14 @@ mod tests { const ALICE: Address = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); #[motsu::test] - fn reads_owner(contract: Ownable) { + fn owner_read_success(contract: Ownable) { contract._owner.set(msg::sender()); let owner = contract.owner(); assert_eq!(owner, msg::sender()); } #[motsu::test] - fn transfers_ownership(contract: Ownable) { + fn transfer_ownership_success(contract: Ownable) { contract._owner.set(msg::sender()); contract.transfer_ownership(ALICE).expect("should transfer ownership"); @@ -227,7 +227,7 @@ mod tests { } #[motsu::test] - fn prevents_non_onwers_from_transferring(contract: Ownable) { + fn transfer_ownership_reverts_when_not_owner(contract: Ownable) { // Alice must be set as owner, because we can't set the // `msg::sender` yet. contract._owner.set(ALICE); @@ -238,7 +238,7 @@ mod tests { } #[motsu::test] - fn prevents_reaching_stuck_state(contract: Ownable) { + fn transfer_ownership_reverts_when_zero_address(contract: Ownable) { contract._owner.set(msg::sender()); let err = contract.transfer_ownership(Address::ZERO).unwrap_err(); @@ -246,7 +246,7 @@ mod tests { } #[motsu::test] - fn loses_ownership_after_renouncing(contract: Ownable) { + fn renounce_ownership_success(contract: Ownable) { contract._owner.set(msg::sender()); let _ = contract.renounce_ownership(); @@ -255,7 +255,7 @@ mod tests { } #[motsu::test] - fn prevents_non_owners_from_renouncing(contract: Ownable) { + fn renounce_ownership_reverts_when_not_owner(contract: Ownable) { // Alice must be set as owner, because we can't set the // `msg::sender` yet. contract._owner.set(ALICE); @@ -265,7 +265,7 @@ mod tests { } #[motsu::test] - fn recovers_access_using_internal_transfer(contract: Ownable) { + fn internal_transfer_ownership_success(contract: Ownable) { contract._owner.set(ALICE); contract._transfer_ownership(ALICE); diff --git a/contracts/src/access/ownable_two_step.rs b/contracts/src/access/ownable_two_step.rs index 8dca87d9f..64aebcdf6 100644 --- a/contracts/src/access/ownable_two_step.rs +++ b/contracts/src/access/ownable_two_step.rs @@ -230,21 +230,21 @@ mod tests { const BOB: Address = address!("B0B0cB49ec2e96DF5F5fFB081acaE66A2cBBc2e2"); #[motsu::test] - fn reads_owner(contract: Ownable2Step) { + fn owner_read_success(contract: Ownable2Step) { contract._ownable._owner.set(msg::sender()); let owner = contract.owner(); assert_eq!(owner, msg::sender()); } #[motsu::test] - fn reads_pending_owner(contract: Ownable2Step) { + fn pending_owner_read_success(contract: Ownable2Step) { contract._pending_owner.set(ALICE); let pending_owner = contract.pending_owner(); assert_eq!(pending_owner, ALICE); } #[motsu::test] - fn initiates_ownership_transfer(contract: Ownable2Step) { + fn transfer_ownership_success(contract: Ownable2Step) { contract._ownable._owner.set(msg::sender()); contract @@ -256,7 +256,7 @@ mod tests { } #[motsu::test] - fn prevents_non_owners_from_initiating_transfer(contract: Ownable2Step) { + fn transfer_ownership_reverts_when_not_owner(contract: Ownable2Step) { contract._ownable._owner.set(ALICE); let err = contract.transfer_ownership(BOB).unwrap_err(); @@ -267,7 +267,7 @@ mod tests { } #[motsu::test] - fn accepts_ownership(contract: Ownable2Step) { + fn accept_ownership_success(contract: Ownable2Step) { contract._ownable._owner.set(ALICE); contract._pending_owner.set(msg::sender()); @@ -277,7 +277,7 @@ mod tests { } #[motsu::test] - fn prevents_non_pending_owner_from_accepting(contract: Ownable2Step) { + fn accept_ownership_reverts_when_not_pending_owner(contract: Ownable2Step) { contract._ownable._owner.set(ALICE); contract._pending_owner.set(BOB); @@ -289,7 +289,7 @@ mod tests { } #[motsu::test] - fn completes_two_step_ownership_transfer(contract: Ownable2Step) { + fn ownership_transfer_success_with_two_steps(contract: Ownable2Step) { contract._ownable._owner.set(msg::sender()); contract @@ -307,7 +307,7 @@ mod tests { } #[motsu::test] - fn renounces_ownership(contract: Ownable2Step) { + fn renounce_ownership_success(contract: Ownable2Step) { contract._ownable._owner.set(msg::sender()); contract.renounce_ownership().expect("should renounce ownership"); @@ -315,7 +315,7 @@ mod tests { } #[motsu::test] - fn prevents_non_owners_from_renouncing(contract: Ownable2Step) { + fn renounce_ownership_reverts_when_not_owner(contract: Ownable2Step) { contract._ownable._owner.set(ALICE); let err = contract.renounce_ownership().unwrap_err(); @@ -326,7 +326,9 @@ mod tests { } #[motsu::test] - fn cancels_transfer_on_renounce(contract: Ownable2Step) { + fn renounce_ownership_success_with_pending_transfer( + contract: Ownable2Step, + ) { contract._ownable._owner.set(msg::sender()); contract._pending_owner.set(ALICE); @@ -336,7 +338,7 @@ mod tests { } #[motsu::test] - fn allows_owner_to_cancel_transfer(contract: Ownable2Step) { + fn transfer_ownership_success_with_cancel(contract: Ownable2Step) { contract._ownable._owner.set(msg::sender()); contract._pending_owner.set(ALICE); @@ -348,7 +350,7 @@ mod tests { } #[motsu::test] - fn allows_owner_to_overwrite_transfer(contract: Ownable2Step) { + fn transfer_ownership_success_with_overwrite(contract: Ownable2Step) { contract._ownable._owner.set(msg::sender()); contract diff --git a/contracts/src/finance/vesting_wallet.rs b/contracts/src/finance/vesting_wallet.rs index 0e5f52656..f548bbdbf 100644 --- a/contracts/src/finance/vesting_wallet.rs +++ b/contracts/src/finance/vesting_wallet.rs @@ -557,45 +557,45 @@ mod tests { } #[motsu::test] - fn reads_start(contract: VestingWallet) { + fn start_read_success(contract: VestingWallet) { let (start, _) = init(contract, start(), 0); assert_eq!(U256::from(start), contract.start()); } #[motsu::test] - fn reads_duration(contract: VestingWallet) { + fn duration_read_success(contract: VestingWallet) { let (_, duration) = init(contract, 0, DURATION); assert_eq!(U256::from(duration), contract.duration()); } #[motsu::test] - fn reads_end(contract: VestingWallet) { + fn end_read_success(contract: VestingWallet) { let (start, duration) = init(contract, start(), DURATION); assert_eq!(U256::from(start + duration), contract.end()); } #[motsu::test] - fn reads_max_end(contract: VestingWallet) { + fn end_read_success_with_max_values(contract: VestingWallet) { init(contract, u64::MAX, u64::MAX); assert_eq!(U256::from(U64::MAX) + U256::from(U64::MAX), contract.end()); } #[motsu::test] - fn reads_released_eth(contract: VestingWallet) { + fn released_eth_read_success(contract: VestingWallet) { let one = uint!(1_U256); contract._released.set(one); assert_eq!(one, contract.released_eth()); } #[motsu::test] - fn reads_released_erc20(contract: VestingWallet) { + fn released_erc20_read_success(contract: VestingWallet) { let one = uint!(1_U256); contract._erc20_released.setter(TOKEN).set(one); assert_eq!(one, contract.released_erc20(TOKEN)); } #[motsu::test] - fn gets_vesting_schedule(contract: VestingWallet) { + fn vesting_schedule_success(contract: VestingWallet) { let (start, duration) = init(contract, start(), DURATION); let one = uint!(1_U256); @@ -617,7 +617,7 @@ mod tests { } #[motsu::test] - fn gets_vesting_schedule_zero_duration(contract: VestingWallet) { + fn vesting_schedule_success_with_zero_duration(contract: VestingWallet) { let (start, _) = init(contract, start(), 0); let two = uint!(2_U256); diff --git a/contracts/src/token/erc1155/extensions/burnable.rs b/contracts/src/token/erc1155/extensions/burnable.rs index bae3789f6..65a625f73 100644 --- a/contracts/src/token/erc1155/extensions/burnable.rs +++ b/contracts/src/token/erc1155/extensions/burnable.rs @@ -142,7 +142,7 @@ mod tests { } #[motsu::test] - fn burns(contract: Erc1155) { + fn burn_success(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 1); @@ -158,7 +158,7 @@ mod tests { } #[motsu::test] - fn burns_with_approval(contract: Erc1155) { + fn burn_success_with_approval(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, BOB, 1); @@ -176,7 +176,7 @@ mod tests { } #[motsu::test] - fn error_when_missing_approval_burns(contract: Erc1155) { + fn burn_reverts_when_approval_missing(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, BOB, 1); @@ -194,7 +194,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_sender_burns(contract: Erc1155) { + fn burn_reverts_when_sender_invalid(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 1); let invalid_sender = Address::ZERO; @@ -218,7 +218,7 @@ mod tests { } #[motsu::test] - fn error_when_insufficient_balance_burn(contract: Erc1155) { + fn burn_reverts_when_balance_insufficient(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 1); @@ -242,7 +242,7 @@ mod tests { } #[motsu::test] - fn burns_batch(contract: Erc1155) { + fn burn_batch_success(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 4); @@ -262,7 +262,7 @@ mod tests { } #[motsu::test] - fn burns_batch_with_approval(contract: Erc1155) { + fn burn_batch_success_with_approval(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, BOB, 4); @@ -284,7 +284,7 @@ mod tests { } #[motsu::test] - fn error_when_missing_approval_burn_batch(contract: Erc1155) { + fn burn_batch_reverts_when_approval_missing(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, BOB, 2); @@ -302,7 +302,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_sender_burn_batch(contract: Erc1155) { + fn burn_batch_reverts_when_sender_invalid(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 5); let invalid_sender = Address::ZERO; @@ -328,7 +328,7 @@ mod tests { } #[motsu::test] - fn error_when_insufficient_balance_burn_batch(contract: Erc1155) { + fn burn_batch_reverts_when_balance_insufficient(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 5); let to_burn: Vec = diff --git a/contracts/src/token/erc1155/extensions/metadata_uri.rs b/contracts/src/token/erc1155/extensions/metadata_uri.rs index e61d5ff35..f0ca69ac2 100644 --- a/contracts/src/token/erc1155/extensions/metadata_uri.rs +++ b/contracts/src/token/erc1155/extensions/metadata_uri.rs @@ -80,7 +80,7 @@ mod tests { use super::{Erc1155MetadataUri, IErc1155MetadataUri, IErc165}; #[motsu::test] - fn uri_ignores_token_id(contract: Erc1155MetadataUri) { + fn uri_success_with_different_ids(contract: Erc1155MetadataUri) { let uri = String::from("https://token-cdn-domain/\\{id\\}.json"); contract._uri.set_str(uri.clone()); @@ -92,7 +92,7 @@ mod tests { } #[motsu::test] - fn interface_id() { + fn interface_id_success() { let actual = ::INTERFACE_ID; let expected = 0x0e89341c; assert_eq!(actual, expected); diff --git a/contracts/src/token/erc1155/extensions/supply.rs b/contracts/src/token/erc1155/extensions/supply.rs index eb3e4f1ca..64e3c06bd 100644 --- a/contracts/src/token/erc1155/extensions/supply.rs +++ b/contracts/src/token/erc1155/extensions/supply.rs @@ -389,7 +389,7 @@ mod tests { } #[motsu::test] - fn before_mint(contract: Erc1155Supply) { + fn total_supply_success_before_mint(contract: Erc1155Supply) { let token_id = random_token_ids(1)[0]; assert_eq!(U256::ZERO, contract.total_supply(token_id)); assert_eq!(U256::ZERO, contract.total_supply_all()); @@ -397,7 +397,7 @@ mod tests { } #[motsu::test] - fn after_mint_single(contract: Erc1155Supply) { + fn total_supply_success_after_single_mint(contract: Erc1155Supply) { let (token_ids, values) = init(contract, ALICE, 1); assert_eq!(values[0], contract.balance_of(ALICE, token_ids[0])); assert_eq!(values[0], contract.total_supply(token_ids[0])); @@ -406,7 +406,7 @@ mod tests { } #[motsu::test] - fn after_mint_batch(contract: Erc1155Supply) { + fn total_supply_success_after_batch_mint(contract: Erc1155Supply) { let (token_ids, values) = init(contract, ALICE, 4); for (&token_id, &value) in token_ids.iter().zip(values.iter()) { assert_eq!(value, contract.balance_of(ALICE, token_id)); @@ -418,7 +418,7 @@ mod tests { } #[motsu::test] - fn mint_reverts_on_invalid_receiver(contract: Erc1155Supply) { + fn mint_reverts_when_receiver_invalid(contract: Erc1155Supply) { let token_id = random_token_ids(1)[0]; let two = U256::from(2); let invalid_receiver = Address::ZERO; @@ -437,7 +437,7 @@ mod tests { #[motsu::test] #[should_panic = "should not exceed `U256::MAX` for `_total_supply`"] - fn mint_panics_on_total_supply_overflow(contract: Erc1155Supply) { + fn mint_reverts_when_total_supply_overflows(contract: Erc1155Supply) { let token_id = random_token_ids(1)[0]; let two = U256::from(2); let three = U256::from(3); @@ -452,7 +452,7 @@ mod tests { #[motsu::test] #[should_panic = "should not exceed `U256::MAX` for `_total_supply_all`"] - fn mint_panics_on_total_supply_all_overflow(contract: Erc1155Supply) { + fn mint_reverts_when_total_supply_all_overflows(contract: Erc1155Supply) { let token_ids = random_token_ids(2); contract ._mint(ALICE, token_ids[0], U256::MAX, &vec![].into()) @@ -462,7 +462,7 @@ mod tests { } #[motsu::test] - fn after_burn_single(contract: Erc1155Supply) { + fn total_supply_success_after_single_burn(contract: Erc1155Supply) { let (token_ids, values) = init(contract, ALICE, 1); contract._burn(ALICE, token_ids[0], values[0]).expect("should burn"); @@ -472,7 +472,7 @@ mod tests { } #[motsu::test] - fn after_burn_batch(contract: Erc1155Supply) { + fn total_supply_success_after_batch_burn(contract: Erc1155Supply) { let (token_ids, values) = init(contract, ALICE, 4); contract ._burn_batch(ALICE, token_ids.clone(), values.clone()) @@ -490,7 +490,7 @@ mod tests { } #[motsu::test] - fn burn_reverts_when_invalid_sender(contract: Erc1155Supply) { + fn burn_reverts_when_sender_invalid(contract: Erc1155Supply) { let (token_ids, values) = init(contract, ALICE, 1); let invalid_sender = Address::ZERO; @@ -507,7 +507,7 @@ mod tests { } #[motsu::test] - fn supply_unaffected_by_no_op(contract: Erc1155Supply) { + fn total_supply_success_with_no_op(contract: Erc1155Supply) { let token_ids = random_token_ids(1); let values = random_values(1); diff --git a/contracts/src/token/erc1155/extensions/uri_storage.rs b/contracts/src/token/erc1155/extensions/uri_storage.rs index 0c62d875d..8c68e38ac 100644 --- a/contracts/src/token/erc1155/extensions/uri_storage.rs +++ b/contracts/src/token/erc1155/extensions/uri_storage.rs @@ -109,9 +109,7 @@ mod tests { const TOKEN_ID: U256 = uint!(1_U256); #[motsu::test] - fn uri_returns_metadata_uri_when_token_uri_is_not_set( - contract: Erc1155MetadataExample, - ) { + fn uri_success_with_metadata_uri_only(contract: Erc1155MetadataExample) { let uri = "https://some.metadata/token/uri"; contract.metadata_uri._uri.set_str(uri.to_owned()); @@ -123,9 +121,7 @@ mod tests { } #[motsu::test] - fn uri_returns_empty_string_when_no_uri_is_set( - contract: Erc1155MetadataExample, - ) { + fn uri_success_with_no_uri_set(contract: Erc1155MetadataExample) { assert!(contract .uri_storage .uri(TOKEN_ID, &contract.metadata_uri) @@ -133,9 +129,7 @@ mod tests { } #[motsu::test] - fn uri_returns_token_uri_when_base_uri_is_empty( - contract: Erc1155MetadataExample, - ) { + fn uri_success_with_token_uri_only(contract: Erc1155MetadataExample) { let token_uri = "https://some.short/token/uri"; contract @@ -151,9 +145,7 @@ mod tests { } #[motsu::test] - fn uri_returns_concatenated_base_uri_and_token_uri( - contract: Erc1155MetadataExample, - ) { + fn uri_success_with_base_and_token_uri(contract: Erc1155MetadataExample) { let base_uri = "https://some.base.uri"; let token_uri = "/some/token/uri"; @@ -171,7 +163,7 @@ mod tests { } #[motsu::test] - fn uri_ignores_metadata_uri_when_token_uri_is_set( + fn uri_success_when_token_uri_overrides_metadata( contract: Erc1155MetadataExample, ) { let uri = "https://some.metadata/token/uri"; @@ -191,7 +183,7 @@ mod tests { } #[motsu::test] - fn test_set_uri(contract: Erc1155MetadataExample) { + fn set_token_uri_success(contract: Erc1155MetadataExample) { let uri = "https://some.metadata/token/uri"; let token_uri = "https://some.short/token/uri".to_string(); @@ -210,7 +202,7 @@ mod tests { } #[motsu::test] - fn test_set_base_uri(contract: Erc1155UriStorage) { + fn set_base_uri_success(contract: Erc1155UriStorage) { let base_uri = "https://docs.openzeppelin.com/".to_string(); contract.set_base_uri(base_uri.clone()); diff --git a/contracts/src/token/erc1155/mod.rs b/contracts/src/token/erc1155/mod.rs index ae93e4764..9e356355e 100644 --- a/contracts/src/token/erc1155/mod.rs +++ b/contracts/src/token/erc1155/mod.rs @@ -1245,7 +1245,7 @@ mod tests { } #[test] - fn should_create_transfer_single() { + fn create_transfer_single_success() { let id = uint!(1_U256); let value = uint!(10_U256); let details = Erc1155ReceiverData::new(vec![id], vec![value]); @@ -1254,7 +1254,7 @@ mod tests { } #[test] - fn should_create_transfer_batch() { + fn create_transfer_batch_success() { let ids = random_token_ids(5); let values = random_values(5); let details = Erc1155ReceiverData::new(ids.clone(), values.clone()); @@ -1263,7 +1263,7 @@ mod tests { } #[motsu::test] - fn balance_of_zero_balance(contract: Erc1155) { + fn balance_of_success_with_zero_balance(contract: Erc1155) { let owner = msg::sender(); let token_id = random_token_ids(1)[0]; let balance = contract.balance_of(owner, token_id); @@ -1271,7 +1271,7 @@ mod tests { } #[motsu::test] - fn error_when_array_length_mismatch(contract: Erc1155) { + fn balance_of_batch_reverts_when_array_length_mismatch(contract: Erc1155) { let token_ids = random_token_ids(3); let accounts = vec![ALICE, BOB, DAVE, CHARLIE]; let ids_length = U256::from(token_ids.len()); @@ -1291,7 +1291,7 @@ mod tests { } #[motsu::test] - fn balance_of_batch_zero_balance(contract: Erc1155) { + fn balance_of_batch_success_with_zero_balance(contract: Erc1155) { let token_ids = random_token_ids(4); let accounts = vec![ALICE, BOB, DAVE, CHARLIE]; let balances = contract @@ -1303,7 +1303,7 @@ mod tests { } #[motsu::test] - fn set_approval_for_all(contract: Erc1155) { + fn set_approval_for_all_success(contract: Erc1155) { let alice = msg::sender(); contract._operator_approvals.setter(alice).setter(BOB).set(false); @@ -1319,7 +1319,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_operator_set_approval_for_all(contract: Erc1155) { + fn set_approval_for_all_reverts_when_operator_invalid(contract: Erc1155) { let invalid_operator = Address::ZERO; let err = contract @@ -1335,7 +1335,7 @@ mod tests { } #[motsu::test] - fn mints(contract: Erc1155) { + fn mint_success(contract: Erc1155) { let alice = msg::sender(); let token_id = random_token_ids(1)[0]; let value = random_values(1)[0]; @@ -1350,7 +1350,7 @@ mod tests { } #[motsu::test] - fn error_when_mints_to_invalid_receiver(contract: Erc1155) { + fn mint_reverts_when_receiver_invalid(contract: Erc1155) { let invalid_receiver = Address::ZERO; let token_id = random_token_ids(1)[0]; let value = random_values(1)[0]; @@ -1368,7 +1368,7 @@ mod tests { } #[motsu::test] - fn mints_batch(contract: Erc1155) { + fn mint_batch_success(contract: Erc1155) { let token_ids = random_token_ids(4); let values = random_values(4); @@ -1393,7 +1393,7 @@ mod tests { } #[motsu::test] - fn mints_batch_same_token(contract: Erc1155) { + fn mint_batch_success_with_same_token(contract: Erc1155) { let token_id = uint!(1_U256); let values = random_values(4); let expected_balance: U256 = values.iter().sum(); @@ -1417,7 +1417,7 @@ mod tests { } #[motsu::test] - fn error_when_batch_mints_to_invalid_receiver(contract: Erc1155) { + fn mint_batch_reverts_when_receiver_invalid(contract: Erc1155) { let token_ids = random_token_ids(1); let values = random_values(1); let invalid_receiver = Address::ZERO; @@ -1440,7 +1440,7 @@ mod tests { } #[motsu::test] - fn error_when_batch_mints_not_equal_arrays(contract: Erc1155) { + fn mint_batch_reverts_when_arrays_length_mismatch(contract: Erc1155) { let token_ids = random_token_ids(3); let values = random_values(4); @@ -1459,7 +1459,7 @@ mod tests { } #[motsu::test] - fn burns(contract: Erc1155) { + fn burn_success(contract: Erc1155) { let (token_ids, values) = init(contract, ALICE, 1); let token_id = token_ids[0]; let value = values[0]; @@ -1472,7 +1472,7 @@ mod tests { } #[motsu::test] - fn error_when_burns_from_invalid_sender(contract: Erc1155) { + fn burn_reverts_when_sender_invalid(contract: Erc1155) { let (token_ids, values) = init(contract, ALICE, 1); let invalid_sender = Address::ZERO; @@ -1489,7 +1489,7 @@ mod tests { } #[motsu::test] - fn error_when_burns_with_insufficient_balance(contract: Erc1155) { + fn burn_reverts_when_balance_insufficient(contract: Erc1155) { let (token_ids, values) = init(contract, ALICE, 1); let err = contract @@ -1508,7 +1508,7 @@ mod tests { } #[motsu::test] - fn burns_batch(contract: Erc1155) { + fn burn_batch_success(contract: Erc1155) { let (token_ids, values) = init(contract, ALICE, 4); contract @@ -1523,7 +1523,7 @@ mod tests { } #[motsu::test] - fn burns_batch_same_token(contract: Erc1155) { + fn burn_batch_success_with_same_token(contract: Erc1155) { let token_id = uint!(1_U256); let value = uint!(80_U256); @@ -1548,7 +1548,7 @@ mod tests { } #[motsu::test] - fn error_when_batch_burns_from_invalid_sender(contract: Erc1155) { + fn burn_batch_reverts_when_sender_invalid(contract: Erc1155) { let (token_ids, values) = init(contract, ALICE, 4); let invalid_sender = Address::ZERO; @@ -1565,7 +1565,7 @@ mod tests { } #[motsu::test] - fn error_when_batch_burns_with_insufficient_balance(contract: Erc1155) { + fn burn_batch_reverts_when_balance_insufficient(contract: Erc1155) { let (token_ids, values) = init(contract, ALICE, 4); let err = contract @@ -1590,7 +1590,7 @@ mod tests { } #[motsu::test] - fn error_when_batch_burns_not_equal_arrays(contract: Erc1155) { + fn burn_batch_reverts_when_arrays_length_mismatch(contract: Erc1155) { let (token_ids, values) = init(contract, ALICE, 3); let err = contract @@ -1608,7 +1608,7 @@ mod tests { } #[motsu::test] - fn safe_transfer_from(contract: Erc1155) { + fn safe_transfer_from_success(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, BOB, 2); let amount_one = values[0] - uint!(1_U256); @@ -1643,7 +1643,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_receiver_safe_transfer_from(contract: Erc1155) { + fn safe_transfer_from_reverts_when_receiver_invalid(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 1); let invalid_receiver = Address::ZERO; @@ -1667,7 +1667,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_sender_safe_transfer_from(contract: Erc1155) { + fn safe_transfer_from_reverts_when_sender_invalid(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 1); let invalid_sender = Address::ZERO; @@ -1697,7 +1697,7 @@ mod tests { } #[motsu::test] - fn error_when_missing_approval_safe_transfer_from(contract: Erc1155) { + fn safe_transfer_from_reverts_when_approval_missing(contract: Erc1155) { let (token_ids, values) = init(contract, ALICE, 1); let err = contract @@ -1720,7 +1720,7 @@ mod tests { } #[motsu::test] - fn error_when_insufficient_balance_safe_transfer_from(contract: Erc1155) { + fn safe_transfer_from_reverts_when_balance_insufficient(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, BOB, 1); @@ -1748,7 +1748,7 @@ mod tests { } #[motsu::test] - fn safe_transfer_from_with_data(contract: Erc1155) { + fn safe_transfer_from_success_with_data(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, DAVE, 1); @@ -1770,7 +1770,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_receiver_safe_transfer_from_with_data( + fn safe_transfer_from_with_data_reverts_when_receiver_invalid( contract: Erc1155, ) { let (token_ids, values) = init(contract, DAVE, 1); @@ -1795,7 +1795,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_sender_safe_transfer_from_with_data( + fn safe_transfer_from_with_data_reverts_when_sender_invalid( contract: Erc1155, ) { let alice = msg::sender(); @@ -1827,7 +1827,7 @@ mod tests { } #[motsu::test] - fn error_when_missing_approval_safe_transfer_from_with_data( + fn safe_transfer_from_with_data_reverts_when_approval_missing( contract: Erc1155, ) { let (token_ids, values) = init(contract, ALICE, 1); @@ -1852,7 +1852,7 @@ mod tests { } #[motsu::test] - fn error_when_insufficient_balance_safe_transfer_from_with_data( + fn safe_transfer_from_with_data_reverts_when_balance_insufficient( contract: Erc1155, ) { let alice = msg::sender(); @@ -1882,7 +1882,7 @@ mod tests { } #[motsu::test] - fn safe_batch_transfer_from(contract: Erc1155) { + fn safe_batch_transfer_from_success(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, DAVE, 2); let amount_one = values[0] - uint!(1_U256); @@ -1908,7 +1908,9 @@ mod tests { } #[motsu::test] - fn error_when_invalid_receiver_safe_batch_transfer_from(contract: Erc1155) { + fn safe_batch_transfer_from_reverts_when_receiver_invalid( + contract: Erc1155, + ) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 4); let invalid_receiver = Address::ZERO; @@ -1932,7 +1934,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_sender_safe_batch_transfer_from(contract: Erc1155) { + fn safe_batch_transfer_from_reverts_when_sender_invalid(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 4); let invalid_sender = Address::ZERO; @@ -1962,7 +1964,9 @@ mod tests { } #[motsu::test] - fn error_when_missing_approval_safe_batch_transfer_from(contract: Erc1155) { + fn safe_batch_transfer_from_reverts_when_approval_missing( + contract: Erc1155, + ) { let (token_ids, values) = init(contract, ALICE, 2); let err = contract @@ -1985,7 +1989,7 @@ mod tests { } #[motsu::test] - fn error_when_insufficient_balance_safe_batch_transfer_from( + fn safe_batch_transfer_from_reverts_when_balance_insufficient( contract: Erc1155, ) { let alice = msg::sender(); @@ -2015,7 +2019,9 @@ mod tests { } #[motsu::test] - fn error_when_not_equal_arrays_safe_batch_transfer_from(contract: Erc1155) { + fn safe_batch_transfer_from_reverts_when_arrays_length_mismatch( + contract: Erc1155, + ) { let alice = msg::sender(); let (token_ids, values) = init(contract, alice, 4); @@ -2042,7 +2048,7 @@ mod tests { } #[motsu::test] - fn safe_batch_transfer_from_with_data(contract: Erc1155) { + fn safe_batch_transfer_from_success_with_data(contract: Erc1155) { let alice = msg::sender(); let (token_ids, values) = init(contract, DAVE, 2); @@ -2066,7 +2072,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_receiver_safe_batch_transfer_from_with_data( + fn safe_batch_transfer_from_with_data_reverts_when_receiver_invalid( contract: Erc1155, ) { let alice = msg::sender(); @@ -2092,7 +2098,7 @@ mod tests { } #[motsu::test] - fn error_when_invalid_sender_safe_batch_transfer_from_with_data( + fn safe_batch_transfer_from_with_data_reverts_when_sender_invalid( contract: Erc1155, ) { let alice = msg::sender(); @@ -2124,7 +2130,7 @@ mod tests { } #[motsu::test] - fn error_when_missing_approval_safe_batch_transfer_from_with_data( + fn safe_batch_transfer_from_with_data_reverts_when_approval_missing( contract: Erc1155, ) { let (token_ids, values) = init(contract, ALICE, 2); @@ -2149,7 +2155,7 @@ mod tests { } #[motsu::test] - fn error_when_insufficient_balance_safe_batch_transfer_from_with_data( + fn safe_batch_transfer_from_with_data_reverts_when_balance_insufficient( contract: Erc1155, ) { let alice = msg::sender(); @@ -2179,7 +2185,7 @@ mod tests { } #[motsu::test] - fn error_when_not_equal_arrays_safe_batch_transfer_from_with_data( + fn safe_batch_transfer_from_with_data_reverts_when_arrays_length_mismatch( contract: Erc1155, ) { let alice = msg::sender(); @@ -2208,7 +2214,7 @@ mod tests { } #[motsu::test] - fn interface_id() { + fn interface_id_success() { let actual = ::INTERFACE_ID; let expected = 0xd9b67a26; assert_eq!(actual, expected); diff --git a/contracts/src/token/erc20/extensions/burnable.rs b/contracts/src/token/erc20/extensions/burnable.rs index 683531720..87b4bdee5 100644 --- a/contracts/src/token/erc20/extensions/burnable.rs +++ b/contracts/src/token/erc20/extensions/burnable.rs @@ -86,7 +86,7 @@ mod tests { use crate::token::erc20::{Erc20, Error, IErc20}; #[motsu::test] - fn burns(contract: Erc20) { + fn burn_success(contract: Erc20) { let zero = U256::ZERO; let one = uint!(1_U256); @@ -107,7 +107,7 @@ mod tests { } #[motsu::test] - fn burns_errors_when_insufficient_balance(contract: Erc20) { + fn burn_reverts_when_balance_insufficient(contract: Erc20) { let zero = U256::ZERO; let one = uint!(1_U256); let sender = msg::sender(); @@ -119,7 +119,7 @@ mod tests { } #[motsu::test] - fn burn_from(contract: Erc20) { + fn burn_from_success(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let sender = msg::sender(); @@ -141,7 +141,7 @@ mod tests { } #[motsu::test] - fn burns_from_errors_when_insufficient_balance(contract: Erc20) { + fn burn_from_reverts_when_balance_insufficient(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); // Alice approves `msg::sender`. @@ -158,7 +158,7 @@ mod tests { } #[motsu::test] - fn burns_from_errors_when_invalid_approver(contract: Erc20) { + fn burn_from_reverts_when_approver_invalid(contract: Erc20) { let one = uint!(1_U256); contract @@ -172,7 +172,7 @@ mod tests { } #[motsu::test] - fn burns_from_errors_when_insufficient_allowance(contract: Erc20) { + fn burn_from_reverts_when_allowance_insufficient(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); // Mint some tokens for Alice. diff --git a/contracts/src/token/erc20/extensions/capped.rs b/contracts/src/token/erc20/extensions/capped.rs index 6b8a23c96..8fa307153 100644 --- a/contracts/src/token/erc20/extensions/capped.rs +++ b/contracts/src/token/erc20/extensions/capped.rs @@ -68,7 +68,7 @@ mod tests { use super::Capped; #[motsu::test] - fn cap_works(contract: Capped) { + fn cap_read_success(contract: Capped) { let value = uint!(2024_U256); contract._cap.set(value); assert_eq!(contract.cap(), value); diff --git a/contracts/src/token/erc20/extensions/flash_mint.rs b/contracts/src/token/erc20/extensions/flash_mint.rs index 9f1629941..88a574c2d 100644 --- a/contracts/src/token/erc20/extensions/flash_mint.rs +++ b/contracts/src/token/erc20/extensions/flash_mint.rs @@ -367,7 +367,7 @@ mod tests { #[motsu::test] #[ignore] - fn max_flash_loan_token_match(contract: Erc20FlashMint) { + fn max_flash_loan_success_with_matching_token(contract: Erc20FlashMint) { let erc20 = Erc20::default(); let max_flash_loan = contract.max_flash_loan(TOKEN_ADDRESS, &erc20); assert_eq!(max_flash_loan, U256::MAX); @@ -375,7 +375,7 @@ mod tests { #[motsu::test] #[ignore] - fn max_flash_loan_token_mismatch(contract: Erc20FlashMint) { + fn max_flash_loan_success_with_mismatched_token(contract: Erc20FlashMint) { let erc20 = Erc20::default(); let max_flash_loan = contract.max_flash_loan(INVALID_TOKEN_ADDRESS, &erc20); @@ -384,7 +384,7 @@ mod tests { #[motsu::test] #[ignore] - fn max_flash_loan_when_token_minted(contract: Erc20FlashMint) { + fn max_flash_loan_success_with_minted_tokens(contract: Erc20FlashMint) { let mut erc20 = Erc20::default(); erc20._mint(msg::sender(), uint!(10000_U256)).unwrap(); let max_flash_loan = contract.max_flash_loan(TOKEN_ADDRESS, &erc20); @@ -393,7 +393,7 @@ mod tests { #[motsu::test] #[ignore] - fn flash_fee(contract: Erc20FlashMint) { + fn flash_fee_success(contract: Erc20FlashMint) { let flash_fee = contract.flash_fee(TOKEN_ADDRESS, uint!(1000_U256)).unwrap(); assert_eq!(flash_fee, U256::MIN); @@ -401,7 +401,7 @@ mod tests { #[motsu::test] #[ignore] - fn error_flash_fee_when_invalid_token(contract: Erc20FlashMint) { + fn flash_fee_reverts_when_token_invalid(contract: Erc20FlashMint) { let result = contract.flash_fee(INVALID_TOKEN_ADDRESS, uint!(1000_U256)); assert!(matches!(result, Err(Error::UnsupportedToken(_)))); @@ -409,7 +409,7 @@ mod tests { #[motsu::test] #[ignore] - fn error_flash_loan_when_exceeded_max_loan(contract: Erc20FlashMint) { + fn flash_loan_reverts_when_max_loan_exceeded(contract: Erc20FlashMint) { let mut erc20 = Erc20::default(); let _ = erc20._mint(msg::sender(), uint!(10000_U256)); let result = contract.flash_loan( @@ -424,7 +424,7 @@ mod tests { #[motsu::test] #[ignore] - fn error_flash_loan_when_zero_receiver_address(contract: Erc20FlashMint) { + fn flash_loan_reverts_when_receiver_zero(contract: Erc20FlashMint) { let mut erc20 = Erc20::default(); let invalid_reciver = Address::ZERO; let result = contract.flash_loan( @@ -439,7 +439,7 @@ mod tests { #[motsu::test] #[ignore] - fn error_flash_loan_when_invalid_receiver(contract: Erc20FlashMint) { + fn flash_loan_reverts_when_receiver_invalid(contract: Erc20FlashMint) { let mut erc20 = Erc20::default(); let result = contract.flash_loan( ALICE, diff --git a/contracts/src/token/erc20/extensions/metadata.rs b/contracts/src/token/erc20/extensions/metadata.rs index 3e7d0db99..c59387d6f 100644 --- a/contracts/src/token/erc20/extensions/metadata.rs +++ b/contracts/src/token/erc20/extensions/metadata.rs @@ -90,7 +90,7 @@ mod tests { use crate::token::erc20::extensions::{Erc20Metadata, IErc20Metadata}; #[motsu::test] - fn interface_id() { + fn interface_id_success() { let actual = ::INTERFACE_ID; let expected = 0xa219a025; assert_eq!(actual, expected); diff --git a/contracts/src/token/erc20/mod.rs b/contracts/src/token/erc20/mod.rs index cf20cfa7d..3966aa20f 100644 --- a/contracts/src/token/erc20/mod.rs +++ b/contracts/src/token/erc20/mod.rs @@ -598,7 +598,7 @@ mod tests { use crate::utils::introspection::erc165::IErc165; #[motsu::test] - fn reads_balance(contract: Erc20) { + fn balance_of_success(contract: Erc20) { let balance = contract.balance_of(Address::ZERO); assert_eq!(U256::ZERO, balance); @@ -610,7 +610,7 @@ mod tests { } #[motsu::test] - fn update_mint(contract: Erc20) { + fn mint_success_with_update(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let one = uint!(1_U256); @@ -629,7 +629,7 @@ mod tests { #[motsu::test] #[should_panic = "should not exceed `U256::MAX` for `_total_supply`"] - fn update_mint_errors_arithmetic_overflow(contract: Erc20) { + fn mint_reverts_when_supply_overflows(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let one = uint!(1_U256); assert_eq!(U256::ZERO, contract.balance_of(alice)); @@ -646,7 +646,7 @@ mod tests { } #[motsu::test] - fn mint_works(contract: Erc20) { + fn mint_success(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let one = uint!(1_U256); @@ -664,7 +664,7 @@ mod tests { } #[motsu::test] - fn mint_errors_invalid_receiver(contract: Erc20) { + fn mint_reverts_when_receiver_invalid(contract: Erc20) { let receiver = Address::ZERO; let one = uint!(1_U256); @@ -683,7 +683,7 @@ mod tests { #[motsu::test] #[should_panic = "should not exceed `U256::MAX` for `_total_supply`"] - fn mint_errors_arithmetic_overflow(contract: Erc20) { + fn mint_reverts_when_supply_overflows(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let one = uint!(1_U256); assert_eq!(U256::ZERO, contract.balance_of(alice)); @@ -699,7 +699,7 @@ mod tests { } #[motsu::test] - fn update_burn(contract: Erc20) { + fn burn_success_with_update(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let one = uint!(1_U256); let two = uint!(2_U256); @@ -724,7 +724,7 @@ mod tests { } #[motsu::test] - fn update_burn_errors_insufficient_balance(contract: Erc20) { + fn burn_reverts_when_balance_insufficient(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let one = uint!(1_U256); let two = uint!(2_U256); @@ -749,7 +749,7 @@ mod tests { } #[motsu::test] - fn update_transfer(contract: Erc20) { + fn transfer_success_with_update(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let bob = address!("B0B0cB49ec2e96DF5F5fFB081acaE66A2cBBc2e2"); let one = uint!(1_U256); @@ -777,7 +777,7 @@ mod tests { } #[motsu::test] - fn update_transfer_errors_insufficient_balance(contract: Erc20) { + fn transfer_reverts_when_balance_insufficient(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let bob = address!("B0B0cB49ec2e96DF5F5fFB081acaE66A2cBBc2e2"); let one = uint!(1_U256); @@ -805,7 +805,7 @@ mod tests { } #[motsu::test] - fn transfers(contract: Erc20) { + fn transfer_success(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let bob = address!("B0B0cB49ec2e96DF5F5fFB081acaE66A2cBBc2e2"); @@ -825,7 +825,7 @@ mod tests { } #[motsu::test] - fn transfers_from(contract: Erc20) { + fn transfer_from_success(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let bob = address!("B0B0cB49ec2e96DF5F5fFB081acaE66A2cBBc2e2"); let sender = msg::sender(); @@ -847,7 +847,7 @@ mod tests { } #[motsu::test] - fn transfer_from_errors_when_insufficient_balance(contract: Erc20) { + fn transfer_from_reverts_when_balance_insufficient(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let bob = address!("B0B0cB49ec2e96DF5F5fFB081acaE66A2cBBc2e2"); @@ -862,7 +862,7 @@ mod tests { } #[motsu::test] - fn transfer_from_errors_when_invalid_approver(contract: Erc20) { + fn transfer_from_reverts_when_approver_invalid(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let one = uint!(1_U256); contract @@ -875,7 +875,7 @@ mod tests { } #[motsu::test] - fn transfer_from_errors_when_invalid_receiver(contract: Erc20) { + fn transfer_from_reverts_when_receiver_invalid(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let one = uint!(1_U256); contract._allowances.setter(alice).setter(msg::sender()).set(one); @@ -884,7 +884,7 @@ mod tests { } #[motsu::test] - fn transfer_from_errors_when_insufficient_allowance(contract: Erc20) { + fn transfer_from_reverts_when_allowance_insufficient(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); let bob = address!("B0B0cB49ec2e96DF5F5fFB081acaE66A2cBBc2e2"); @@ -898,7 +898,7 @@ mod tests { } #[motsu::test] - fn reads_allowance(contract: Erc20) { + fn allowance_read_success(contract: Erc20) { let owner = msg::sender(); let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); @@ -912,7 +912,7 @@ mod tests { } #[motsu::test] - fn approves(contract: Erc20) { + fn approve_success(contract: Erc20) { let alice = address!("A11CEacF9aa32246d767FCCD72e02d6bCbcC375d"); // `msg::sender` approves Alice. @@ -922,7 +922,7 @@ mod tests { } #[motsu::test] - fn approve_errors_when_invalid_spender(contract: Erc20) { + fn approve_reverts_when_spender_invalid(contract: Erc20) { // `msg::sender` approves `Address::ZERO`. let one = uint!(1_U256); let result = contract.approve(Address::ZERO, one); @@ -930,7 +930,7 @@ mod tests { } #[motsu::test] - fn interface_id() { + fn interface_id_success() { let actual = ::INTERFACE_ID; let expected = 0x36372b07; assert_eq!(actual, expected); diff --git a/contracts/src/token/erc20/utils/safe_erc20.rs b/contracts/src/token/erc20/utils/safe_erc20.rs index 7066a1b8a..56c3f21c5 100644 --- a/contracts/src/token/erc20/utils/safe_erc20.rs +++ b/contracts/src/token/erc20/utils/safe_erc20.rs @@ -408,32 +408,32 @@ impl SafeErc20 { mod tests { use super::SafeErc20; #[test] - fn encodes_true_empty_slice() { + fn encodes_true_reverts_when_slice_empty() { assert!(!SafeErc20::encodes_true(&[])); } #[test] - fn encodes_false_single_byte() { + fn encodes_true_reverts_when_single_byte_zero() { assert!(!SafeErc20::encodes_true(&[0])); } #[test] - fn encodes_true_single_byte() { + fn encodes_true_success_with_single_byte() { assert!(SafeErc20::encodes_true(&[1])); } #[test] - fn encodes_false_many_bytes() { + fn encodes_true_reverts_when_all_bytes_zero() { assert!(!SafeErc20::encodes_true(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])); } #[test] - fn encodes_true_many_bytes() { + fn encodes_true_success_with_many_bytes() { assert!(SafeErc20::encodes_true(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])); } #[test] - fn encodes_true_wrong_bytes() { + fn encodes_true_reverts_when_bytes_invalid() { assert!(!SafeErc20::encodes_true(&[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1])); } } diff --git a/contracts/src/token/erc721/extensions/burnable.rs b/contracts/src/token/erc721/extensions/burnable.rs index f06a90535..1c736ea55 100644 --- a/contracts/src/token/erc721/extensions/burnable.rs +++ b/contracts/src/token/erc721/extensions/burnable.rs @@ -68,7 +68,7 @@ mod tests { const TOKEN_ID: U256 = uint!(1_U256); #[motsu::test] - fn burns(contract: Erc721) { + fn burn_success(contract: Erc721) { let alice = msg::sender(); let one = uint!(1_U256); @@ -100,7 +100,7 @@ mod tests { } #[motsu::test] - fn burns_with_approval(contract: Erc721) { + fn burn_success_with_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint a token for Bob"); @@ -131,7 +131,7 @@ mod tests { } #[motsu::test] - fn burns_with_approval_for_all(contract: Erc721) { + fn burn_success_with_approval_for_all(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint a token for Bob"); @@ -164,7 +164,7 @@ mod tests { } #[motsu::test] - fn error_when_get_approved_of_previous_approval_burned(contract: Erc721) { + fn get_approved_reverts_when_token_burned(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token for Alice"); @@ -187,7 +187,7 @@ mod tests { } #[motsu::test] - fn error_when_burn_without_approval(contract: Erc721) { + fn burn_reverts_when_approval_missing(contract: Erc721) { contract._mint(BOB, TOKEN_ID).expect("should mint a token for Bob"); let err = contract @@ -204,7 +204,7 @@ mod tests { } #[motsu::test] - fn error_when_burn_nonexistent_token(contract: Erc721) { + fn burn_reverts_when_token_nonexistent(contract: Erc721) { let err = contract .burn(TOKEN_ID) .expect_err("should return Error::NonexistentToken"); diff --git a/contracts/src/token/erc721/extensions/consecutive.rs b/contracts/src/token/erc721/extensions/consecutive.rs index 8211493f0..7f4c24976 100644 --- a/contracts/src/token/erc721/extensions/consecutive.rs +++ b/contracts/src/token/erc721/extensions/consecutive.rs @@ -847,7 +847,7 @@ mod tests { } #[motsu::test] - fn mints(contract: Erc721Consecutive) { + fn mint_success_with_consecutive(contract: Erc721Consecutive) { let alice = msg::sender(); let initial_balance = contract @@ -880,7 +880,7 @@ mod tests { } #[motsu::test] - fn error_when_minting_token_id_twice(contract: Erc721Consecutive) { + fn mint_reverts_when_token_id_exists(contract: Erc721Consecutive) { let alice = msg::sender(); contract ._mint(alice, TOKEN_ID) @@ -898,7 +898,7 @@ mod tests { } #[motsu::test] - fn error_when_minting_token_invalid_receiver(contract: Erc721Consecutive) { + fn mint_reverts_when_receiver_invalid(contract: Erc721Consecutive) { let invalid_receiver = Address::ZERO; let err = contract @@ -914,7 +914,9 @@ mod tests { } #[motsu::test] - fn error_when_to_is_zero(contract: Erc721Consecutive) { + fn mint_consecutive_reverts_when_receiver_zero( + contract: Erc721Consecutive, + ) { let err = contract ._mint_consecutive(Address::ZERO, uint!(11_U96)) .expect_err("should not mint consecutive"); @@ -927,7 +929,9 @@ mod tests { } #[motsu::test] - fn error_when_exceed_batch_size(contract: Erc721Consecutive) { + fn mint_consecutive_reverts_when_batch_size_exceeded( + contract: Erc721Consecutive, + ) { let alice = msg::sender(); let batch_size = contract._max_batch_size() + uint!(1_U96); let err = contract @@ -944,7 +948,7 @@ mod tests { } #[motsu::test] - fn transfers_from(contract: Erc721Consecutive) { + fn transfer_from_success_with_consecutive(contract: Erc721Consecutive) { let alice = msg::sender(); let bob = BOB; @@ -997,7 +1001,7 @@ mod tests { } #[motsu::test] - fn burns(contract: Erc721Consecutive) { + fn burn_success_with_consecutive(contract: Erc721Consecutive) { let alice = msg::sender(); // Mint batch of 1000 tokens to Alice. @@ -1067,7 +1071,7 @@ mod tests { } #[motsu::test] - fn safe_transfer_from(contract: Erc721Consecutive) { + fn safe_transfer_from_success(contract: Erc721Consecutive) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -1083,7 +1087,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_from_approved_token(contract: Erc721Consecutive) { + fn safe_transfer_from_success_with_approval(contract: Erc721Consecutive) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); contract.erc721._token_approvals.setter(TOKEN_ID).set(alice); @@ -1097,7 +1101,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_from_incorrect_owner( + fn safe_transfer_from_reverts_when_owner_incorrect( contract: Erc721Consecutive, ) { let alice = msg::sender(); @@ -1119,7 +1123,7 @@ mod tests { } #[motsu::test] - fn error_when_internal_safe_transfer_nonexistent_token( + fn safe_transfer_reverts_when_token_nonexistent( contract: Erc721Consecutive, ) { let alice = msg::sender(); @@ -1136,7 +1140,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_to_invalid_receiver( + fn safe_transfer_from_reverts_when_receiver_invalid( contract: Erc721Consecutive, ) { let alice = msg::sender(); @@ -1162,7 +1166,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_from_with_data(contract: Erc721Consecutive) { + fn safe_transfer_from_success_with_data(contract: Erc721Consecutive) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -1183,7 +1187,7 @@ mod tests { } #[motsu::test] - fn error_when_internal_safe_transfer_to_invalid_receiver( + fn safe_transfer_reverts_when_receiver_invalid( contract: Erc721Consecutive, ) { let alice = msg::sender(); @@ -1214,9 +1218,7 @@ mod tests { } #[motsu::test] - fn error_when_internal_safe_transfer_from_incorrect_owner( - contract: Erc721Consecutive, - ) { + fn safe_transfer_reverts_when_owner_incorrect(contract: Erc721Consecutive) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -1235,7 +1237,7 @@ mod tests { } #[motsu::test] - fn safe_mints(contract: Erc721Consecutive) { + fn safe_mint_success(contract: Erc721Consecutive) { let alice = msg::sender(); let initial_balance = contract @@ -1259,7 +1261,7 @@ mod tests { } #[motsu::test] - fn approves(contract: Erc721Consecutive) { + fn approve_success(contract: Erc721Consecutive) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); contract @@ -1269,7 +1271,7 @@ mod tests { } #[motsu::test] - fn error_when_approve_for_nonexistent_token(contract: Erc721Consecutive) { + fn approve_reverts_when_token_nonexistent(contract: Erc721Consecutive) { let err = contract .approve(BOB, TOKEN_ID) .expect_err("should not approve for a non-existent token"); @@ -1283,7 +1285,7 @@ mod tests { } #[motsu::test] - fn error_when_approve_by_invalid_approver(contract: Erc721Consecutive) { + fn approve_reverts_when_approver_invalid(contract: Erc721Consecutive) { contract._mint(BOB, TOKEN_ID).expect("should mint a token"); let err = contract @@ -1299,7 +1301,7 @@ mod tests { } #[motsu::test] - fn approval_for_all(contract: Erc721Consecutive) { + fn approve_for_all_success(contract: Erc721Consecutive) { let alice = msg::sender(); contract .erc721 @@ -1320,7 +1322,7 @@ mod tests { } #[motsu::test] - fn error_when_get_approved_of_nonexistent_token( + fn get_approved_reverts_when_token_nonexistent( contract: Erc721Consecutive, ) { let err = contract diff --git a/contracts/src/token/erc721/extensions/enumerable.rs b/contracts/src/token/erc721/extensions/enumerable.rs index 34e3dc901..62c03467e 100644 --- a/contracts/src/token/erc721/extensions/enumerable.rs +++ b/contracts/src/token/erc721/extensions/enumerable.rs @@ -350,12 +350,14 @@ mod tests { const BOB: Address = address!("F4EaCDAbEf3c8f1EdE91b6f2A6840bc2E4DD3526"); #[motsu::test] - fn total_supply_no_tokens(contract: Erc721Enumerable) { + fn total_supply_success_with_no_tokens(contract: Erc721Enumerable) { assert_eq!(U256::ZERO, contract.total_supply()); } #[motsu::test] - fn error_when_token_by_index_is_out_of_bound(contract: Erc721Enumerable) { + fn token_by_index_reverts_when_index_out_of_bounds( + contract: Erc721Enumerable, + ) { assert_eq!(U256::ZERO, contract.total_supply()); let token_idx = uint!(2024_U256); @@ -365,7 +367,7 @@ mod tests { } #[motsu::test] - fn add_token_to_all_tokens_enumeration_works(contract: Erc721Enumerable) { + fn token_enumeration_success_with_add_token(contract: Erc721Enumerable) { assert_eq!(U256::ZERO, contract.total_supply()); let tokens_len = 10; @@ -395,9 +397,7 @@ mod tests { } #[motsu::test] - fn remove_token_from_all_tokens_enumeration_works( - contract: Erc721Enumerable, - ) { + fn token_enumeration_success_with_remove_token(contract: Erc721Enumerable) { assert_eq!(U256::ZERO, contract.total_supply()); let initial_tokens_len = 10; @@ -446,14 +446,14 @@ mod tests { } #[motsu::test] - fn check_increase_balance() { + fn check_increase_balance_success() { assert!(Erc721Enumerable::_check_increase_balance(0).is_ok()); let err = Erc721Enumerable::_check_increase_balance(1).unwrap_err(); assert!(matches!(err, Error::EnumerableForbiddenBatchMint(_))); } #[motsu::test] - fn token_of_owner_by_index_works(contract: Erc721Enumerable) { + fn token_of_owner_by_index_success(contract: Erc721Enumerable) { let alice = msg::sender(); let mut erc721 = Erc721::default(); assert_eq!( @@ -480,7 +480,7 @@ mod tests { } #[motsu::test] - fn error_when_token_of_owner_for_index_out_of_bound( + fn token_of_owner_by_index_reverts_when_index_out_of_bounds( contract: Erc721Enumerable, ) { let alice = msg::sender(); @@ -507,7 +507,7 @@ mod tests { } #[motsu::test] - fn error_when_token_of_owner_does_not_own_any_token( + fn token_of_owner_by_index_reverts_when_no_tokens( contract: Erc721Enumerable, ) { let erc721 = Erc721::default(); @@ -522,7 +522,7 @@ mod tests { } #[motsu::test] - fn token_of_owner_by_index_after_transfer_works( + fn token_of_owner_by_index_success_after_transfer( contract: Erc721Enumerable, ) { let alice = msg::sender(); @@ -572,7 +572,7 @@ mod tests { } #[motsu::test] - fn interface_id() { + fn interface_id_success() { let actual = ::INTERFACE_ID; let expected = 0x780e9d63; assert_eq!(actual, expected); diff --git a/contracts/src/token/erc721/extensions/metadata.rs b/contracts/src/token/erc721/extensions/metadata.rs index cc417c674..63226212d 100644 --- a/contracts/src/token/erc721/extensions/metadata.rs +++ b/contracts/src/token/erc721/extensions/metadata.rs @@ -129,14 +129,14 @@ mod tests { use super::{Erc721Metadata, IErc165, IErc721Metadata}; #[motsu::test] - fn interface_id() { + fn interface_id_success() { let actual = ::INTERFACE_ID; let expected = 0x93254542; assert_eq!(actual, expected); } #[motsu::test] - fn supports_interface() { + fn supports_interface_success() { assert!(::supports_interface( 0x5b5e139f.into() )); diff --git a/contracts/src/token/erc721/extensions/uri_storage.rs b/contracts/src/token/erc721/extensions/uri_storage.rs index 96fdc33a4..ce832de5e 100644 --- a/contracts/src/token/erc721/extensions/uri_storage.rs +++ b/contracts/src/token/erc721/extensions/uri_storage.rs @@ -133,7 +133,7 @@ mod tests { const TOKEN_ID: U256 = uint!(1_U256); #[motsu::test] - fn get_token_uri_works(contract: Erc721MetadataExample) { + fn token_uri_read_success(contract: Erc721MetadataExample) { let alice = msg::sender(); contract @@ -158,7 +158,7 @@ mod tests { } #[motsu::test] - fn set_token_uri_works(contract: Erc721MetadataExample) { + fn set_token_uri_success(contract: Erc721MetadataExample) { let alice = msg::sender(); contract diff --git a/contracts/src/token/erc721/mod.rs b/contracts/src/token/erc721/mod.rs index 21a9b0c4f..b435e2051 100644 --- a/contracts/src/token/erc721/mod.rs +++ b/contracts/src/token/erc721/mod.rs @@ -1166,7 +1166,7 @@ mod tests { const TOKEN_ID: U256 = uint!(1_U256); #[motsu::test] - fn error_when_checking_balance_of_invalid_owner(contract: Erc721) { + fn balance_of_reverts_when_owner_invalid(contract: Erc721) { let invalid_owner = Address::ZERO; let err = contract .balance_of(invalid_owner) @@ -1178,7 +1178,7 @@ mod tests { } #[motsu::test] - fn balance_of_zero_balance(contract: Erc721) { + fn balance_of_success_with_zero_balance(contract: Erc721) { let owner = msg::sender(); let balance = contract.balance_of(owner).expect("should return `U256::ZERO`"); @@ -1186,7 +1186,7 @@ mod tests { } #[motsu::test] - fn error_when_checking_owner_of_nonexistent_token(contract: Erc721) { + fn owner_of_reverts_when_token_nonexistent(contract: Erc721) { let err = contract .owner_of(TOKEN_ID) .expect_err("should return Error::NonexistentToken"); @@ -1200,7 +1200,7 @@ mod tests { } #[motsu::test] - fn mints(contract: Erc721) { + fn mint_success(contract: Erc721) { let alice = msg::sender(); let initial_balance = contract @@ -1221,7 +1221,7 @@ mod tests { } #[motsu::test] - fn error_when_minting_token_id_twice(contract: Erc721) { + fn mint_reverts_when_token_already_exists(contract: Erc721) { let alice = msg::sender(); contract ._mint(alice, TOKEN_ID) @@ -1237,7 +1237,7 @@ mod tests { } #[motsu::test] - fn error_when_minting_token_invalid_receiver(contract: Erc721) { + fn mint_reverts_when_receiver_invalid(contract: Erc721) { let invalid_receiver = Address::ZERO; let err = contract @@ -1253,7 +1253,7 @@ mod tests { } #[motsu::test] - fn safe_mints(contract: Erc721) { + fn safe_mint_success(contract: Erc721) { let alice = msg::sender(); let initial_balance = contract @@ -1277,7 +1277,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_mint_token_id_twice(contract: Erc721) { + fn safe_mint_reverts_when_token_already_exists(contract: Erc721) { let alice = msg::sender(); contract ._mint(alice, TOKEN_ID) @@ -1294,7 +1294,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_mint_invalid_receiver(contract: Erc721) { + fn safe_mint_reverts_when_receiver_invalid(contract: Erc721) { let invalid_receiver = Address::ZERO; let err = contract @@ -1310,7 +1310,7 @@ mod tests { } #[motsu::test] - fn transfers_from(contract: Erc721) { + fn transfer_from_success(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); contract @@ -1323,7 +1323,7 @@ mod tests { } #[motsu::test] - fn transfers_from_approved_token(contract: Erc721) { + fn transfer_from_success_with_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); contract._token_approvals.setter(TOKEN_ID).set(alice); @@ -1337,7 +1337,7 @@ mod tests { } #[motsu::test] - fn transfers_from_approved_for_all(contract: Erc721) { + fn transfer_from_success_with_approval_for_all(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); @@ -1358,9 +1358,7 @@ mod tests { } #[motsu::test] - fn error_when_transfer_from_transfers_to_invalid_receiver( - contract: Erc721, - ) { + fn transfer_from_reverts_when_receiver_invalid(contract: Erc721) { let alice = msg::sender(); let invalid_receiver = Address::ZERO; @@ -1384,9 +1382,7 @@ mod tests { } #[motsu::test] - fn error_when_transfer_from_transfers_from_incorrect_owner( - contract: Erc721, - ) { + fn transfer_from_reverts_when_owner_incorrect(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -1411,9 +1407,7 @@ mod tests { } #[motsu::test] - fn error_when_transfer_from_transfers_with_insufficient_approval( - contract: Erc721, - ) { + fn transfer_from_reverts_when_approval_insufficient(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); let err = contract @@ -1429,7 +1423,7 @@ mod tests { } #[motsu::test] - fn error_when_transfer_from_transfers_nonexistent_token(contract: Erc721) { + fn transfer_from_reverts_when_token_nonexistent(contract: Erc721) { let alice = msg::sender(); let err = contract .transfer_from(alice, BOB, TOKEN_ID) @@ -1443,7 +1437,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_from(contract: Erc721) { + fn safe_transfer_from_success(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -1459,7 +1453,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_from_approved_token(contract: Erc721) { + fn safe_transfer_from_success_with_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); contract._token_approvals.setter(TOKEN_ID).set(alice); @@ -1473,7 +1467,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_from_approved_for_all(contract: Erc721) { + fn safe_transfer_from_success_with_approval_for_all(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); @@ -1494,7 +1488,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_to_invalid_receiver(contract: Erc721) { + fn safe_transfer_from_reverts_when_receiver_invalid(contract: Erc721) { let alice = msg::sender(); let invalid_receiver = Address::ZERO; @@ -1518,9 +1512,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_from_transfers_from_incorrect_owner( - contract: Erc721, - ) { + fn safe_transfer_from_reverts_when_owner_incorrect(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -1545,9 +1537,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_from_transfers_with_insufficient_approval( - contract: Erc721, - ) { + fn safe_transfer_from_reverts_when_approval_insufficient(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); let err = contract @@ -1563,9 +1553,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_from_transfers_nonexistent_token( - contract: Erc721, - ) { + fn safe_transfer_from_reverts_when_token_nonexistent(contract: Erc721) { let alice = msg::sender(); let err = contract .safe_transfer_from(alice, BOB, TOKEN_ID) @@ -1579,7 +1567,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_from_with_data(contract: Erc721) { + fn safe_transfer_from_success_with_data(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -1600,7 +1588,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_from_with_data_approved_token(contract: Erc721) { + fn safe_transfer_from_success_with_data_and_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); contract._token_approvals.setter(TOKEN_ID).set(alice); @@ -1619,7 +1607,9 @@ mod tests { } #[motsu::test] - fn safe_transfers_from_with_data_approved_for_all(contract: Erc721) { + fn safe_transfer_from_success_with_data_and_approval_for_all( + contract: Erc721, + ) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); @@ -1645,7 +1635,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_from_with_data_transfers_to_invalid_receiver( + fn safe_transfer_from_with_data_reverts_when_receiver_invalid( contract: Erc721, ) { let alice = msg::sender(); @@ -1676,7 +1666,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_from_with_data_transfers_from_incorrect_owner( + fn safe_transfer_from_with_data_reverts_when_owner_incorrect( contract: Erc721, ) { let alice = msg::sender(); @@ -1710,7 +1700,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_from_with_data_transfers_with_insufficient_approval( + fn safe_transfer_from_with_data_reverts_when_approval_insufficient( contract: Erc721, ) { let alice = msg::sender(); @@ -1733,7 +1723,7 @@ mod tests { } #[motsu::test] - fn error_when_safe_transfer_from_with_data_transfers_nonexistent_token( + fn safe_transfer_from_with_data_reverts_when_token_nonexistent( contract: Erc721, ) { let alice = msg::sender(); @@ -1754,7 +1744,7 @@ mod tests { } #[motsu::test] - fn approves(contract: Erc721) { + fn approve_success(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); contract @@ -1764,7 +1754,7 @@ mod tests { } #[motsu::test] - fn error_when_approve_for_nonexistent_token(contract: Erc721) { + fn approve_reverts_when_token_nonexistent(contract: Erc721) { let err = contract .approve(BOB, TOKEN_ID) .expect_err("should not approve for a non-existent token"); @@ -1778,7 +1768,7 @@ mod tests { } #[motsu::test] - fn error_when_approve_by_invalid_approver(contract: Erc721) { + fn approve_reverts_when_approver_invalid(contract: Erc721) { contract._mint(BOB, TOKEN_ID).expect("should mint a token"); let err = contract @@ -1794,7 +1784,7 @@ mod tests { } #[motsu::test] - fn approval_for_all(contract: Erc721) { + fn approve_for_all_success(contract: Erc721) { let alice = msg::sender(); contract._operator_approvals.setter(alice).setter(BOB).set(false); @@ -1810,7 +1800,7 @@ mod tests { } #[motsu::test] - fn error_when_approval_for_all_for_invalid_operator(contract: Erc721) { + fn approve_for_all_reverts_when_operator_invalid(contract: Erc721) { let invalid_operator = Address::ZERO; let err = contract @@ -1826,7 +1816,7 @@ mod tests { } #[motsu::test] - fn error_when_get_approved_of_nonexistent_token(contract: Erc721) { + fn get_approved_reverts_when_token_nonexistent(contract: Erc721) { let err = contract .get_approved(TOKEN_ID) .expect_err("should not return approved for a non-existent token"); @@ -1840,7 +1830,7 @@ mod tests { } #[motsu::test] - fn owner_of_works(contract: Erc721) { + fn owner_of_success(contract: Erc721) { contract._mint(BOB, TOKEN_ID).expect("should mint a token"); let owner = contract._owner_of(TOKEN_ID); @@ -1848,19 +1838,19 @@ mod tests { } #[motsu::test] - fn owner_of_nonexistent_token(contract: Erc721) { + fn owner_of_read_success_with_nonexistent_token(contract: Erc721) { let owner = contract._owner_of(TOKEN_ID); assert_eq!(Address::ZERO, owner); } #[motsu::test] - fn get_approved_nonexistent_token(contract: Erc721) { + fn get_approved_success_with_nonexistent_token(contract: Erc721) { let approved = contract._get_approved(TOKEN_ID); assert_eq!(Address::ZERO, approved); } #[motsu::test] - fn get_approved_token_without_approval(contract: Erc721) { + fn get_approved_success_with_no_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); @@ -1869,7 +1859,7 @@ mod tests { } #[motsu::test] - fn get_approved_token_with_approval(contract: Erc721) { + fn get_approved_success_with_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); @@ -1882,7 +1872,7 @@ mod tests { } #[motsu::test] - fn get_approved_token_with_approval_for_all(contract: Erc721) { + fn get_approved_success_with_approval_for_all(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); @@ -1895,14 +1885,14 @@ mod tests { } #[motsu::test] - fn is_authorized_nonexistent_token(contract: Erc721) { + fn is_authorized_success_with_nonexistent_token(contract: Erc721) { let alice = msg::sender(); let authorized = contract._is_authorized(alice, BOB, TOKEN_ID); assert!(!authorized); } #[motsu::test] - fn is_authorized_token_owner(contract: Erc721) { + fn is_authorized_success_with_token_owner(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); @@ -1911,7 +1901,7 @@ mod tests { } #[motsu::test] - fn is_authorized_without_approval(contract: Erc721) { + fn is_authorized_success_with_no_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); @@ -1920,7 +1910,7 @@ mod tests { } #[motsu::test] - fn is_authorized_with_approval(contract: Erc721) { + fn is_authorized_success_with_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); contract @@ -1932,7 +1922,7 @@ mod tests { } #[motsu::test] - fn is_authorized_with_approval_for_all(contract: Erc721) { + fn is_authorized_success_with_approval_for_all(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); contract @@ -1944,7 +1934,7 @@ mod tests { } #[motsu::test] - fn check_authorized_nonexistent_token(contract: Erc721) { + fn check_authorized_reverts_when_token_nonexistent(contract: Erc721) { let alice = msg::sender(); let err = contract ._check_authorized(Address::ZERO, alice, TOKEN_ID) @@ -1959,7 +1949,7 @@ mod tests { } #[motsu::test] - fn check_authorized_token_owner(contract: Erc721) { + fn check_authorized_success_with_token_owner(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); @@ -1969,7 +1959,7 @@ mod tests { } #[motsu::test] - fn check_authorized_without_approval(contract: Erc721) { + fn check_authorized_reverts_when_not_approved(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); @@ -1987,7 +1977,7 @@ mod tests { } #[motsu::test] - fn check_authorized_with_approval(contract: Erc721) { + fn check_authorized_success_with_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); contract @@ -1999,7 +1989,7 @@ mod tests { } #[motsu::test] - fn check_authorized_with_approval_for_all(contract: Erc721) { + fn check_authorized_success_with_approval_for_all(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); contract @@ -2011,7 +2001,7 @@ mod tests { } #[motsu::test] - fn burns(contract: Erc721) { + fn burn_success(contract: Erc721) { let alice = msg::sender(); let one = uint!(1_U256); @@ -2043,7 +2033,7 @@ mod tests { } #[motsu::test] - fn error_when_get_approved_of_previous_approval_burned(contract: Erc721) { + fn get_approved_reverts_when_token_burned(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token for Alice"); @@ -2066,7 +2056,7 @@ mod tests { } #[motsu::test] - fn error_when_burn_nonexistent_token(contract: Erc721) { + fn burn_reverts_when_token_nonexistent(contract: Erc721) { let err = contract ._burn(TOKEN_ID) .expect_err("should return Error::NonexistentToken"); @@ -2080,7 +2070,7 @@ mod tests { } #[motsu::test] - fn transfers(contract: Erc721) { + fn transfer_success(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); contract @@ -2093,7 +2083,7 @@ mod tests { } #[motsu::test] - fn transfers_approved_token(contract: Erc721) { + fn transfer_success_with_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); contract._token_approvals.setter(TOKEN_ID).set(alice); @@ -2107,7 +2097,7 @@ mod tests { } #[motsu::test] - fn transfers_approved_for_all(contract: Erc721) { + fn transfer_success_with_approval_for_all(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); @@ -2128,7 +2118,7 @@ mod tests { } #[motsu::test] - fn error_when_transfer_transfers_to_invalid_receiver(contract: Erc721) { + fn transfer_reverts_when_receiver_invalid(contract: Erc721) { let alice = msg::sender(); let invalid_receiver = Address::ZERO; @@ -2152,7 +2142,7 @@ mod tests { } #[motsu::test] - fn error_when_transfer_transfers_from_incorrect_owner(contract: Erc721) { + fn transfer_reverts_when_owner_incorrect(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -2178,7 +2168,7 @@ mod tests { } #[motsu::test] - fn error_when_transfer_transfers_nonexistent_token(contract: Erc721) { + fn transfer_reverts_when_token_nonexistent(contract: Erc721) { let alice = msg::sender(); let err = contract ._transfer(alice, BOB, TOKEN_ID) @@ -2192,7 +2182,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_internal(contract: Erc721) { + fn safe_transfer_success(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -2208,7 +2198,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_internal_approved_token(contract: Erc721) { + fn safe_transfer_success_with_approval(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); contract._token_approvals.setter(TOKEN_ID).set(alice); @@ -2222,7 +2212,7 @@ mod tests { } #[motsu::test] - fn safe_transfers_internal_approved_for_all(contract: Erc721) { + fn safe_transfer_success_with_approval_for_all(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint token to Bob"); @@ -2243,7 +2233,7 @@ mod tests { } #[motsu::test] - fn error_when_internal_safe_transfer_to_invalid_receiver(contract: Erc721) { + fn safe_transfer_reverts_when_receiver_invalid(contract: Erc721) { let alice = msg::sender(); let invalid_receiver = Address::ZERO; @@ -2272,9 +2262,7 @@ mod tests { } #[motsu::test] - fn error_when_internal_safe_transfer_from_incorrect_owner( - contract: Erc721, - ) { + fn safe_transfer_reverts_when_owner_incorrect(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token to Alice"); @@ -2299,7 +2287,7 @@ mod tests { } #[motsu::test] - fn error_when_internal_safe_transfer_nonexistent_token(contract: Erc721) { + fn safe_transfer_reverts_when_token_nonexistent(contract: Erc721) { let alice = msg::sender(); let err = contract ._safe_transfer(alice, BOB, TOKEN_ID, &vec![0, 1, 2, 3].into()) @@ -2314,7 +2302,7 @@ mod tests { } #[motsu::test] - fn approves_internal(contract: Erc721) { + fn approve_internal_success(contract: Erc721) { let alice = msg::sender(); contract._mint(alice, TOKEN_ID).expect("should mint a token"); contract @@ -2324,7 +2312,7 @@ mod tests { } #[motsu::test] - fn error_when_approve_internal_for_nonexistent_token(contract: Erc721) { + fn approve_internal_reverts_when_token_nonexistent(contract: Erc721) { let err = contract ._approve(BOB, TOKEN_ID, msg::sender(), false) .expect_err("should not approve for a non-existent token"); @@ -2338,7 +2326,7 @@ mod tests { } #[motsu::test] - fn error_when_approve_internal_by_invalid_approver(contract: Erc721) { + fn approve_internal_reverts_when_approver_invalid(contract: Erc721) { let alice = msg::sender(); contract._mint(BOB, TOKEN_ID).expect("should mint a token"); @@ -2355,7 +2343,7 @@ mod tests { } #[motsu::test] - fn approval_for_all_internal(contract: Erc721) { + fn approve_for_all_internal_success(contract: Erc721) { let alice = msg::sender(); contract._operator_approvals.setter(alice).setter(BOB).set(false); @@ -2371,7 +2359,7 @@ mod tests { } #[motsu::test] - fn error_when_approval_for_all_internal_for_invalid_operator( + fn approve_for_all_internal_reverts_when_operator_invalid( contract: Erc721, ) { let invalid_operator = Address::ZERO; @@ -2389,7 +2377,7 @@ mod tests { } #[motsu::test] - fn require_owned_works(contract: Erc721) { + fn require_owned_success(contract: Erc721) { contract._mint(BOB, TOKEN_ID).expect("should mint a token"); let owner = contract @@ -2400,7 +2388,7 @@ mod tests { } #[motsu::test] - fn error_when_require_owned_for_nonexistent_token(contract: Erc721) { + fn require_owned_reverts_when_token_nonexistent(contract: Erc721) { let err = contract ._require_owned(TOKEN_ID) .expect_err("should return Error::NonexistentToken"); @@ -2414,7 +2402,7 @@ mod tests { } #[motsu::test] - fn interface_id() { + fn interface_id_success() { let actual = ::INTERFACE_ID; let expected = 0x80ac58cd; assert_eq!(actual, expected); diff --git a/contracts/src/utils/cryptography/ecdsa.rs b/contracts/src/utils/cryptography/ecdsa.rs index 73d7d6152..3f0507f79 100644 --- a/contracts/src/utils/cryptography/ecdsa.rs +++ b/contracts/src/utils/cryptography/ecdsa.rs @@ -224,14 +224,14 @@ mod tests { ); #[test] - fn prepares_calldata() { + fn encode_calldata_success() { let expected = alloy_primitives::bytes!("a1de988600a42c4b4ab089b619297c17d53cffae5d5120d82d8a92d0bb3b78f2000000000000000000000000000000000000000000000000000000000000001c65e72b1cf8e189569963750e10ccb88fe89389daeeb8b735277d59cd6885ee823eb5a6982b540f185703492dab77b863a88ce01f27e21ade8b2879c10fc9e653"); let calldata = encode_calldata(MSG_HASH, V, R, S); assert_eq!(expected, calldata); } #[test] - fn rejects_invalid_s() { + fn check_if_malleable_reverts_when_s_invalid() { let invalid_s = SIGNATURE_S_UPPER_BOUND + uint!(1_U256); let invalid_s = B256::from_slice(&invalid_s.to_be_bytes_vec()); let err = check_if_malleable(&invalid_s) @@ -245,7 +245,7 @@ mod tests { } #[test] - fn validates_s() { + fn check_if_malleable_success_with_valid_s() { let valid_s = SIGNATURE_S_UPPER_BOUND - uint!(1_U256); let invalid_s = B256::from_slice(&valid_s.to_be_bytes_vec()); let result = check_if_malleable(&invalid_s); diff --git a/contracts/src/utils/cryptography/eip712.rs b/contracts/src/utils/cryptography/eip712.rs index f69d63809..1c685e97d 100644 --- a/contracts/src/utils/cryptography/eip712.rs +++ b/contracts/src/utils/cryptography/eip712.rs @@ -163,7 +163,7 @@ mod tests { } #[test] - fn domain_test() { + fn eip712_domain_success() { let contract = TestEIP712::default(); let domain = contract.eip712_domain(); assert_eq!(FIELDS, domain.0); @@ -176,7 +176,7 @@ mod tests { } #[test] - fn test_to_typed_data_hash() { + fn to_typed_data_hash_success() { // TYPE_HASH let domain_separator = b256!( "8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f" diff --git a/contracts/src/utils/math/alloy.rs b/contracts/src/utils/math/alloy.rs index c3f385529..81f6e512b 100644 --- a/contracts/src/utils/math/alloy.rs +++ b/contracts/src/utils/math/alloy.rs @@ -154,7 +154,7 @@ mod tests { use crate::utils::math::alloy::Math; #[test] - fn check_sqrt() { + fn sqrt_success() { proptest!(|(value: U256)| { // U256::root(..) method requires std. Can only be used in tests. assert_eq!(value.sqrt(), value.root(2)); @@ -162,7 +162,7 @@ mod tests { } #[test] - fn check_average() { + fn average_success() { proptest!(|(left: U256, right: U256)| { // compute average in straight forward way with overflow and downcast. let expected = (U512::from(left) + U512::from(right)) / uint!(2_U512); diff --git a/contracts/src/utils/nonces.rs b/contracts/src/utils/nonces.rs index 4a588af5f..29f688a56 100644 --- a/contracts/src/utils/nonces.rs +++ b/contracts/src/utils/nonces.rs @@ -122,12 +122,12 @@ mod tests { use crate::utils::nonces::{Error, Nonces}; #[motsu::test] - fn initiate_nonce(contract: Nonces) { + fn nonce_read_success_with_initialization(contract: Nonces) { assert_eq!(contract.nonces(msg::sender()), U256::ZERO); } #[motsu::test] - fn use_nonce(contract: Nonces) { + fn use_nonce_success(contract: Nonces) { let owner = msg::sender(); let use_nonce = contract.use_nonce(owner); @@ -138,7 +138,7 @@ mod tests { } #[motsu::test] - fn use_checked_nonce(contract: Nonces) { + fn use_checked_nonce_success(contract: Nonces) { let owner = msg::sender(); let use_checked_nonce = contract.use_checked_nonce(owner, U256::ZERO); @@ -149,7 +149,7 @@ mod tests { } #[motsu::test] - fn use_checked_nonce_invalid_nonce(contract: Nonces) { + fn use_checked_nonce_reverts_when_nonce_invalid(contract: Nonces) { let owner = msg::sender(); let use_checked_nonce = contract.use_checked_nonce(owner, ONE); diff --git a/contracts/src/utils/pausable.rs b/contracts/src/utils/pausable.rs index 60e369628..63d5b6ed9 100644 --- a/contracts/src/utils/pausable.rs +++ b/contracts/src/utils/pausable.rs @@ -161,7 +161,7 @@ mod tests { use crate::utils::pausable::{Error, Pausable}; #[motsu::test] - fn paused_works(contract: Pausable) { + fn paused_read_success(contract: Pausable) { contract._paused.set(false); assert!(!contract.paused()); contract._paused.set(true); @@ -169,7 +169,7 @@ mod tests { } #[motsu::test] - fn when_not_paused_works(contract: Pausable) { + fn when_not_paused_success(contract: Pausable) { contract._paused.set(false); assert!(!contract.paused()); @@ -178,7 +178,7 @@ mod tests { } #[motsu::test] - fn when_not_paused_errors_when_paused(contract: Pausable) { + fn when_not_paused_reverts_when_paused(contract: Pausable) { contract._paused.set(true); assert!(contract.paused()); @@ -187,7 +187,7 @@ mod tests { } #[motsu::test] - fn when_paused_works(contract: Pausable) { + fn when_paused_success(contract: Pausable) { contract._paused.set(true); assert!(contract.paused()); @@ -196,7 +196,7 @@ mod tests { } #[motsu::test] - fn when_paused_errors_when_not_paused(contract: Pausable) { + fn when_paused_reverts_when_not_paused(contract: Pausable) { contract._paused.set(false); assert!(!contract.paused()); @@ -205,7 +205,7 @@ mod tests { } #[motsu::test] - fn pause_works(contract: Pausable) { + fn pause_success(contract: Pausable) { contract._paused.set(false); assert!(!contract.paused()); @@ -216,7 +216,7 @@ mod tests { } #[motsu::test] - fn pause_errors_when_already_paused(contract: Pausable) { + fn pause_reverts_when_already_paused(contract: Pausable) { contract._paused.set(true); assert!(contract.paused()); @@ -226,7 +226,7 @@ mod tests { } #[motsu::test] - fn unpause_works(contract: Pausable) { + fn unpause_success(contract: Pausable) { contract._paused.set(true); assert!(contract.paused()); @@ -237,7 +237,7 @@ mod tests { } #[motsu::test] - fn unpause_errors_when_already_unpaused(contract: Pausable) { + fn unpause_reverts_when_already_unpaused(contract: Pausable) { contract._paused.set(false); assert!(!contract.paused()); diff --git a/contracts/src/utils/structs/bitmap.rs b/contracts/src/utils/structs/bitmap.rs index 40f808a18..6164aee6a 100644 --- a/contracts/src/utils/structs/bitmap.rs +++ b/contracts/src/utils/structs/bitmap.rs @@ -102,7 +102,7 @@ mod tests { use crate::utils::structs::bitmap::BitMap; #[motsu::test] - fn set_value() { + fn set_success() { proptest!(|(value: U256)| { let mut bit_map = BitMap::default(); assert!(!bit_map.get(value)); @@ -112,7 +112,7 @@ mod tests { } #[motsu::test] - fn unset_value() { + fn unset_success() { proptest!(|(value: U256)| { let mut bit_map = BitMap::default(); bit_map.set(value); @@ -123,7 +123,7 @@ mod tests { } #[motsu::test] - fn set_to_value() { + fn set_to_success() { proptest!(|(value: U256)| { let mut bit_map = BitMap::default(); bit_map.set_to(value, true); diff --git a/contracts/src/utils/structs/checkpoints/mod.rs b/contracts/src/utils/structs/checkpoints/mod.rs index 81d522f58..9aa004d4c 100644 --- a/contracts/src/utils/structs/checkpoints/mod.rs +++ b/contracts/src/utils/structs/checkpoints/mod.rs @@ -384,7 +384,7 @@ mod tests { }; #[motsu::test] - fn push(checkpoint: Trace) { + fn push_success(checkpoint: Trace) { let first_key = uint!(1_U96); let first_value = uint!(11_U160); @@ -406,7 +406,7 @@ mod tests { } #[motsu::test] - fn push_same_value(checkpoint: Trace) { + fn push_success_with_same_value(checkpoint: Trace) { let first_key = uint!(1_U96); let first_value = uint!(11_U160); @@ -431,7 +431,7 @@ mod tests { } #[motsu::test] - fn lower_lookup(checkpoint: Trace) { + fn lower_lookup_success(checkpoint: Trace) { checkpoint.push(uint!(1_U96), uint!(11_U160)).expect("push first"); checkpoint.push(uint!(3_U96), uint!(33_U160)).expect("push second"); checkpoint.push(uint!(5_U96), uint!(55_U160)).expect("push third"); @@ -443,7 +443,7 @@ mod tests { } #[motsu::test] - fn upper_lookup(checkpoint: Trace) { + fn upper_lookup_success(checkpoint: Trace) { checkpoint.push(uint!(1_U96), uint!(11_U160)).expect("push first"); checkpoint.push(uint!(3_U96), uint!(33_U160)).expect("push second"); checkpoint.push(uint!(5_U96), uint!(55_U160)).expect("push third"); @@ -455,7 +455,7 @@ mod tests { } #[motsu::test] - fn upper_lookup_recent(checkpoint: Trace) { + fn upper_lookup_recent_success(checkpoint: Trace) { // `upper_lookup_recent` has different optimizations for "short" (<=5) // and "long" (>5) checkpoint arrays. // @@ -499,7 +499,7 @@ mod tests { } #[motsu::test] - fn latest(checkpoint: Trace) { + fn latest_success(checkpoint: Trace) { assert_eq!(checkpoint.latest(), uint!(0_U160)); checkpoint.push(uint!(1_U96), uint!(11_U160)).expect("push first"); checkpoint.push(uint!(3_U96), uint!(33_U160)).expect("push second"); @@ -508,7 +508,7 @@ mod tests { } #[motsu::test] - fn latest_checkpoint(checkpoint: Trace) { + fn latest_checkpoint_success(checkpoint: Trace) { assert_eq!(checkpoint.latest_checkpoint(), None); checkpoint.push(uint!(1_U96), uint!(11_U160)).expect("push first"); checkpoint.push(uint!(3_U96), uint!(33_U160)).expect("push second"); @@ -520,7 +520,7 @@ mod tests { } #[motsu::test] - fn error_when_unordered_insertion(checkpoint: Trace) { + fn push_reverts_when_insertion_unordered(checkpoint: Trace) { checkpoint.push(uint!(1_U96), uint!(11_U160)).expect("push first"); checkpoint.push(uint!(3_U96), uint!(33_U160)).expect("push second"); let err = checkpoint diff --git a/examples/access-control/tests/access_control.rs b/examples/access-control/tests/access_control.rs index d8eb52c29..1ba926bc6 100644 --- a/examples/access-control/tests/access_control.rs +++ b/examples/access-control/tests/access_control.rs @@ -21,7 +21,7 @@ const NEW_ADMIN_ROLE: [u8; 32] = // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> Result<()> { +async fn constructor_success(alice: Account) -> Result<()> { let alice_addr = alice.address(); let receipt = alice.as_deployer().deploy().await?; let contract = AccessControl::new(receipt.address()?, &alice.wallet); @@ -40,9 +40,7 @@ async fn constructs(alice: Account) -> Result<()> { } #[e2e::test] -async fn other_roles_admin_is_the_default_admin_role( - alice: Account, -) -> Result<()> { +async fn role_admin_success_with_default_admin(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = AccessControl::new(contract_addr, &alice.wallet); @@ -54,7 +52,7 @@ async fn other_roles_admin_is_the_default_admin_role( } #[e2e::test] -async fn default_role_is_default_admin(alice: Account) -> Result<()> { +async fn default_admin_role_success(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = AccessControl::new(contract_addr, &alice.wallet); @@ -70,7 +68,7 @@ async fn default_role_is_default_admin(alice: Account) -> Result<()> { } #[e2e::test] -async fn error_when_non_admin_grants_role( +async fn grant_role_reverts_when_not_admin( alice: Account, bob: Account, ) -> Result<()> { @@ -90,7 +88,7 @@ async fn error_when_non_admin_grants_role( } #[e2e::test] -async fn accounts_can_be_granted_roles_multiple_times( +async fn grant_role_success_with_multiple_grants( alice: Account, bob: Account, ) -> Result<()> { @@ -117,7 +115,7 @@ async fn accounts_can_be_granted_roles_multiple_times( } #[e2e::test] -async fn not_granted_roles_can_be_revoked(alice: Account) -> Result<()> { +async fn revoke_role_success_with_ungranted_role(alice: Account) -> Result<()> { let alice_addr = alice.address(); let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = AccessControl::new(contract_addr, &alice.wallet); @@ -137,7 +135,7 @@ async fn not_granted_roles_can_be_revoked(alice: Account) -> Result<()> { } #[e2e::test] -async fn admin_can_revoke_role(alice: Account, bob: Account) -> Result<()> { +async fn revoke_role_success(alice: Account, bob: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = AccessControl::new(contract_addr, &alice.wallet); @@ -157,7 +155,7 @@ async fn admin_can_revoke_role(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn error_when_non_admin_revokes_role( +async fn revoke_role_reverts_when_not_admin( alice: Account, bob: Account, ) -> Result<()> { @@ -181,7 +179,7 @@ async fn error_when_non_admin_revokes_role( } #[e2e::test] -async fn roles_can_be_revoked_multiple_times( +async fn revoke_role_success_with_multiple_revokes( alice: Account, bob: Account, ) -> Result<()> { @@ -203,7 +201,9 @@ async fn roles_can_be_revoked_multiple_times( } #[e2e::test] -async fn not_granted_roles_can_be_renounced(alice: Account) -> Result<()> { +async fn renounce_role_success_with_ungranted_role( + alice: Account, +) -> Result<()> { let alice_addr = alice.address(); let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = AccessControl::new(contract_addr, &alice.wallet); @@ -219,7 +219,7 @@ async fn not_granted_roles_can_be_renounced(alice: Account) -> Result<()> { } #[e2e::test] -async fn bearer_can_renounce_role(alice: Account, bob: Account) -> Result<()> { +async fn renounce_role_success(alice: Account, bob: Account) -> Result<()> { let bob_addr = bob.address(); let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = AccessControl::new(contract_addr, &alice.wallet); @@ -238,7 +238,7 @@ async fn bearer_can_renounce_role(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn error_when_the_one_renouncing_is_not_the_sender( +async fn renounce_role_reverts_when_not_sender( alice: Account, bob: Account, ) -> Result<()> { @@ -259,7 +259,9 @@ async fn error_when_the_one_renouncing_is_not_the_sender( } #[e2e::test] -async fn roles_can_be_renounced_multiple_times(alice: Account) -> Result<()> { +async fn renounce_role_success_with_multiple_renounces( + alice: Account, +) -> Result<()> { let alice_addr = alice.address(); let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = AccessControl::new(contract_addr, &alice.wallet); @@ -276,7 +278,7 @@ async fn roles_can_be_renounced_multiple_times(alice: Account) -> Result<()> { } #[e2e::test] -async fn a_roles_admin_role_can_change(alice: Account) -> Result<()> { +async fn set_role_admin_success(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = AccessControl::new(contract_addr, &alice.wallet); @@ -296,7 +298,7 @@ async fn a_roles_admin_role_can_change(alice: Account) -> Result<()> { } #[e2e::test] -async fn the_new_admin_can_grant_roles( +async fn role_admin_change_success_with_new_grant( alice: Account, bob: Account, ) -> Result<()> { @@ -328,7 +330,7 @@ async fn the_new_admin_can_grant_roles( } #[e2e::test] -async fn the_new_admin_can_revoke_roles( +async fn role_admin_change_success_with_new_revoke( alice: Account, bob: Account, ) -> Result<()> { @@ -361,7 +363,7 @@ async fn the_new_admin_can_revoke_roles( } #[e2e::test] -async fn error_when_previous_admin_grants_roles( +async fn role_admin_change_reverts_when_old_admin_grants( alice: Account, bob: Account, ) -> Result<()> { @@ -390,7 +392,7 @@ async fn error_when_previous_admin_grants_roles( } #[e2e::test] -async fn error_when_previous_admin_revokes_roles( +async fn role_admin_change_reverts_when_old_admin_revokes( alice: Account, bob: Account, ) -> Result<()> { diff --git a/examples/ecdsa/tests/ecdsa.rs b/examples/ecdsa/tests/ecdsa.rs index 1673a6c90..38975b6bc 100644 --- a/examples/ecdsa/tests/ecdsa.rs +++ b/examples/ecdsa/tests/ecdsa.rs @@ -24,7 +24,7 @@ const ADDRESS: Address = address!("f39Fd6e51aad88F6F4ce6aB8827279cffFb92266"); // ============================================================================ #[e2e::test] -async fn ecrecover_works(alice: Account) -> Result<()> { +async fn recover_success(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); @@ -37,9 +37,7 @@ async fn ecrecover_works(alice: Account) -> Result<()> { } #[e2e::test] -async fn different_hash_recovers_different_address( - alice: Account, -) -> Result<()> { +async fn recover_success_with_different_hash(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); @@ -55,7 +53,7 @@ async fn different_hash_recovers_different_address( } #[e2e::test] -async fn different_v_recovers_different_address(alice: Account) -> Result<()> { +async fn recover_success_with_different_v(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); @@ -70,7 +68,7 @@ async fn different_v_recovers_different_address(alice: Account) -> Result<()> { } #[e2e::test] -async fn different_r_recovers_different_address(alice: Account) -> Result<()> { +async fn recover_success_with_different_r(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); @@ -87,7 +85,7 @@ async fn different_r_recovers_different_address(alice: Account) -> Result<()> { } #[e2e::test] -async fn different_s_recovers_different_address(alice: Account) -> Result<()> { +async fn recover_success_with_different_s(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); @@ -103,7 +101,7 @@ async fn different_s_recovers_different_address(alice: Account) -> Result<()> { } #[e2e::test] -async fn recovers_from_v_r_s(alice: Account) -> Result<()> { +async fn recover_from_vrs_success(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); @@ -124,7 +122,7 @@ async fn recovers_from_v_r_s(alice: Account) -> Result<()> { } #[e2e::test] -async fn rejects_v0_with_invalid_signature_error(alice: Account) -> Result<()> { +async fn recover_reverts_when_v_is_zero(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); @@ -141,7 +139,7 @@ async fn rejects_v0_with_invalid_signature_error(alice: Account) -> Result<()> { } #[e2e::test] -async fn rejects_v1_with_invalid_signature_error(alice: Account) -> Result<()> { +async fn recover_reverts_when_v_is_one(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); @@ -158,7 +156,7 @@ async fn rejects_v1_with_invalid_signature_error(alice: Account) -> Result<()> { } #[e2e::test] -async fn error_when_higher_s(alice: Account) -> Result<()> { +async fn recover_reverts_when_s_exceeds_bound(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = ECDSA::new(contract_addr, &alice.wallet); diff --git a/examples/erc1155-metadata-uri/tests/erc1155-metadata-uri.rs b/examples/erc1155-metadata-uri/tests/erc1155-metadata-uri.rs index d57642c2c..8f8c023bd 100644 --- a/examples/erc1155-metadata-uri/tests/erc1155-metadata-uri.rs +++ b/examples/erc1155-metadata-uri/tests/erc1155-metadata-uri.rs @@ -22,7 +22,7 @@ fn ctr(uri: &str) -> constructorCall { // ============================================================================ #[e2e::test] -async fn uri_returns_metadata_uri_when_token_uri_is_not_set( +async fn uri_success_with_metadata_uri_only( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice @@ -43,9 +43,7 @@ async fn uri_returns_metadata_uri_when_token_uri_is_not_set( } #[e2e::test] -async fn uri_returns_empty_string_when_no_uri_is_set( - alice: Account, -) -> eyre::Result<()> { +async fn uri_success_with_no_uri_set(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_constructor(ctr("")) @@ -65,7 +63,7 @@ async fn uri_returns_empty_string_when_no_uri_is_set( } #[e2e::test] -async fn uri_returns_concatenated_base_uri_and_token_uri( +async fn uri_success_with_base_and_token_uri( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice @@ -97,9 +95,7 @@ async fn uri_returns_concatenated_base_uri_and_token_uri( } #[e2e::test] -async fn uri_returns_token_uri_when_base_uri_is_empty( - alice: Account, -) -> eyre::Result<()> { +async fn uri_success_with_token_uri_only(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_constructor(ctr("")) @@ -126,7 +122,7 @@ async fn uri_returns_token_uri_when_base_uri_is_empty( } #[e2e::test] -async fn uri_ignores_metadata_uri_when_token_uri_is_set( +async fn uri_success_when_token_uri_overrides_metadata( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice @@ -162,7 +158,7 @@ async fn uri_ignores_metadata_uri_when_token_uri_is_set( // ============================================================================ #[e2e::test] -async fn supports_interface(alice: Account) -> eyre::Result<()> { +async fn supports_interface_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_constructor(ctr(URI)) diff --git a/examples/erc1155-supply/tests/erc1155-supply.rs b/examples/erc1155-supply/tests/erc1155-supply.rs index bf6682185..bce068549 100644 --- a/examples/erc1155-supply/tests/erc1155-supply.rs +++ b/examples/erc1155-supply/tests/erc1155-supply.rs @@ -23,7 +23,7 @@ fn random_values(size: usize) -> Vec { // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> eyre::Result<()> { +async fn constructor_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); @@ -41,7 +41,7 @@ async fn constructs(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mint(alice: Account) -> eyre::Result<()> { +async fn mint_success_with_supply(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); @@ -75,7 +75,9 @@ async fn mint(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mint_to_receiver_contract(alice: Account) -> eyre::Result<()> { +async fn mint_success_with_receiver_and_supply( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); @@ -124,7 +126,10 @@ async fn mint_to_receiver_contract(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mint_batch(alice: Account, bob: Account) -> eyre::Result<()> { +async fn mint_batch_success_with_supply( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); @@ -177,7 +182,7 @@ async fn mint_batch(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mint_batch_transfer_to_receiver_contract( +async fn mint_batch_success_with_receiver_and_supply( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -247,7 +252,7 @@ async fn mint_batch_transfer_to_receiver_contract( } #[e2e::test] -async fn mint_panics_on_total_supply_overflow( +async fn mint_reverts_when_total_supply_overflows( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -282,7 +287,7 @@ async fn mint_panics_on_total_supply_overflow( } #[e2e::test] -async fn mint_panics_on_total_supply_all_overflow( +async fn mint_reverts_when_total_supply_all_overflows( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -312,7 +317,7 @@ async fn mint_panics_on_total_supply_all_overflow( } #[e2e::test] -async fn burn(alice: Account) -> eyre::Result<()> { +async fn burn_success_with_supply(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); @@ -347,7 +352,10 @@ async fn burn(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn burn_with_approval(alice: Account, bob: Account) -> eyre::Result<()> { +async fn burn_success_with_approval_and_supply( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); let contract_bob = Erc1155Supply::new(contract_addr, &bob.wallet); @@ -385,7 +393,7 @@ async fn burn_with_approval(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn burn_batch(alice: Account) -> eyre::Result<()> { +async fn burn_batch_success_with_supply(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); @@ -432,7 +440,7 @@ async fn burn_batch(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn burn_batch_with_approval( +async fn burn_batch_success_with_approval_and_supply( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -486,7 +494,7 @@ async fn burn_batch_with_approval( } #[e2e::test] -async fn supply_unaffected_by_safe_transfer_from( +async fn total_supply_success_after_single_transfer( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -552,7 +560,7 @@ async fn supply_unaffected_by_safe_transfer_from( } #[e2e::test] -async fn supply_unaffected_by_safe_transfer_from_batch( +async fn total_supply_success_after_batch_transfer( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -639,7 +647,9 @@ async fn supply_unaffected_by_safe_transfer_from_batch( // ===================================================================== #[e2e::test] -async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { +async fn balance_of_success_with_zero_balance( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); let token_ids = random_token_ids(1); @@ -652,7 +662,7 @@ async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn balance_of_batch_zero_balance( +async fn balance_of_batch_success_with_zero_balance( alice: Account, bob: Account, dave: Account, @@ -672,7 +682,7 @@ async fn balance_of_batch_zero_balance( } #[e2e::test] -async fn set_approval_for_all( +async fn set_approval_for_all_success( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -714,7 +724,9 @@ async fn set_approval_for_all( } #[e2e::test] -async fn is_approved_for_all_zero_address(alice: Account) -> eyre::Result<()> { +async fn is_approved_for_all_success_with_zero_address( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); @@ -731,7 +743,10 @@ async fn is_approved_for_all_zero_address(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn safe_transfer_from(alice: Account, bob: Account) -> eyre::Result<()> { +async fn safe_transfer_from_success( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155Supply::new(contract_addr, &alice.wallet); @@ -779,7 +794,7 @@ async fn safe_transfer_from(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn safe_transfer_from_with_approval( +async fn safe_transfer_from_success_with_approval( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -834,7 +849,7 @@ async fn safe_transfer_from_with_approval( } #[e2e::test] -async fn safe_transfer_to_receiver_contract( +async fn safe_transfer_from_success_with_receiver_contract( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -896,7 +911,7 @@ async fn safe_transfer_to_receiver_contract( } #[e2e::test] -async fn safe_batch_transfer_from( +async fn safe_batch_transfer_from_success( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -965,7 +980,7 @@ async fn safe_batch_transfer_from( } #[e2e::test] -async fn safe_batch_transfer_to_receiver_contract( +async fn safe_batch_transfer_from_success_with_receiver_contract( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1051,7 +1066,7 @@ async fn safe_batch_transfer_to_receiver_contract( } #[e2e::test] -async fn safe_batch_transfer_from_with_approval( +async fn safe_batch_transfer_from_success_with_approval( alice: Account, bob: Account, dave: Account, diff --git a/examples/erc1155/tests/erc1155.rs b/examples/erc1155/tests/erc1155.rs index 8953ee18d..cec41b10c 100644 --- a/examples/erc1155/tests/erc1155.rs +++ b/examples/erc1155/tests/erc1155.rs @@ -23,7 +23,7 @@ fn random_values(size: usize) -> Vec { // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> eyre::Result<()> { +async fn constructor_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -35,7 +35,7 @@ async fn constructs(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn invalid_array_length_error_in_balance_of_batch( +async fn balance_of_batch_reverts_when_array_length_invalid( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -60,7 +60,9 @@ async fn invalid_array_length_error_in_balance_of_batch( } #[e2e::test] -async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { +async fn balance_of_success_with_zero_balance( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); let token_ids = random_token_ids(1); @@ -73,7 +75,7 @@ async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn balance_of_batch_zero_balance( +async fn balance_of_batch_success_with_zero_balance( alice: Account, bob: Account, dave: Account, @@ -93,7 +95,7 @@ async fn balance_of_batch_zero_balance( } #[e2e::test] -async fn mints(alice: Account) -> eyre::Result<()> { +async fn mint_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -124,7 +126,9 @@ async fn mints(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mints_to_receiver_contract(alice: Account) -> eyre::Result<()> { +async fn mint_success_with_receiver_contract( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -166,7 +170,7 @@ async fn mints_to_receiver_contract(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn errors_when_receiver_reverts_with_reason_in_mint( +async fn mint_reverts_when_receiver_reverts_with_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -197,7 +201,7 @@ async fn errors_when_receiver_reverts_with_reason_in_mint( } #[e2e::test] -async fn errors_when_receiver_reverts_without_reason_in_mint( +async fn mint_reverts_when_receiver_reverts_without_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -228,9 +232,7 @@ async fn errors_when_receiver_reverts_without_reason_in_mint( } #[e2e::test] -async fn errors_when_receiver_panics_in_mint( - alice: Account, -) -> eyre::Result<()> { +async fn mint_reverts_when_receiver_panics(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -257,7 +259,7 @@ async fn errors_when_receiver_panics_in_mint( } #[e2e::test] -async fn errors_when_invalid_receiver_contract_in_mint( +async fn mint_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -282,7 +284,7 @@ async fn errors_when_invalid_receiver_contract_in_mint( } #[e2e::test] -async fn mint_batch(alice: Account) -> eyre::Result<()> { +async fn mint_batch_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -324,7 +326,7 @@ async fn mint_batch(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mint_batch_transfer_to_receiver_contract( +async fn mint_batch_success_with_receiver_contract( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -390,7 +392,7 @@ async fn mint_batch_transfer_to_receiver_contract( } #[e2e::test] -async fn errors_when_receiver_reverts_with_reason_in_batch_mint( +async fn mint_batch_reverts_when_receiver_reverts_with_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -421,7 +423,7 @@ async fn errors_when_receiver_reverts_with_reason_in_batch_mint( } #[e2e::test] -async fn errors_when_receiver_reverts_without_reason_in_batch_mint( +async fn mint_batch_reverts_when_receiver_reverts_without_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -452,7 +454,7 @@ async fn errors_when_receiver_reverts_without_reason_in_batch_mint( } #[e2e::test] -async fn errors_when_receiver_panics_in_batch_mint( +async fn mint_batch_reverts_when_receiver_panics( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -481,7 +483,7 @@ async fn errors_when_receiver_panics_in_batch_mint( } #[e2e::test] -async fn errors_when_invalid_receiver_contract_in_batch_mint( +async fn mint_batch_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -506,7 +508,7 @@ async fn errors_when_invalid_receiver_contract_in_batch_mint( } #[e2e::test] -async fn error_invalid_array_length_in_batch_mint( +async fn mint_batch_reverts_when_array_length_invalid( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -534,7 +536,7 @@ async fn error_invalid_array_length_in_batch_mint( } #[e2e::test] -async fn set_approval_for_all( +async fn set_approval_for_all_success( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -576,7 +578,7 @@ async fn set_approval_for_all( } #[e2e::test] -async fn error_when_invalid_operator_approval_for_all( +async fn set_approval_for_all_reverts_when_operator_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -595,7 +597,9 @@ async fn error_when_invalid_operator_approval_for_all( } #[e2e::test] -async fn is_approved_for_all_zero_address(alice: Account) -> eyre::Result<()> { +async fn is_approved_for_all_success_with_zero_address( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -612,7 +616,10 @@ async fn is_approved_for_all_zero_address(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn safe_transfer_from(alice: Account, bob: Account) -> eyre::Result<()> { +async fn safe_transfer_from_success( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -660,7 +667,7 @@ async fn safe_transfer_from(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn safe_transfer_from_with_approval( +async fn safe_transfer_from_success_with_approval( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -715,7 +722,7 @@ async fn safe_transfer_from_with_approval( } #[e2e::test] -async fn safe_transfer_to_receiver_contract( +async fn safe_transfer_from_success_with_receiver_contract( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -777,7 +784,7 @@ async fn safe_transfer_to_receiver_contract( } #[e2e::test] -async fn errors_when_receiver_reverts_with_reason( +async fn safe_transfer_from_reverts_when_receiver_reverts_with_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -817,7 +824,7 @@ async fn errors_when_receiver_reverts_with_reason( } #[e2e::test] -async fn errors_when_receiver_reverts_without_reason( +async fn safe_transfer_from_reverts_when_receiver_reverts_without_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -857,7 +864,9 @@ async fn errors_when_receiver_reverts_without_reason( } #[e2e::test] -async fn errors_when_receiver_panics(alice: Account) -> eyre::Result<()> { +async fn safe_transfer_from_reverts_when_receiver_panics( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -893,7 +902,7 @@ async fn errors_when_receiver_panics(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn errors_when_invalid_receiver_contract( +async fn safe_transfer_from_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -927,7 +936,7 @@ async fn errors_when_invalid_receiver_contract( } #[e2e::test] -async fn error_when_invalid_receiver_safe_transfer_from( +async fn safe_transfer_from_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -956,7 +965,7 @@ async fn error_when_invalid_receiver_safe_transfer_from( } #[e2e::test] -async fn error_when_missing_approval_safe_transfer_from( +async fn safe_transfer_from_reverts_when_approval_missing( alice: Account, bob: Account, dave: Account, @@ -989,7 +998,7 @@ async fn error_when_missing_approval_safe_transfer_from( } #[e2e::test] -async fn error_when_insufficient_balance_safe_transfer_from( +async fn safe_transfer_from_reverts_when_balance_insufficient( alice: Account, bob: Account, dave: Account, @@ -1028,7 +1037,7 @@ async fn error_when_insufficient_balance_safe_transfer_from( } #[e2e::test] -async fn safe_batch_transfer_from( +async fn safe_batch_transfer_from_success( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1096,7 +1105,7 @@ async fn safe_batch_transfer_from( } #[e2e::test] -async fn safe_batch_transfer_to_receiver_contract( +async fn safe_batch_transfer_from_success_with_receiver_contract( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1182,7 +1191,7 @@ async fn safe_batch_transfer_to_receiver_contract( } #[e2e::test] -async fn errors_when_receiver_reverts_with_reason_in_batch_transfer( +async fn safe_batch_transfer_from_reverts_when_receiver_reverts_with_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1222,7 +1231,7 @@ async fn errors_when_receiver_reverts_with_reason_in_batch_transfer( } #[e2e::test] -async fn errors_when_receiver_reverts_without_reason_in_batch_transfer( +async fn safe_batch_transfer_from_reverts_when_receiver_reverts_without_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1262,7 +1271,7 @@ async fn errors_when_receiver_reverts_without_reason_in_batch_transfer( } #[e2e::test] -async fn errors_when_receiver_panics_in_batch_transfer( +async fn safe_batch_transfer_from_reverts_when_receiver_panics( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1300,7 +1309,7 @@ async fn errors_when_receiver_panics_in_batch_transfer( } #[e2e::test] -async fn errors_when_invalid_receiver_contract_in_batch_transfer( +async fn safe_batch_transfer_from_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1334,7 +1343,7 @@ async fn errors_when_invalid_receiver_contract_in_batch_transfer( } #[e2e::test] -async fn safe_batch_transfer_from_with_approval( +async fn safe_batch_transfer_from_success_with_approval( alice: Account, bob: Account, dave: Account, @@ -1407,7 +1416,7 @@ async fn safe_batch_transfer_from_with_approval( } #[e2e::test] -async fn error_when_invalid_receiver_safe_batch_transfer_from( +async fn safe_batch_transfer_from_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1442,7 +1451,7 @@ async fn error_when_invalid_receiver_safe_batch_transfer_from( } #[e2e::test] -async fn error_invalid_array_length_in_safe_batch_transfer_from( +async fn safe_batch_transfer_from_reverts_when_array_length_invalid( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1479,7 +1488,7 @@ async fn error_invalid_array_length_in_safe_batch_transfer_from( } #[e2e::test] -async fn error_when_missing_approval_safe_batch_transfer_from( +async fn safe_batch_transfer_from_reverts_when_approval_missing( alice: Account, bob: Account, dave: Account, @@ -1518,7 +1527,7 @@ async fn error_when_missing_approval_safe_batch_transfer_from( } #[e2e::test] -async fn error_when_insufficient_balance_safe_batch_transfer_from( +async fn safe_batch_transfer_from_reverts_when_balance_insufficient( alice: Account, bob: Account, dave: Account, @@ -1565,7 +1574,7 @@ async fn error_when_insufficient_balance_safe_batch_transfer_from( // ============================================================================ #[e2e::test] -async fn burns(alice: Account) -> eyre::Result<()> { +async fn burn_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -1602,7 +1611,10 @@ async fn burns(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn burns_with_approval(alice: Account, bob: Account) -> eyre::Result<()> { +async fn burn_success_with_approval( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); let contract_bob = Erc1155::new(contract_addr, &bob.wallet); @@ -1639,7 +1651,7 @@ async fn burns_with_approval(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_missing_approval_burn( +async fn burn_reverts_when_approval_missing( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1666,7 +1678,7 @@ async fn error_when_missing_approval_burn( } #[e2e::test] -async fn error_when_insufficient_balance_burn( +async fn burn_reverts_when_balance_insufficient( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1693,7 +1705,7 @@ async fn error_when_insufficient_balance_burn( } #[e2e::test] -async fn burns_batch(alice: Account) -> eyre::Result<()> { +async fn burn_batch_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -1736,7 +1748,7 @@ async fn burns_batch(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn burns_batch_with_approval( +async fn burn_batch_success_with_approval( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1786,7 +1798,7 @@ async fn burns_batch_with_approval( } #[e2e::test] -async fn error_when_missing_approval_burn_batch( +async fn burn_batch_reverts_when_approval_missing( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1817,7 +1829,7 @@ async fn error_when_missing_approval_burn_batch( } #[e2e::test] -async fn error_when_insufficient_balance_burn_batch( +async fn burn_batch_reverts_when_balance_insufficient( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1857,7 +1869,7 @@ async fn error_when_insufficient_balance_burn_batch( // ============================================================================ #[e2e::test] -async fn supports_interface(alice: Account) -> eyre::Result<()> { +async fn supports_interface_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); let invalid_interface_id: u32 = 0xffffffff; @@ -1892,7 +1904,7 @@ async fn supports_interface(alice: Account) -> eyre::Result<()> { // ============================================================================ #[e2e::test] -async fn pauses(alice: Account) -> eyre::Result<()> { +async fn pause_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -1909,7 +1921,7 @@ async fn pauses(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn pause_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { +async fn pause_reverts_when_already_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -1925,7 +1937,7 @@ async fn pause_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn unpauses(alice: Account) -> eyre::Result<()> { +async fn unpause_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -1944,7 +1956,9 @@ async fn unpauses(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn unpause_reverts_in_unpaused_state(alice: Account) -> eyre::Result<()> { +async fn unpause_reverts_when_already_unpaused( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -1962,7 +1976,7 @@ async fn unpause_reverts_in_unpaused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mint_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { +async fn mint_reverts_when_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -1986,9 +2000,7 @@ async fn mint_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mint_batch_reverts_in_paused_state( - alice: Account, -) -> eyre::Result<()> { +async fn mint_batch_reverts_when_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -2012,7 +2024,7 @@ async fn mint_batch_reverts_in_paused_state( } #[e2e::test] -async fn burn_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { +async fn burn_reverts_when_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -2038,9 +2050,7 @@ async fn burn_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn burn_batch_reverts_in_paused_state( - alice: Account, -) -> eyre::Result<()> { +async fn burn_batch_reverts_when_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc1155::new(contract_addr, &alice.wallet); @@ -2070,7 +2080,7 @@ async fn burn_batch_reverts_in_paused_state( } #[e2e::test] -async fn safe_transfer_from_reverts_in_paused_state( +async fn safe_transfer_from_reverts_when_paused( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -2105,7 +2115,7 @@ async fn safe_transfer_from_reverts_in_paused_state( } #[e2e::test] -async fn safe_batch_transfer_from_reverts_in_paused_state( +async fn safe_batch_transfer_from_reverts_when_paused( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -2141,7 +2151,7 @@ async fn safe_batch_transfer_from_reverts_in_paused_state( } #[e2e::test] -async fn set_approval_for_all_does_not_revert_in_paused_state( +async fn set_approval_for_all_success_when_paused( alice: Account, bob: Account, ) -> eyre::Result<()> { diff --git a/examples/erc20-flash-mint/tests/erc20-flash-mint.rs b/examples/erc20-flash-mint/tests/erc20-flash-mint.rs index 988e045f5..0e34075c4 100644 --- a/examples/erc20-flash-mint/tests/erc20-flash-mint.rs +++ b/examples/erc20-flash-mint/tests/erc20-flash-mint.rs @@ -38,7 +38,7 @@ fn ctr(fee_receiver: Address, fee_amount: U256) -> constructorCall { } #[e2e::test] -async fn constructs(alice: Account) -> Result<()> { +async fn constructor_success(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -57,7 +57,7 @@ async fn constructs(alice: Account) -> Result<()> { } #[e2e::test] -async fn max_flash_loan(alice: Account) -> Result<()> { +async fn max_flash_loan_success(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -77,7 +77,7 @@ async fn max_flash_loan(alice: Account) -> Result<()> { } #[e2e::test] -async fn max_flash_loan_return_zero_if_no_more_tokens_to_mint( +async fn max_flash_loan_success_when_no_tokens_available( alice: Account, ) -> Result<()> { let contract_addr = alice @@ -98,7 +98,7 @@ async fn max_flash_loan_return_zero_if_no_more_tokens_to_mint( } #[e2e::test] -async fn max_flash_loan_returns_zero_on_invalid_address( +async fn max_flash_loan_success_with_invalid_address( alice: Account, ) -> Result<()> { let contract_addr = alice @@ -128,7 +128,7 @@ async fn max_flash_loan_returns_zero_on_invalid_address( // implementations may have different behavior (e.g. return fee as a percentage // of the passed amount). #[e2e::test] -async fn flash_fee_returns_same_value_regardless_of_amount( +async fn flash_fee_success_with_different_amounts( alice: Account, ) -> Result<()> { let contract_addr = alice @@ -149,7 +149,9 @@ async fn flash_fee_returns_same_value_regardless_of_amount( } #[e2e::test] -async fn flash_fee_reverts_on_unsupported_token(alice: Account) -> Result<()> { +async fn flash_fee_reverts_when_token_unsupported( + alice: Account, +) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -184,7 +186,7 @@ async fn flash_fee_reverts_on_unsupported_token(alice: Account) -> Result<()> { } #[e2e::test] -async fn flash_loan_with_fee(alice: Account) -> Result<()> { +async fn flash_loan_success_with_fee(alice: Account) -> Result<()> { let erc20_addr = alice .as_deployer() .with_constructor(ctr(Address::ZERO, FLASH_FEE_VALUE)) @@ -240,7 +242,7 @@ async fn flash_loan_with_fee(alice: Account) -> Result<()> { } #[e2e::test] -async fn flash_loan_with_fee_receiver(alice: Account) -> Result<()> { +async fn flash_loan_success_with_fee_receiver(alice: Account) -> Result<()> { let erc20_addr = alice .as_deployer() .with_constructor(ctr(FEE_RECEIVER, U256::ZERO)) @@ -301,7 +303,9 @@ async fn flash_loan_with_fee_receiver(alice: Account) -> Result<()> { } #[e2e::test] -async fn flash_loan_with_fee_and_fee_receiver(alice: Account) -> Result<()> { +async fn flash_loan_success_with_fee_and_receiver( + alice: Account, +) -> Result<()> { let erc20_addr = alice .as_deployer() .with_default_constructor::() @@ -368,7 +372,7 @@ async fn flash_loan_with_fee_and_fee_receiver(alice: Account) -> Result<()> { } #[e2e::test] -async fn flash_loan_reverts_when_loan_amount_greater_than_max_loan( +async fn flash_loan_reverts_when_amount_exceeds_max( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -401,7 +405,7 @@ async fn flash_loan_reverts_when_loan_amount_greater_than_max_loan( } #[e2e::test] -async fn flash_loan_reverts_with_exceeded_max_with_unsupported_token( +async fn flash_loan_reverts_when_token_unsupported_with_amount( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -432,7 +436,7 @@ async fn flash_loan_reverts_with_exceeded_max_with_unsupported_token( } #[e2e::test] -async fn flash_loan_reverts_with_unsupported_token_with_zero_loan_amount_and_unsupported_token( +async fn flash_loan_reverts_when_token_unsupported_with_zero_amount( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -463,7 +467,7 @@ async fn flash_loan_reverts_with_unsupported_token_with_zero_loan_amount_and_uns } #[e2e::test] -async fn flash_loan_reverts_when_invalid_receiver( +async fn flash_loan_reverts_when_receiver_invalid( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -498,7 +502,7 @@ async fn flash_loan_reverts_when_invalid_receiver( } #[e2e::test] -async fn flash_loan_reverts_when_receiver_callback_reverts( +async fn flash_loan_reverts_when_callback_reverts( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -529,7 +533,7 @@ async fn flash_loan_reverts_when_receiver_callback_reverts( } #[e2e::test] -async fn flash_loan_reverts_when_receiver_returns_invalid_callback_value( +async fn flash_loan_reverts_when_callback_value_invalid( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -560,7 +564,7 @@ async fn flash_loan_reverts_when_receiver_returns_invalid_callback_value( } #[e2e::test] -async fn flash_loan_reverts_when_receiver_doesnt_approve_allowance( +async fn flash_loan_reverts_when_allowance_not_approved( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -621,7 +625,7 @@ async fn flash_loan_reverts_when_allowance_overflows( } #[e2e::test] -async fn flash_loan_reverts_when_receiver_doesnt_have_enough_tokens( +async fn flash_loan_reverts_when_balance_insufficient( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -674,7 +678,7 @@ async fn flash_loan_reverts_when_receiver_doesnt_have_enough_tokens( } #[e2e::test] -async fn flash_loan_reverts_when_receiver_doesnt_have_enough_tokens_and_fee_is_zero( +async fn flash_loan_reverts_when_balance_insufficient_with_zero_fee( alice: Account, ) -> Result<()> { let erc20_addr = alice @@ -711,7 +715,7 @@ async fn flash_loan_reverts_when_receiver_doesnt_have_enough_tokens_and_fee_is_z } #[e2e::test] -async fn flash_loan_reverts_when_receiver_doesnt_have_enough_tokens_and_fee_receiver_is_zero( +async fn flash_loan_reverts_when_balance_insufficient_with_zero_receiver( alice: Account, ) -> Result<()> { let erc20_addr = alice diff --git a/examples/erc20-permit/tests/erc20permit.rs b/examples/erc20-permit/tests/erc20permit.rs index 022bd4162..d23b92387 100644 --- a/examples/erc20-permit/tests/erc20permit.rs +++ b/examples/erc20-permit/tests/erc20permit.rs @@ -75,7 +75,7 @@ fn extract_signature_v(signature: &Signature) -> u8 { // ============================================================================ #[e2e::test] -async fn error_when_expired_deadline_for_permit( +async fn permit_reverts_when_deadline_expired( alice: Account, bob: Account, ) -> Result<()> { @@ -121,7 +121,10 @@ async fn error_when_expired_deadline_for_permit( } #[e2e::test] -async fn permit_works(alice: Account, bob: Account) -> Result<()> { +async fn permit_success_with_transfer( + alice: Account, + bob: Account, +) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract_alice = Erc20Permit::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); @@ -209,7 +212,7 @@ async fn permit_works(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn permit_rejects_reused_signature( +async fn permit_reverts_when_signature_reused( alice: Account, bob: Account, ) -> Result<()> { @@ -284,7 +287,7 @@ async fn permit_rejects_reused_signature( } #[e2e::test] -async fn permit_rejects_invalid_signature( +async fn permit_reverts_when_signature_invalid( alice: Account, bob: Account, ) -> Result<()> { @@ -336,7 +339,7 @@ async fn permit_rejects_invalid_signature( // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> Result<()> { +async fn constructor_success(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc20Permit::new(contract_addr, &alice.wallet); @@ -348,7 +351,7 @@ async fn constructs(alice: Account) -> Result<()> { } #[e2e::test] -async fn mints(alice: Account) -> Result<()> { +async fn mint_success(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc20Permit::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); @@ -380,7 +383,7 @@ async fn mints(alice: Account) -> Result<()> { } #[e2e::test] -async fn mints_rejects_invalid_receiver(alice: Account) -> Result<()> { +async fn mint_reverts_when_receiver_invalid(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc20Permit::new(contract_addr, &alice.wallet); let invalid_receiver = Address::ZERO; @@ -408,7 +411,7 @@ async fn mints_rejects_invalid_receiver(alice: Account) -> Result<()> { } #[e2e::test] -async fn transfers(alice: Account, bob: Account) -> Result<()> { +async fn transfer_success(alice: Account, bob: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract_alice = Erc20Permit::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); @@ -449,7 +452,7 @@ async fn transfers(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn transfer_rejects_insufficient_balance( +async fn transfer_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> Result<()> { @@ -493,7 +496,7 @@ async fn transfer_rejects_insufficient_balance( } #[e2e::test] -async fn transfer_rejects_invalid_receiver(alice: Account) -> Result<()> { +async fn transfer_reverts_when_receiver_invalid(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract_alice = Erc20Permit::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); @@ -532,7 +535,7 @@ async fn transfer_rejects_invalid_receiver(alice: Account) -> Result<()> { } #[e2e::test] -async fn approves(alice: Account, bob: Account) -> Result<()> { +async fn approve_success(alice: Account, bob: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc20Permit::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); @@ -599,7 +602,7 @@ async fn approves(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn approve_rejects_invalid_spender(alice: Account) -> Result<()> { +async fn approve_reverts_when_spender_invalid(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc20Permit::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); @@ -651,7 +654,7 @@ async fn approve_rejects_invalid_spender(alice: Account) -> Result<()> { } #[e2e::test] -async fn transfers_from(alice: Account, bob: Account) -> Result<()> { +async fn transfer_from_success(alice: Account, bob: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract_alice = Erc20Permit::new(contract_addr, &alice.wallet); let contract_bob = Erc20Permit::new(contract_addr, &bob.wallet); @@ -703,7 +706,7 @@ async fn transfers_from(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn transfer_from_reverts_insufficient_balance( +async fn transfer_from_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> Result<()> { @@ -758,7 +761,7 @@ async fn transfer_from_reverts_insufficient_balance( } #[e2e::test] -async fn transfer_from_rejects_insufficient_allowance( +async fn transfer_from_reverts_when_allowance_insufficient( alice: Account, bob: Account, ) -> Result<()> { @@ -813,7 +816,7 @@ async fn transfer_from_rejects_insufficient_allowance( } #[e2e::test] -async fn transfer_from_rejects_invalid_receiver( +async fn transfer_from_reverts_when_receiver_invalid( alice: Account, bob: Account, ) -> Result<()> { diff --git a/examples/erc20/tests/erc20.rs b/examples/erc20/tests/erc20.rs index 9aaca888f..b5aa62c28 100644 --- a/examples/erc20/tests/erc20.rs +++ b/examples/erc20/tests/erc20.rs @@ -40,7 +40,7 @@ fn ctr(cap: U256) -> constructorCall { // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> Result<()> { +async fn constructor_success(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -67,7 +67,7 @@ async fn constructs(alice: Account) -> Result<()> { } #[e2e::test] -async fn mints(alice: Account) -> Result<()> { +async fn mint_success(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -104,7 +104,7 @@ async fn mints(alice: Account) -> Result<()> { } #[e2e::test] -async fn mints_rejects_invalid_receiver(alice: Account) -> Result<()> { +async fn mint_reverts_when_receiver_invalid(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -137,7 +137,7 @@ async fn mints_rejects_invalid_receiver(alice: Account) -> Result<()> { } #[e2e::test] -async fn mints_rejects_overflow(alice: Account) -> Result<()> { +async fn mint_reverts_when_supply_overflows(alice: Account) -> Result<()> { let max_cap = U256::MAX; let contract_addr = alice @@ -177,7 +177,7 @@ async fn mints_rejects_overflow(alice: Account) -> Result<()> { } #[e2e::test] -async fn transfers(alice: Account, bob: Account) -> Result<()> { +async fn transfer_success(alice: Account, bob: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -223,7 +223,7 @@ async fn transfers(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn transfer_rejects_insufficient_balance( +async fn transfer_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> Result<()> { @@ -272,7 +272,7 @@ async fn transfer_rejects_insufficient_balance( } #[e2e::test] -async fn transfer_rejects_invalid_receiver(alice: Account) -> Result<()> { +async fn transfer_reverts_when_receiver_invalid(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -316,7 +316,7 @@ async fn transfer_rejects_invalid_receiver(alice: Account) -> Result<()> { } #[e2e::test] -async fn approves(alice: Account, bob: Account) -> Result<()> { +async fn approve_success(alice: Account, bob: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -388,7 +388,7 @@ async fn approves(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn approve_rejects_invalid_spender(alice: Account) -> Result<()> { +async fn approve_reverts_when_spender_invalid(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -443,7 +443,7 @@ async fn approve_rejects_invalid_spender(alice: Account) -> Result<()> { } #[e2e::test] -async fn transfers_from(alice: Account, bob: Account) -> Result<()> { +async fn transfer_from_success(alice: Account, bob: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -500,7 +500,7 @@ async fn transfers_from(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn transfer_from_reverts_insufficient_balance( +async fn transfer_from_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> Result<()> { @@ -560,7 +560,7 @@ async fn transfer_from_reverts_insufficient_balance( } #[e2e::test] -async fn transfer_from_rejects_insufficient_allowance( +async fn transfer_from_reverts_when_allowance_insufficient( alice: Account, bob: Account, ) -> Result<()> { @@ -620,7 +620,7 @@ async fn transfer_from_rejects_insufficient_allowance( } #[e2e::test] -async fn transfer_from_rejects_invalid_receiver( +async fn transfer_from_reverts_when_receiver_invalid( alice: Account, bob: Account, ) -> Result<()> { @@ -684,7 +684,7 @@ async fn transfer_from_rejects_invalid_receiver( // ============================================================================ #[e2e::test] -async fn burns(alice: Account) -> Result<()> { +async fn burn_success(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -724,7 +724,7 @@ async fn burns(alice: Account) -> Result<()> { } #[e2e::test] -async fn burn_rejects_insufficient_balance(alice: Account) -> Result<()> { +async fn burn_reverts_when_balance_insufficient(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -764,7 +764,7 @@ async fn burn_rejects_insufficient_balance(alice: Account) -> Result<()> { } #[e2e::test] -async fn burns_from(alice: Account, bob: Account) -> Result<()> { +async fn burn_from_success(alice: Account, bob: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -820,7 +820,7 @@ async fn burns_from(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn burn_from_reverts_insufficient_balance( +async fn burn_from_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> Result<()> { @@ -880,7 +880,7 @@ async fn burn_from_reverts_insufficient_balance( } #[e2e::test] -async fn burn_from_rejects_insufficient_allowance( +async fn burn_from_reverts_when_allowance_insufficient( alice: Account, bob: Account, ) -> Result<()> { @@ -944,7 +944,7 @@ async fn burn_from_rejects_insufficient_allowance( // ============================================================================ #[e2e::test] -async fn mint_rejects_exceeding_cap(alice: Account) -> Result<()> { +async fn mint_reverts_when_cap_exceeded(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -985,7 +985,7 @@ async fn mint_rejects_exceeding_cap(alice: Account) -> Result<()> { } #[e2e::test] -async fn mint_rejects_when_cap_reached(alice: Account) -> Result<()> { +async fn mint_reverts_when_cap_reached(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -1025,9 +1025,7 @@ async fn mint_rejects_when_cap_reached(alice: Account) -> Result<()> { } #[e2e::test] -async fn should_not_deploy_capped_with_invalid_cap( - alice: Account, -) -> Result<()> { +async fn constructor_reverts_when_cap_invalid(alice: Account) -> Result<()> { let invalid_cap = U256::ZERO; let err = alice .as_deployer() @@ -1046,7 +1044,7 @@ async fn should_not_deploy_capped_with_invalid_cap( // ============================================================================ #[e2e::test] -async fn pauses(alice: Account) -> eyre::Result<()> { +async fn pause_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -1067,7 +1065,7 @@ async fn pauses(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn pause_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { +async fn pause_reverts_when_already_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -1088,7 +1086,7 @@ async fn pause_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn unpauses(alice: Account) -> eyre::Result<()> { +async fn unpause_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -1111,7 +1109,9 @@ async fn unpauses(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn unpause_reverts_in_unpaused_state(alice: Account) -> eyre::Result<()> { +async fn unpause_reverts_when_already_unpaused( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -1134,7 +1134,7 @@ async fn unpause_reverts_in_unpaused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_burn_in_paused_state(alice: Account) -> Result<()> { +async fn burn_reverts_when_paused(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -1172,7 +1172,7 @@ async fn error_when_burn_in_paused_state(alice: Account) -> Result<()> { } #[e2e::test] -async fn error_when_burn_from_in_paused_state( +async fn burn_from_reverts_when_paused( alice: Account, bob: Account, ) -> Result<()> { @@ -1229,7 +1229,7 @@ async fn error_when_burn_from_in_paused_state( } #[e2e::test] -async fn error_when_mint_in_paused_state(alice: Account) -> Result<()> { +async fn mint_reverts_when_paused(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -1264,7 +1264,7 @@ async fn error_when_mint_in_paused_state(alice: Account) -> Result<()> { } #[e2e::test] -async fn error_when_transfer_in_paused_state( +async fn transfer_reverts_when_paused( alice: Account, bob: Account, ) -> Result<()> { @@ -1310,7 +1310,10 @@ async fn error_when_transfer_in_paused_state( } #[e2e::test] -async fn error_when_transfer_from(alice: Account, bob: Account) -> Result<()> { +async fn transfer_from_reverts_when_paused( + alice: Account, + bob: Account, +) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() @@ -1368,7 +1371,7 @@ async fn error_when_transfer_from(alice: Account, bob: Account) -> Result<()> { // ============================================================================ #[e2e::test] -async fn supports_interface(alice: Account) -> Result<()> { +async fn supports_interface_success(alice: Account) -> Result<()> { let contract_addr = alice .as_deployer() .with_default_constructor::() diff --git a/examples/erc721-consecutive/tests/erc721-consecutive.rs b/examples/erc721-consecutive/tests/erc721-consecutive.rs index 740779a42..9eefa6280 100644 --- a/examples/erc721-consecutive/tests/erc721-consecutive.rs +++ b/examples/erc721-consecutive/tests/erc721-consecutive.rs @@ -31,7 +31,7 @@ fn ctr(receivers: Vec
, amounts: Vec) -> constructorCall { } #[e2e::test] -async fn constructs(alice: Account) -> eyre::Result<()> { +async fn constructor_success(alice: Account) -> eyre::Result<()> { let alice_addr = alice.address(); let receivers = vec![alice_addr]; let amounts = vec![10_u128]; @@ -48,7 +48,7 @@ async fn constructs(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn mints(alice: Account) -> eyre::Result<()> { +async fn mint_success_with_consecutive(alice: Account) -> eyre::Result<()> { let batch_size = 10_u128; let receivers = vec![alice.address()]; let amounts = vec![batch_size]; @@ -81,7 +81,9 @@ async fn mints(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_to_is_zero(alice: Account) -> eyre::Result<()> { +async fn mint_consecutive_reverts_when_receiver_zero( + alice: Account, +) -> eyre::Result<()> { let receivers = vec![Address::ZERO]; let amounts = vec![10_u128]; let err = alice @@ -98,7 +100,9 @@ async fn error_when_to_is_zero(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_exceed_batch_size(alice: Account) -> eyre::Result<()> { +async fn mint_consecutive_reverts_when_batch_size_exceeded( + alice: Account, +) -> eyre::Result<()> { let receivers = vec![alice.address()]; let amounts = vec![MAX_BATCH_SIZE + 1]; let err = alice @@ -116,7 +120,10 @@ async fn error_when_exceed_batch_size(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { +async fn transfer_from_success_with_consecutive( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let receivers = vec![alice.address(), bob.address()]; let amounts = vec![1000_u128, 1000_u128]; // Deploy and mint batches of 1000 tokens to Alice and Bob. @@ -168,7 +175,7 @@ async fn transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn burns(alice: Account) -> eyre::Result<()> { +async fn burn_success_with_consecutive(alice: Account) -> eyre::Result<()> { let receivers = vec![alice.address()]; let amounts = vec![1000_u128]; // Mint batch of 1000 tokens to Alice. diff --git a/examples/erc721-metadata/tests/erc721.rs b/examples/erc721-metadata/tests/erc721.rs index de604757d..da41467a2 100644 --- a/examples/erc721-metadata/tests/erc721.rs +++ b/examples/erc721-metadata/tests/erc721.rs @@ -34,7 +34,7 @@ fn ctr(base_uri: &str) -> constructorCall { // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> eyre::Result<()> { +async fn constructor_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_constructor(ctr( @@ -59,7 +59,7 @@ async fn constructs(alice: Account) -> eyre::Result<()> { // ============================================================================ #[e2e::test] -async fn error_when_checking_token_uri_for_nonexistent_token( +async fn token_uri_reverts_when_token_nonexistent( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice @@ -86,9 +86,7 @@ async fn error_when_checking_token_uri_for_nonexistent_token( } #[e2e::test] -async fn return_empty_token_uri_when_without_base_uri_and_token_uri( - alice: Account, -) -> eyre::Result<()> { +async fn token_uri_success_with_no_uris(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_constructor(ctr("")) @@ -111,7 +109,7 @@ async fn return_empty_token_uri_when_without_base_uri_and_token_uri( } #[e2e::test] -async fn return_token_uri_with_base_uri_and_without_token_uri( +async fn token_uri_success_with_base_uri_only( alice: Account, ) -> eyre::Result<()> { let base_uri = "https://github.com/OpenZeppelin/rust-contracts-stylus/"; @@ -137,7 +135,7 @@ async fn return_token_uri_with_base_uri_and_without_token_uri( } #[e2e::test] -async fn return_token_uri_with_base_uri_and_token_uri( +async fn token_uri_success_with_base_and_token_uri( alice: Account, ) -> eyre::Result<()> { let base_uri = "https://github.com/OpenZeppelin/rust-contracts-stylus/"; @@ -172,7 +170,7 @@ async fn return_token_uri_with_base_uri_and_token_uri( } #[e2e::test] -async fn set_token_uri_before_mint(alice: Account) -> eyre::Result<()> { +async fn set_token_uri_success_before_mint(alice: Account) -> eyre::Result<()> { let base_uri = "https://github.com/OpenZeppelin/rust-contracts-stylus/"; let contract_addr = alice @@ -215,7 +213,7 @@ async fn set_token_uri_before_mint(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn return_token_uri_after_burn_and_remint( +async fn token_uri_success_after_burn_and_remint( alice: Account, ) -> eyre::Result<()> { let base_uri = "https://github.com/OpenZeppelin/rust-contracts-stylus/"; @@ -277,7 +275,7 @@ async fn return_token_uri_after_burn_and_remint( // ============================================================================ #[e2e::test] -async fn supports_interface(alice: Account) -> eyre::Result<()> { +async fn supports_interface_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice .as_deployer() .with_constructor(ctr( diff --git a/examples/erc721/tests/erc721.rs b/examples/erc721/tests/erc721.rs index 97f8983c2..eba98f798 100644 --- a/examples/erc721/tests/erc721.rs +++ b/examples/erc721/tests/erc721.rs @@ -20,7 +20,7 @@ fn random_token_id() -> U256 { // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> eyre::Result<()> { +async fn constructor_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -32,7 +32,7 @@ async fn constructs(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_checking_balance_of_invalid_owner( +async fn balance_of_reverts_when_owner_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -52,7 +52,9 @@ async fn error_when_checking_balance_of_invalid_owner( } #[e2e::test] -async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { +async fn balance_of_success_with_zero_balance( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -64,7 +66,7 @@ async fn balance_of_zero_balance(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_checking_owner_of_nonexistent_token( +async fn owner_of_reverts_when_token_nonexistent( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -85,7 +87,7 @@ async fn error_when_checking_owner_of_nonexistent_token( } #[e2e::test] -async fn mints(alice: Account) -> eyre::Result<()> { +async fn mint_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -111,7 +113,7 @@ async fn mints(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_minting_token_id_twice(alice: Account) -> eyre::Result<()> { +async fn mint_reverts_when_token_id_exists(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -128,7 +130,7 @@ async fn error_when_minting_token_id_twice(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_minting_token_to_invalid_receiver( +async fn mint_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -147,7 +149,10 @@ async fn error_when_minting_token_to_invalid_receiver( } #[e2e::test] -async fn transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { +async fn transfer_from_success( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -189,7 +194,7 @@ async fn transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn transfers_from_approved_token( +async fn transfer_from_success_with_approval( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -237,7 +242,7 @@ async fn transfers_from_approved_token( } #[e2e::test] -async fn transfers_from_approved_for_all( +async fn transfer_from_success_with_approval_for_all( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -285,7 +290,7 @@ async fn transfers_from_approved_for_all( } #[e2e::test] -async fn error_when_transfer_to_invalid_receiver( +async fn transfer_from_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -313,7 +318,7 @@ async fn error_when_transfer_to_invalid_receiver( } #[e2e::test] -async fn error_when_transfer_from_incorrect_owner( +async fn transfer_from_reverts_when_owner_incorrect( alice: Account, bob: Account, dave: Account, @@ -346,7 +351,7 @@ async fn error_when_transfer_from_incorrect_owner( } #[e2e::test] -async fn error_when_transfer_with_insufficient_approval( +async fn transfer_from_reverts_when_approval_insufficient( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -375,7 +380,7 @@ async fn error_when_transfer_with_insufficient_approval( } #[e2e::test] -async fn error_when_transfer_nonexistent_token( +async fn transfer_from_reverts_when_token_nonexistent( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -405,7 +410,10 @@ async fn error_when_transfer_nonexistent_token( } #[e2e::test] -async fn safe_transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { +async fn safe_transfer_from_success( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -447,7 +455,7 @@ async fn safe_transfers_from(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn safe_transfers_to_receiver_contract( +async fn safe_transfer_from_success_with_receiver( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -505,7 +513,7 @@ async fn safe_transfers_to_receiver_contract( } #[e2e::test] -async fn safe_transfers_from_approved_token( +async fn safe_transfer_from_success_with_approval( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -554,7 +562,7 @@ async fn safe_transfers_from_approved_token( } #[e2e::test] -async fn safe_transfers_from_approved_for_all( +async fn safe_transfer_from_success_with_approval_for_all( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -603,7 +611,7 @@ async fn safe_transfers_from_approved_for_all( } #[e2e::test] -async fn error_when_safe_transfer_to_invalid_receiver( +async fn safe_transfer_from_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -633,7 +641,7 @@ async fn error_when_safe_transfer_to_invalid_receiver( } #[e2e::test] -async fn error_when_safe_transfer_from_incorrect_owner( +async fn safe_transfer_from_reverts_when_owner_incorrect( alice: Account, bob: Account, dave: Account, @@ -666,7 +674,7 @@ async fn error_when_safe_transfer_from_incorrect_owner( } #[e2e::test] -async fn error_when_safe_transfer_with_insufficient_approval( +async fn safe_transfer_from_reverts_when_approval_insufficient( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -697,7 +705,7 @@ async fn error_when_safe_transfer_with_insufficient_approval( } #[e2e::test] -async fn error_when_safe_transfer_nonexistent_token( +async fn safe_transfer_from_reverts_when_token_nonexistent( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -728,7 +736,7 @@ async fn error_when_safe_transfer_nonexistent_token( } #[e2e::test] -async fn safe_transfers_from_with_data( +async fn safe_transfer_from_success_with_data( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -777,7 +785,7 @@ async fn safe_transfers_from_with_data( } #[e2e::test] -async fn safe_transfers_with_data_to_receiver_contract( +async fn safe_transfer_from_success_with_data_and_receiver( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -837,7 +845,7 @@ async fn safe_transfers_with_data_to_receiver_contract( } #[e2e::test] -async fn safe_transfers_from_with_data_approved_token( +async fn safe_transfer_from_success_with_data_and_approval( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -889,7 +897,7 @@ async fn safe_transfers_from_with_data_approved_token( } #[e2e::test] -async fn safe_transfers_from_with_data_approved_for_all( +async fn safe_transfer_from_success_with_data_and_approval_for_all( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -941,7 +949,7 @@ async fn safe_transfers_from_with_data_approved_for_all( } #[e2e::test] -async fn error_when_safe_transfer_with_data_to_invalid_receiver( +async fn safe_transfer_from_with_data_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -972,7 +980,7 @@ async fn error_when_safe_transfer_with_data_to_invalid_receiver( } #[e2e::test] -async fn error_when_safe_transfer_with_data_from_incorrect_owner( +async fn safe_transfer_from_with_data_reverts_when_owner_incorrect( alice: Account, bob: Account, dave: Account, @@ -1010,7 +1018,7 @@ async fn error_when_safe_transfer_with_data_from_incorrect_owner( } #[e2e::test] -async fn error_when_safe_transfer_with_data_with_insufficient_approval( +async fn safe_transfer_from_with_data_reverts_when_approval_insufficient( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1045,7 +1053,7 @@ async fn error_when_safe_transfer_with_data_with_insufficient_approval( } #[e2e::test] -async fn error_when_safe_transfer_with_data_nonexistent_token( +async fn safe_transfer_from_with_data_reverts_when_token_nonexistent( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1080,7 +1088,7 @@ async fn error_when_safe_transfer_with_data_nonexistent_token( } #[e2e::test] -async fn errors_when_receiver_reverts_with_reason( +async fn safe_transfer_from_reverts_when_receiver_reverts_with_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1112,7 +1120,7 @@ async fn errors_when_receiver_reverts_with_reason( } #[e2e::test] -async fn errors_when_receiver_reverts_without_reason( +async fn safe_transfer_from_reverts_when_receiver_reverts_without_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1144,7 +1152,9 @@ async fn errors_when_receiver_reverts_without_reason( } #[e2e::test] -async fn errors_when_receiver_panics(alice: Account) -> eyre::Result<()> { +async fn safe_transfer_from_reverts_when_receiver_panics( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1172,7 +1182,7 @@ async fn errors_when_receiver_panics(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn approves(alice: Account, bob: Account) -> eyre::Result<()> { +async fn approve_success(alice: Account, bob: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1202,7 +1212,7 @@ async fn approves(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_approve_for_nonexistent_token( +async fn approve_reverts_when_token_nonexistent( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1223,7 +1233,7 @@ async fn error_when_approve_for_nonexistent_token( } #[e2e::test] -async fn error_when_approve_by_invalid_approver( +async fn approve_reverts_when_approver_invalid( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1252,7 +1262,7 @@ async fn error_when_approve_by_invalid_approver( } #[e2e::test] -async fn error_when_checking_approved_of_nonexistent_token( +async fn get_approved_reverts_when_token_nonexistent( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1273,7 +1283,7 @@ async fn error_when_checking_approved_of_nonexistent_token( } #[e2e::test] -async fn sets_approval_for_all( +async fn set_approval_for_all_success( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1315,7 +1325,7 @@ async fn sets_approval_for_all( } #[e2e::test] -async fn error_when_set_approval_for_all_by_invalid_operator( +async fn set_approval_for_all_reverts_when_operator_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1334,7 +1344,7 @@ async fn error_when_set_approval_for_all_by_invalid_operator( } #[e2e::test] -async fn is_approved_for_all_invalid_operator( +async fn is_approved_for_all_success_with_invalid_operator( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1353,7 +1363,7 @@ async fn is_approved_for_all_invalid_operator( } #[e2e::test] -async fn safe_mint_to_eoa_without_data(alice: Account) -> eyre::Result<()> { +async fn safe_mint_success_without_data(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); @@ -1381,7 +1391,7 @@ async fn safe_mint_to_eoa_without_data(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn safe_mint_to_eoa_with_data(alice: Account) -> eyre::Result<()> { +async fn safe_mint_success_with_data(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); let alice_addr = alice.address(); @@ -1409,7 +1419,7 @@ async fn safe_mint_to_eoa_with_data(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn safe_mint_to_receiver_contract_without_data( +async fn safe_mint_success_with_receiver_without_data( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1450,7 +1460,7 @@ async fn safe_mint_to_receiver_contract_without_data( } #[e2e::test] -async fn safe_mint_to_receiver_contract_with_data( +async fn safe_mint_success_with_receiver_with_data( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1491,7 +1501,7 @@ async fn safe_mint_to_receiver_contract_with_data( } #[e2e::test] -async fn error_when_safe_mint_to_invalid_receiver_contract( +async fn safe_mint_reverts_when_receiver_invalid( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1511,7 +1521,7 @@ async fn error_when_safe_mint_to_invalid_receiver_contract( } #[e2e::test] -async fn error_when_safe_mint_to_invalid_sender_with_data( +async fn safe_mint_reverts_when_sender_invalid( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1533,7 +1543,7 @@ async fn error_when_safe_mint_to_invalid_sender_with_data( } #[e2e::test] -async fn error_when_receiver_reverts_with_reason_on_safe_mint_with_data( +async fn safe_mint_reverts_when_receiver_reverts_with_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1559,7 +1569,7 @@ async fn error_when_receiver_reverts_with_reason_on_safe_mint_with_data( } #[e2e::test] -async fn error_when_receiver_reverts_without_reason_on_safe_mint_with_data( +async fn safe_mint_reverts_when_receiver_reverts_without_reason( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1587,7 +1597,7 @@ async fn error_when_receiver_reverts_without_reason_on_safe_mint_with_data( } #[e2e::test] -async fn error_when_receiver_panics_on_safe_mint_with_data( +async fn safe_mint_reverts_when_receiver_panics( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -1615,7 +1625,7 @@ async fn error_when_receiver_panics_on_safe_mint_with_data( // ============================================================================ #[e2e::test] -async fn pauses(alice: Account) -> eyre::Result<()> { +async fn pause_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1631,7 +1641,7 @@ async fn pauses(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn pause_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { +async fn pause_reverts_when_already_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1647,7 +1657,7 @@ async fn pause_reverts_in_paused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn unpauses(alice: Account) -> eyre::Result<()> { +async fn unpause_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1665,7 +1675,9 @@ async fn unpauses(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn unpause_reverts_in_unpaused_state(alice: Account) -> eyre::Result<()> { +async fn unpause_reverts_when_already_unpaused( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1683,7 +1695,7 @@ async fn unpause_reverts_in_unpaused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_burn_in_paused_state(alice: Account) -> eyre::Result<()> { +async fn burn_reverts_when_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1714,7 +1726,7 @@ async fn error_when_burn_in_paused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_mint_in_paused_state(alice: Account) -> eyre::Result<()> { +async fn mint_reverts_when_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1745,7 +1757,7 @@ async fn error_when_mint_in_paused_state(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_transfer_in_paused_state( +async fn transfer_reverts_when_paused( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1786,7 +1798,7 @@ async fn error_when_transfer_in_paused_state( } #[e2e::test] -async fn error_when_safe_transfer_in_paused_state( +async fn safe_transfer_from_reverts_when_paused( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1828,7 +1840,7 @@ async fn error_when_safe_transfer_in_paused_state( } #[e2e::test] -async fn error_when_safe_transfer_with_data_in_paused_state( +async fn safe_transfer_from_with_data_reverts_when_paused( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -1874,9 +1886,7 @@ async fn error_when_safe_transfer_with_data_in_paused_state( } #[e2e::test] -async fn error_when_safe_mint_in_paused_state( - alice: Account, -) -> eyre::Result<()> { +async fn safe_mint_reverts_when_paused(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1919,7 +1929,7 @@ async fn error_when_safe_mint_in_paused_state( // ============================================================================ #[e2e::test] -async fn burns(alice: Account) -> eyre::Result<()> { +async fn burn_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -1957,7 +1967,7 @@ async fn burns(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn burns_approved_token( +async fn burn_success_with_approval( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -2002,7 +2012,7 @@ async fn burns_approved_token( } #[e2e::test] -async fn burns_approved_for_all( +async fn burn_success_with_approval_for_all( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -2047,7 +2057,7 @@ async fn burns_approved_for_all( } #[e2e::test] -async fn error_when_burn_with_insufficient_approval( +async fn burn_reverts_when_approval_insufficient( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -2080,7 +2090,9 @@ async fn error_when_burn_with_insufficient_approval( } #[e2e::test] -async fn error_when_burn_nonexistent_token(alice: Account) -> eyre::Result<()> { +async fn burn_reverts_when_token_nonexistent( + alice: Account, +) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -2099,7 +2111,7 @@ async fn error_when_burn_nonexistent_token(alice: Account) -> eyre::Result<()> { // ============================================================================ #[e2e::test] -async fn totally_supply_works(alice: Account) -> eyre::Result<()> { +async fn total_supply_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -2120,7 +2132,7 @@ async fn totally_supply_works(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn error_when_checking_token_of_owner_by_index_out_of_bound( +async fn token_of_owner_by_index_reverts_when_index_out_of_bounds( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -2148,7 +2160,7 @@ async fn error_when_checking_token_of_owner_by_index_out_of_bound( } #[e2e::test] -async fn error_when_checking_token_of_owner_by_index_account_has_no_tokens( +async fn token_of_owner_by_index_reverts_when_no_tokens( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -2173,7 +2185,7 @@ async fn error_when_checking_token_of_owner_by_index_account_has_no_tokens( } #[e2e::test] -async fn token_of_owner_by_index_works(alice: Account) -> eyre::Result<()> { +async fn token_of_owner_by_index_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -2197,7 +2209,7 @@ async fn token_of_owner_by_index_works(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn token_of_owner_by_index_after_transfer_to_another_account( +async fn token_of_owner_by_index_success_after_transfer( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -2254,7 +2266,7 @@ async fn token_of_owner_by_index_after_transfer_to_another_account( } #[e2e::test] -async fn error_when_checking_token_by_index_account_has_no_tokens( +async fn token_by_index_reverts_when_no_tokens( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -2277,7 +2289,7 @@ async fn error_when_checking_token_by_index_account_has_no_tokens( } #[e2e::test] -async fn error_when_checking_token_by_index_out_of_bound( +async fn token_by_index_reverts_when_index_out_of_bounds( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -2305,7 +2317,7 @@ async fn error_when_checking_token_by_index_out_of_bound( } #[e2e::test] -async fn token_by_index_works(alice: Account) -> eyre::Result<()> { +async fn token_by_index_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -2329,7 +2341,7 @@ async fn token_by_index_works(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn token_by_index_after_burn(alice: Account) -> eyre::Result<()> { +async fn token_by_index_success_after_burn(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); @@ -2368,7 +2380,7 @@ async fn token_by_index_after_burn(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn token_by_index_after_burn_and_some_mints( +async fn token_by_index_success_after_burn_and_mints( alice: Account, ) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; @@ -2410,7 +2422,7 @@ async fn token_by_index_after_burn_and_some_mints( // ============================================================================ #[e2e::test] -async fn supports_interface(alice: Account) -> eyre::Result<()> { +async fn supports_interface_success(alice: Account) -> eyre::Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = Erc721::new(contract_addr, &alice.wallet); let invalid_interface_id: u32 = 0x_ffffffff; diff --git a/examples/ownable-two-step/tests/ownable_two_step.rs b/examples/ownable-two-step/tests/ownable_two_step.rs index 0e2216231..410979830 100644 --- a/examples/ownable-two-step/tests/ownable_two_step.rs +++ b/examples/ownable-two-step/tests/ownable_two_step.rs @@ -23,7 +23,7 @@ fn ctr(owner: Address) -> constructorCall { // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> Result<()> { +async fn constructor_success(alice: Account) -> Result<()> { let alice_addr = alice.address(); let receipt = alice.as_deployer().with_constructor(ctr(alice_addr)).deploy().await?; @@ -45,9 +45,7 @@ async fn constructs(alice: Account) -> Result<()> { } #[e2e::test] -async fn construct_reverts_when_owner_is_zero_address( - alice: Account, -) -> Result<()> { +async fn constructor_reverts_when_owner_zero(alice: Account) -> Result<()> { let err = alice .as_deployer() .with_constructor(ctr(Address::ZERO)) @@ -63,7 +61,7 @@ async fn construct_reverts_when_owner_is_zero_address( } #[e2e::test] -async fn transfer_ownership_initiates_transfer( +async fn transfer_ownership_success( alice: Account, bob: Account, ) -> Result<()> { @@ -122,7 +120,7 @@ async fn transfer_ownership_reverts_when_not_owner( } #[e2e::test] -async fn accept_ownership(alice: Account, bob: Account) -> Result<()> { +async fn accept_ownership_success(alice: Account, bob: Account) -> Result<()> { let alice_addr = alice.address(); let bob_addr = bob.address(); @@ -154,7 +152,7 @@ async fn accept_ownership(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn transfer_ownership_cancel_transfer( +async fn transfer_ownership_success_with_cancel( alice: Account, bob: Account, ) -> Result<()> { @@ -184,7 +182,7 @@ async fn transfer_ownership_cancel_transfer( } #[e2e::test] -async fn overwrite_previous_transfer_ownership( +async fn transfer_ownership_success_with_overwrite( alice: Account, bob: Account, charlie: Account, @@ -275,7 +273,7 @@ async fn accept_ownership_reverts_when_not_pending_owner( } #[e2e::test] -async fn renounce_ownership(alice: Account) -> Result<()> { +async fn renounce_ownership_success(alice: Account) -> Result<()> { let alice_addr = alice.address(); let contract_addr = alice .as_deployer() diff --git a/examples/ownable/tests/ownable.rs b/examples/ownable/tests/ownable.rs index 2ee644215..b0a42f619 100644 --- a/examples/ownable/tests/ownable.rs +++ b/examples/ownable/tests/ownable.rs @@ -20,7 +20,7 @@ fn ctr(owner: Address) -> constructorCall { // ============================================================================ #[e2e::test] -async fn constructs(alice: Account) -> Result<()> { +async fn constructor_success(alice: Account) -> Result<()> { let alice_addr = alice.address(); let receipt = alice.as_deployer().with_constructor(ctr(alice_addr)).deploy().await?; @@ -37,7 +37,7 @@ async fn constructs(alice: Account) -> Result<()> { } #[e2e::test] -async fn rejects_zero_address_initial_owner(alice: Account) -> Result<()> { +async fn constructor_reverts_when_owner_zero(alice: Account) -> Result<()> { let err = alice .as_deployer() .with_constructor(ctr(Address::ZERO)) @@ -51,7 +51,10 @@ async fn rejects_zero_address_initial_owner(alice: Account) -> Result<()> { } #[e2e::test] -async fn transfers_ownership(alice: Account, bob: Account) -> Result<()> { +async fn transfer_ownership_success( + alice: Account, + bob: Account, +) -> Result<()> { let alice_addr = alice.address(); let bob_addr = bob.address(); @@ -76,7 +79,7 @@ async fn transfers_ownership(alice: Account, bob: Account) -> Result<()> { } #[e2e::test] -async fn prevents_non_owners_from_transferring( +async fn transfer_ownership_reverts_when_not_owner( alice: Account, bob: Account, ) -> Result<()> { @@ -101,7 +104,9 @@ async fn prevents_non_owners_from_transferring( } #[e2e::test] -async fn guards_against_stuck_state(alice: Account) -> Result<()> { +async fn transfer_ownership_reverts_when_zero_address( + alice: Account, +) -> Result<()> { let alice_addr = alice.address(); let contract_addr = alice .as_deployer() @@ -122,7 +127,7 @@ async fn guards_against_stuck_state(alice: Account) -> Result<()> { } #[e2e::test] -async fn loses_ownership_after_renouncement(alice: Account) -> Result<()> { +async fn renounce_ownership_success(alice: Account) -> Result<()> { let alice_addr = alice.address(); let contract_addr = alice .as_deployer() @@ -145,7 +150,7 @@ async fn loses_ownership_after_renouncement(alice: Account) -> Result<()> { } #[e2e::test] -async fn prevents_non_owners_from_renouncement( +async fn renounce_ownership_reverts_when_not_owner( alice: Account, bob: Account, ) -> Result<()> { diff --git a/examples/poseidon/tests/poseidon.rs b/examples/poseidon/tests/poseidon.rs index 763c37b3c..3dd64f1a4 100644 --- a/examples/poseidon/tests/poseidon.rs +++ b/examples/poseidon/tests/poseidon.rs @@ -13,7 +13,7 @@ mod abi; // ============================================================================ #[e2e::test] -async fn poseidon_works(alice: Account) -> Result<()> { +async fn poseidon_hash_success(alice: Account) -> Result<()> { let contract_addr = alice.as_deployer().deploy().await?.address()?; let contract = PoseidonExample::new(contract_addr, &alice.wallet); diff --git a/examples/safe-erc20/tests/address_with_no_code.rs b/examples/safe-erc20/tests/address_with_no_code.rs index 221be9714..faf92ab5f 100644 --- a/examples/safe-erc20/tests/address_with_no_code.rs +++ b/examples/safe-erc20/tests/address_with_no_code.rs @@ -8,7 +8,7 @@ mod abi; mod mock; #[e2e::test] -async fn reverts_on_transfer( +async fn safe_transfer_reverts_when_eoa_token( alice: Account, bob: Account, has_no_code: Account, @@ -31,7 +31,7 @@ async fn reverts_on_transfer( } #[e2e::test] -async fn reverts_on_transfer_from( +async fn safe_transfer_from_reverts_when_eoa_token( alice: Account, bob: Account, has_no_code: Account, @@ -59,7 +59,7 @@ async fn reverts_on_transfer_from( } #[e2e::test] -async fn reverts_on_increase_allowance( +async fn safe_increase_allowance_reverts_when_eoa_token( alice: Account, bob: Account, has_no_code: Account, @@ -85,7 +85,7 @@ async fn reverts_on_increase_allowance( } #[e2e::test] -async fn reverts_on_decrease_allowance( +async fn safe_decrease_allowance_reverts_when_eoa_token( alice: Account, bob: Account, has_no_code: Account, @@ -111,7 +111,7 @@ async fn reverts_on_decrease_allowance( } #[e2e::test] -async fn reverts_on_force_approve( +async fn force_approve_reverts_when_eoa_token( alice: Account, bob: Account, has_no_code: Account, diff --git a/examples/safe-erc20/tests/erc20.rs b/examples/safe-erc20/tests/erc20.rs index ae534333e..df792b8dd 100644 --- a/examples/safe-erc20/tests/erc20.rs +++ b/examples/safe-erc20/tests/erc20.rs @@ -16,7 +16,7 @@ mod transfers { use super::*; #[e2e::test] - async fn does_not_revert_on_transfer( + async fn safe_transfer_success( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -62,7 +62,7 @@ mod transfers { } #[e2e::test] - async fn reverts_on_transfer_with_internal_error( + async fn safe_transfer_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -102,7 +102,7 @@ mod transfers { } #[e2e::test] - async fn does_not_revert_on_transfer_from( + async fn safe_transfer_from_success( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -150,7 +150,7 @@ mod transfers { } #[e2e::test] - async fn reverts_on_transfer_from_internal_error( + async fn safe_transfer_from_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -198,7 +198,7 @@ mod approvals { use super::super::*; #[e2e::test] - async fn does_not_revert_when_force_approving_a_non_zero_allowance( + async fn force_approve_success_with_non_zero_value( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -241,7 +241,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_force_approving_a_zero_allowance( + async fn force_approve_success_with_zero_value( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -282,7 +282,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_increasing_the_allowance( + async fn safe_increase_allowance_success( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -325,7 +325,7 @@ mod approvals { } #[e2e::test] - async fn panics_when_increasing_the_allowance_overflow( + async fn safe_increase_allowance_reverts_when_allowance_overflows( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -358,7 +358,7 @@ mod approvals { } #[e2e::test] - async fn reverts_when_decreasing_the_allowance( + async fn safe_decrease_allowance_reverts_when_insufficient_allowance( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -400,7 +400,7 @@ mod approvals { use super::super::*; #[e2e::test] - async fn does_not_revert_when_force_approving_a_non_zero_allowance( + async fn force_approve_success_with_existing_allowance( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -445,7 +445,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_force_approving_a_zero_allowance( + async fn force_approve_success_with_existing_allowance_to_zero( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -488,7 +488,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_increasing_the_allowance( + async fn safe_increase_allowance_success_with_existing_allowance( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -533,7 +533,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_decreasing_the_allowance_to_a_positive_value( + async fn safe_decrease_allowance_success_to_positive( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -578,7 +578,7 @@ mod approvals { } #[e2e::test] - async fn reverts_when_decreasing_the_allowance_to_a_negative_value( + async fn safe_decrease_allowance_reverts_when_negative( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = diff --git a/examples/safe-erc20/tests/erc20_that_always_returns_false.rs b/examples/safe-erc20/tests/erc20_that_always_returns_false.rs index a3fa78519..b72c91d86 100644 --- a/examples/safe-erc20/tests/erc20_that_always_returns_false.rs +++ b/examples/safe-erc20/tests/erc20_that_always_returns_false.rs @@ -9,7 +9,10 @@ mod abi; mod mock; #[e2e::test] -async fn reverts_on_transfer(alice: Account, bob: Account) -> eyre::Result<()> { +async fn safe_transfer_reverts_when_operation_fails( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let safe_erc20_addr = alice.as_deployer().deploy().await?.address()?; let safe_erc20_alice = SafeErc20::new(safe_erc20_addr, &alice.wallet); let bob_addr = bob.address(); @@ -30,7 +33,7 @@ async fn reverts_on_transfer(alice: Account, bob: Account) -> eyre::Result<()> { } #[e2e::test] -async fn reverts_on_transfer_from( +async fn safe_transfer_from_reverts_when_operation_fails( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -56,7 +59,7 @@ async fn reverts_on_transfer_from( } #[e2e::test] -async fn reverts_on_increase_allowance( +async fn safe_increase_allowance_reverts_when_operation_fails( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -80,7 +83,7 @@ async fn reverts_on_increase_allowance( } #[e2e::test] -async fn reverts_on_decrease_allowance( +async fn safe_decrease_allowance_reverts_when_operation_fails( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -104,7 +107,7 @@ async fn reverts_on_decrease_allowance( } #[e2e::test] -async fn reverts_on_force_approve( +async fn force_approve_reverts_when_operation_fails( alice: Account, bob: Account, ) -> eyre::Result<()> { diff --git a/examples/safe-erc20/tests/erc20_that_does_not_return.rs b/examples/safe-erc20/tests/erc20_that_does_not_return.rs index 9fbffe3f9..79e088d1a 100644 --- a/examples/safe-erc20/tests/erc20_that_does_not_return.rs +++ b/examples/safe-erc20/tests/erc20_that_does_not_return.rs @@ -16,7 +16,7 @@ mod transfers { use super::*; #[e2e::test] - async fn does_not_revert_on_transfer( + async fn safe_transfer_success_with_no_return( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -62,7 +62,7 @@ mod transfers { } #[e2e::test] - async fn reverts_on_transfer_with_internal_error( + async fn safe_transfer_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -101,7 +101,7 @@ mod transfers { } #[e2e::test] - async fn does_not_revert_on_transfer_from( + async fn safe_transfer_from_success_with_no_return( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -149,7 +149,7 @@ mod transfers { } #[e2e::test] - async fn reverts_on_transfer_from_internal_error( + async fn safe_transfer_from_reverts_when_balance_insufficient( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -196,7 +196,7 @@ mod approvals { use super::super::*; #[e2e::test] - async fn does_not_revert_when_force_approving_a_non_zero_allowance( + async fn force_approve_success_with_non_zero_value( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -240,7 +240,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_force_approving_a_zero_allowance( + async fn force_approve_success_with_zero_value( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -282,7 +282,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_increasing_the_allowance( + async fn safe_increase_allowance_success( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -326,7 +326,7 @@ mod approvals { } #[e2e::test] - async fn panics_when_increasing_the_allowance_overflow( + async fn safe_increase_allowance_reverts_when_allowance_overflows( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -360,7 +360,7 @@ mod approvals { } #[e2e::test] - async fn reverts_when_decreasing_the_allowance( + async fn safe_decrease_allowance_reverts_when_insufficient_allowance( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -403,7 +403,7 @@ mod approvals { use super::super::*; #[e2e::test] - async fn does_not_revert_when_force_approving_a_non_zero_allowance( + async fn force_approve_success_with_existing_allowance( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -449,7 +449,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_force_approving_a_zero_allowance( + async fn force_approve_success_with_existing_allowance_to_zero( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -493,7 +493,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_increasing_the_allowance( + async fn safe_increase_allowance_success_with_existing_allowance( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -539,7 +539,7 @@ mod approvals { } #[e2e::test] - async fn does_not_revert_when_decreasing_the_allowance_to_a_positive_value( + async fn safe_decrease_allowance_success_to_positive( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = @@ -585,7 +585,7 @@ mod approvals { } #[e2e::test] - async fn reverts_when_decreasing_the_allowance_to_a_negative_value( + async fn safe_decrease_allowance_reverts_when_negative( alice: Account, ) -> eyre::Result<()> { let safe_erc20_addr = diff --git a/examples/safe-erc20/tests/usdt_approval_behavior.rs b/examples/safe-erc20/tests/usdt_approval_behavior.rs index 9530a3ca0..07e08c4ae 100644 --- a/examples/safe-erc20/tests/usdt_approval_behavior.rs +++ b/examples/safe-erc20/tests/usdt_approval_behavior.rs @@ -9,7 +9,7 @@ mod abi; mod mock; #[e2e::test] -async fn safe_increase_allowance_works( +async fn safe_increase_allowance_success_with_force_approve( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -53,7 +53,7 @@ async fn safe_increase_allowance_works( } #[e2e::test] -async fn safe_decrease_allowance_works( +async fn safe_decrease_allowance_success_with_force_approve( alice: Account, bob: Account, ) -> eyre::Result<()> { @@ -97,7 +97,10 @@ async fn safe_decrease_allowance_works( } #[e2e::test] -async fn force_approve_works(alice: Account, bob: Account) -> eyre::Result<()> { +async fn force_approve_success( + alice: Account, + bob: Account, +) -> eyre::Result<()> { let safe_erc20_addr = alice.as_deployer().deploy().await?.address()?; let safe_erc20_alice = SafeErc20::new(safe_erc20_addr, &alice.wallet); let bob_addr = bob.address(); diff --git a/examples/vesting-wallet/tests/vesting-wallet.rs b/examples/vesting-wallet/tests/vesting-wallet.rs index d292b8b7f..e7a33cad6 100644 --- a/examples/vesting-wallet/tests/vesting-wallet.rs +++ b/examples/vesting-wallet/tests/vesting-wallet.rs @@ -62,7 +62,7 @@ fn assert_in_delta(expected: U256, actual: U256) { } #[e2e::test] -async fn constructs(alice: Account) -> eyre::Result<()> { +async fn constructor_success(alice: Account) -> eyre::Result<()> { let start_timestamp = block_timestamp(&alice).await?; let contract_addr = alice .as_deployer() @@ -86,7 +86,7 @@ async fn constructs(alice: Account) -> eyre::Result<()> { } #[e2e::test] -async fn rejects_zero_address_for_beneficiary( +async fn constructor_reverts_when_beneficiary_zero( alice: Account, ) -> eyre::Result<()> { let start = block_timestamp(&alice).await?; @@ -172,34 +172,42 @@ mod ether_vesting { } #[e2e::test] - async fn check_release_0_percent(alice: Account) -> eyre::Result<()> { + async fn release_eth_success_at_zero_percent( + alice: Account, + ) -> eyre::Result<()> { run_check_release(alice, 0).await } #[e2e::test] - async fn check_release_25_percent(alice: Account) -> eyre::Result<()> { + async fn release_eth_success_at_25_percent( + alice: Account, + ) -> eyre::Result<()> { run_check_release(alice, DURATION / 4).await } #[e2e::test] - async fn check_release_50_percent(alice: Account) -> eyre::Result<()> { + async fn release_eth_success_at_50_percent( + alice: Account, + ) -> eyre::Result<()> { run_check_release(alice, DURATION / 2).await } #[e2e::test] - async fn check_release_100_percent(alice: Account) -> eyre::Result<()> { + async fn release_eth_success_at_100_percent( + alice: Account, + ) -> eyre::Result<()> { run_check_release(alice, DURATION).await } #[e2e::test] - async fn check_release_100_percent_vesting_in_the_past( + async fn release_eth_success_with_past_vesting( alice: Account, ) -> eyre::Result<()> { run_check_release(alice, DURATION * 4 / 3).await } #[e2e::test] - async fn check_vested_amount(alice: Account) -> eyre::Result<()> { + async fn vested_amount_eth_success(alice: Account) -> eyre::Result<()> { let start = block_timestamp(&alice).await?; let contract_addr = deploy(&alice, start, DURATION, BALANCE).await?; @@ -320,34 +328,42 @@ mod erc20_vesting { } #[e2e::test] - async fn check_release_0_percent(alice: Account) -> eyre::Result<()> { + async fn release_erc20_success_at_zero_percent( + alice: Account, + ) -> eyre::Result<()> { run_check_release(alice, 0).await } #[e2e::test] - async fn check_release_25_percent(alice: Account) -> eyre::Result<()> { + async fn release_erc20_success_at_25_percent( + alice: Account, + ) -> eyre::Result<()> { run_check_release(alice, DURATION / 4).await } #[e2e::test] - async fn check_release_50_percent(alice: Account) -> eyre::Result<()> { + async fn release_erc20_success_at_50_percent( + alice: Account, + ) -> eyre::Result<()> { run_check_release(alice, DURATION / 2).await } #[e2e::test] - async fn check_release_100_percent(alice: Account) -> eyre::Result<()> { + async fn release_erc20_success_at_100_percent( + alice: Account, + ) -> eyre::Result<()> { run_check_release(alice, DURATION).await } #[e2e::test] - async fn check_release_100_percent_vesting_in_the_past( + async fn release_erc20_success_with_past_vesting( alice: Account, ) -> eyre::Result<()> { run_check_release(alice, DURATION * 4 / 3).await } #[e2e::test] - async fn check_vested_amount(alice: Account) -> eyre::Result<()> { + async fn vested_amount_erc20_success(alice: Account) -> eyre::Result<()> { let start = block_timestamp(&alice).await?; let contract_addr = deploy(&alice, start, DURATION).await?; let erc20_address = @@ -377,7 +393,7 @@ mod erc20_vesting { } #[e2e::test] - async fn releasable_erc20_reverts_on_invalid_token( + async fn releasable_erc20_reverts_when_token_invalid( alice: Account, ) -> eyre::Result<()> { let start = block_timestamp(&alice).await?; @@ -396,7 +412,7 @@ mod erc20_vesting { } #[e2e::test] - async fn release_erc20_reverts_on_invalid_token( + async fn release_erc20_reverts_when_token_invalid( alice: Account, ) -> eyre::Result<()> { let start = block_timestamp(&alice).await?; @@ -415,7 +431,7 @@ mod erc20_vesting { } #[e2e::test] - async fn release_erc20_reverts_on_failed_transfer( + async fn release_erc20_reverts_when_transfer_fails( alice: Account, ) -> eyre::Result<()> { let start = block_timestamp(&alice).await?; @@ -436,7 +452,7 @@ mod erc20_vesting { } #[e2e::test] - async fn vested_amount_erc20_reverts_on_invalid_token( + async fn vested_amount_erc20_reverts_when_token_invalid( alice: Account, ) -> eyre::Result<()> { let start = block_timestamp(&alice).await?; @@ -455,7 +471,7 @@ mod erc20_vesting { } #[e2e::test] - async fn vested_amount_reverts_on_scaled_allocation_overflow( + async fn vested_amount_reverts_when_allocation_overflows( alice: Account, ) -> eyre::Result<()> { let start = block_timestamp(&alice).await?; diff --git a/lib/crypto/src/bigint.rs b/lib/crypto/src/bigint.rs index 5701739b9..34ee27f06 100644 --- a/lib/crypto/src/bigint.rs +++ b/lib/crypto/src/bigint.rs @@ -319,7 +319,7 @@ mod test { use super::*; #[test] - fn convert_from_str_radix() { + fn convert_from_str_radix_success() { let uint_from_base10: Uint<4> = from_str_radix( "28948022309329048855892746252171976963363056481941647379679742748393362948097", 10 @@ -343,7 +343,7 @@ mod test { } #[test] - fn convert_from_str_hex() { + fn convert_from_str_hex_success() { // Test different implementations of hex parsing on random hex inputs. proptest!(|(s in "[0-9a-fA-F]{1,64}")| { let uint_from_hex: Uint<4> = from_str_hex(&s); @@ -353,7 +353,7 @@ mod test { } #[test] - fn uint_bit_iterator_be() { + fn uint_bit_iterator_be_success() { let words: [Word; 4] = [0b1100, 0, 0, 0]; let num = Uint::<4>::from_words(words); let bits: Vec = num.bit_be_trimmed_iter().collect(); diff --git a/lib/crypto/src/bits.rs b/lib/crypto/src/bits.rs index 307b36572..6e56c6f14 100644 --- a/lib/crypto/src/bits.rs +++ b/lib/crypto/src/bits.rs @@ -35,7 +35,7 @@ mod tests { use super::*; #[test] - fn u64_bit_iterator_be() { + fn bit_iterator_be_success_with_u64() { let num: u64 = 0b1100; let bits: Vec = num.bit_be_trimmed_iter().collect(); diff --git a/lib/crypto/src/field/fp.rs b/lib/crypto/src/field/fp.rs index d5ee9052f..4efb2bb7c 100644 --- a/lib/crypto/src/field/fp.rs +++ b/lib/crypto/src/field/fp.rs @@ -888,7 +888,7 @@ mod tests { proptest! { #[test] - fn add(a: i64, b: i64) { + fn add_success(a: i64, b: i64) { let res = Field64::from(a) + Field64::from(b); let res: i128 = res.into(); let a = i128::from(a); @@ -897,7 +897,7 @@ mod tests { } #[test] - fn double(a: i64) { + fn double_success(a: i64) { let res = Field64::from(a).double(); let res: i128 = res.into(); let a = i128::from(a); @@ -905,7 +905,7 @@ mod tests { } #[test] - fn sub(a: i64, b: i64) { + fn sub_success(a: i64, b: i64) { let res = Field64::from(a) - Field64::from(b); let res: i128 = res.into(); let a = i128::from(a); @@ -914,7 +914,7 @@ mod tests { } #[test] - fn mul(a: i64, b: i64) { + fn mul_success(a: i64, b: i64) { let res = Field64::from(a) * Field64::from(b); let res: i128 = res.into(); let a = i128::from(a); @@ -923,7 +923,7 @@ mod tests { } #[test] - fn square(a: i64) { + fn square_success(a: i64) { let res = Field64::from(a).square(); let res: i128 = res.into(); let a = i128::from(a); @@ -931,7 +931,7 @@ mod tests { } #[test] - fn div(a: i64, b: i64) { + fn div_success_when_denominator_nonzero(a: i64, b: i64) { // Skip if `b` is zero. if i128::from(b) % MODULUS == 0 { return Ok(()); @@ -946,7 +946,7 @@ mod tests { } #[test] - fn pow(a: i64, b in 0_u32..1000) { + fn pow_success(a: i64, b in 0_u32..1000) { /// Compute a^b in an expensive and iterative way. fn dumb_pow(a: i128, b: i128) -> i128 { (0..b).fold(1, |acc, _| (acc * a).rem_euclid(MODULUS)) @@ -960,7 +960,7 @@ mod tests { } #[test] - fn neg(a: i64) { + fn neg_success(a: i64) { let res = -Field64::from(a); let res: i128 = res.into(); let a = i128::from(a); @@ -968,7 +968,7 @@ mod tests { } #[test] - fn one(a: i64) { + fn one_success(a: i64) { let res = Field64::one(); let res: i128 = res.into(); prop_assert_eq!(res, 1); @@ -980,7 +980,7 @@ mod tests { } #[test] - fn zero(a: i64) { + fn zero_success(a: i64) { let res = Field64::zero(); let res: i128 = res.into(); prop_assert_eq!(res, 0); diff --git a/lib/crypto/src/hash.rs b/lib/crypto/src/hash.rs index eb60ebecd..608433a34 100644 --- a/lib/crypto/src/hash.rs +++ b/lib/crypto/src/hash.rs @@ -165,7 +165,7 @@ mod tests { } #[test] - fn hashes_pairs() { + fn hash_pair_success() { let builder = KeccakBuilder; let a = [1u8].as_slice(); let b = [2u8].as_slice(); @@ -179,7 +179,7 @@ mod tests { } #[test] - fn commutatively_hashes_pairs() { + fn commutative_hash_pair_success() { let builder = KeccakBuilder; let a = [1u8].as_slice(); let b = [2u8].as_slice(); diff --git a/lib/crypto/src/merkle.rs b/lib/crypto/src/merkle.rs index 973073fde..d54dbf236 100644 --- a/lib/crypto/src/merkle.rs +++ b/lib/crypto/src/merkle.rs @@ -383,7 +383,7 @@ mod tests { } #[test] - fn verifies_valid_proofs() { + fn verify_success_with_valid_proof() { // ```js // const merkleTree = StandardMerkleTree.of( // toElements('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='), @@ -419,7 +419,7 @@ mod tests { } #[test] - fn rejects_invalid_proofs() { + fn verify_reverts_when_proof_invalid() { // ```js // const correctMerkleTree = StandardMerkleTree.of(toElements('abc'), ['string']); // const otherMerkleTree = StandardMerkleTree.of(toElements('def'), ['string']); @@ -439,7 +439,7 @@ mod tests { } #[test] - fn rejects_proofs_with_invalid_length() { + fn verify_reverts_when_proof_length_invalid() { // ```js // const merkleTree = StandardMerkleTree.of(toElements('abc'), ['string']); // @@ -462,7 +462,7 @@ mod tests { } #[test] - fn verifies_valid_multi_proof() { + fn verify_multi_proof_success_with_valid_proof() { // ```js // const merkleTree = StandardMerkleTree.of(toElements('abcdef'), ['string']); // @@ -490,7 +490,7 @@ mod tests { } #[test] - fn rejects_invalid_multi_proof() { + fn verify_multi_proof_reverts_when_proof_invalid() { // ```js // const merkleTree = StandardMerkleTree.of(toElements('abcdef'), ['string']); // const otherMerkleTree = StandardMerkleTree.of(toElements('ghi'), ['string']); @@ -516,7 +516,7 @@ mod tests { } #[test] - fn errors_invalid_multi_proof_leaves() { + fn verify_multi_proof_reverts_when_leaves_invalid() { // ```js // const merkleTree = StandardMerkleTree.of(toElements('abcd'), ['string']); // @@ -552,7 +552,7 @@ mod tests { } #[test] - fn errors_multi_proof_len_invalid() { + fn verify_multi_proof_reverts_when_length_invalid() { // ```js // const merkleTree = StandardMerkleTree.of(toElements('abcd'), ['string']); // @@ -588,7 +588,7 @@ mod tests { } #[test] - fn verifies_single_leaf_multi_proof() { + fn verify_multi_proof_success_with_single_leaf() { // ```js // const merkleTree = StandardMerkleTree.of(toElements('a'), ['string']); // @@ -611,7 +611,7 @@ mod tests { } #[test] - fn verifies_empty_leaves_multi_proof() { + fn verify_multi_proof_success_with_empty_leaves() { // ```js // const merkleTree = StandardMerkleTree.of(toElements('abcd'), ['string']); // @@ -630,7 +630,7 @@ mod tests { #[test] /// Errors when processing manipulated proofs with a zero-value node at /// depth 1. - fn errors_manipulated_multi_proof() { + fn verify_multi_proof_reverts_when_proof_manipulated() { // ```js // // Create a merkle tree that contains a zero leaf at depth 1 // const leave = ethers.id('real leaf'); diff --git a/lib/crypto/src/poseidon2/instance/babybear.rs b/lib/crypto/src/poseidon2/instance/babybear.rs index 8418bf334..2c504a12d 100644 --- a/lib/crypto/src/poseidon2/instance/babybear.rs +++ b/lib/crypto/src/poseidon2/instance/babybear.rs @@ -811,7 +811,7 @@ mod tests { type Scalar = FpBabyBear; #[test] - fn smoke() { + fn poseidon2_hash_success() { let mut poseidon2 = Poseidon2::::new(); for i in 1..BabyBear24Params::T { poseidon2.absorb(&Scalar::from(i as u64)); diff --git a/lib/crypto/src/poseidon2/instance/bls12.rs b/lib/crypto/src/poseidon2/instance/bls12.rs index dd6c11de5..ddb41bc0e 100644 --- a/lib/crypto/src/poseidon2/instance/bls12.rs +++ b/lib/crypto/src/poseidon2/instance/bls12.rs @@ -1039,7 +1039,7 @@ mod tests { type Scalar = FpBLS12; #[test] - fn smoke() { + fn poseidon2_hash_success() { let mut poseidon2 = Poseidon2::::new(); for i in 1..BLS2Params::T { poseidon2.absorb(&Scalar::from(i as u64)); diff --git a/lib/crypto/src/poseidon2/instance/bn256.rs b/lib/crypto/src/poseidon2/instance/bn256.rs index ca12b20b0..5dda5241f 100644 --- a/lib/crypto/src/poseidon2/instance/bn256.rs +++ b/lib/crypto/src/poseidon2/instance/bn256.rs @@ -362,7 +362,7 @@ mod tests { type Scalar = FpBN256; #[test] - fn smoke() { + fn poseidon2_hash_success() { let mut poseidon2 = Poseidon2::::new(); for i in 1..BN256Params::T { poseidon2.absorb(&Scalar::from(i as u64)); diff --git a/lib/crypto/src/poseidon2/instance/goldilocks.rs b/lib/crypto/src/poseidon2/instance/goldilocks.rs index ce450363e..d5f850d13 100644 --- a/lib/crypto/src/poseidon2/instance/goldilocks.rs +++ b/lib/crypto/src/poseidon2/instance/goldilocks.rs @@ -467,7 +467,7 @@ mod tests { type Scalar = FpGoldiLocks; #[test] - fn smoke() { + fn poseidon2_hash_success() { let mut poseidon2 = Poseidon2::::new(); for i in 1..Goldilocks12Params::T { poseidon2.absorb(&Scalar::from(i as u64)); diff --git a/lib/crypto/src/poseidon2/instance/pallas.rs b/lib/crypto/src/poseidon2/instance/pallas.rs index 7b3dd451c..57e2a8e83 100644 --- a/lib/crypto/src/poseidon2/instance/pallas.rs +++ b/lib/crypto/src/poseidon2/instance/pallas.rs @@ -361,7 +361,7 @@ mod tests { type Scalar = FpPallas; #[test] - fn smoke() { + fn poseidon2_hash_success() { let mut poseidon2 = Poseidon2::::new(); for i in 1..PallasParams::T { poseidon2.absorb(&Scalar::from(i as u64)); diff --git a/lib/crypto/src/poseidon2/instance/vesta.rs b/lib/crypto/src/poseidon2/instance/vesta.rs index aac8c65ec..ba174e84b 100644 --- a/lib/crypto/src/poseidon2/instance/vesta.rs +++ b/lib/crypto/src/poseidon2/instance/vesta.rs @@ -363,7 +363,7 @@ mod tests { type Scalar = FpVesta; #[test] - fn smoke() { + fn poseidon2_hash_success() { let mut poseidon2 = Poseidon2::::new(); for i in 1..VestaParams::T { poseidon2.absorb(&Scalar::from(i as u64));