Skip to content

Commit

Permalink
Improve mocks (#1146)
Browse files Browse the repository at this point in the history
* feat: add features

* feat: remove access dual dispatchers (#1154)

* feat: bump scarb

* feat: update CHANGELOG

* feat: add features

* feat: remove account dual dispatchers (#1168)

* feat: move mocks to test_common

* Remove token dual dispatchers (#1175)

* feat: remove modules

* fix: mock

* fix: linter

* fix: tests

* fix: mock

* feat: apply review suggestions

* feat: update docs

* feat: update CHANGELOG

* fix: typo

* fix: mod

* feat: remove unused imports

* fix: README

* feat: move mocks into test_common

* feat: remove mocks from release target

* fix: mock

* fix: imports

* feat: bumo scarb and remove assert_macros from manifest

* feat: re-add assert_macros

* feat: add test target names

* docs: update index
  • Loading branch information
ericnordelo authored Oct 8, 2024
1 parent 5728ae8 commit 1cbef43
Show file tree
Hide file tree
Showing 109 changed files with 1,081 additions and 1,343 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Bump scarb to v2.8.3 (#1166)
- Bump scarb to v2.8.4 (#1146)

### Changed (Breaking)

- Bump snforge to 0.31.0
- Remove openzeppelin_utils::selectors (#1163)
- Remove `DualCase dispatchers` (#1163)
- Remove `try_selector_with_fallback` from `openzeppelin_utils`
Expand Down
14 changes: 10 additions & 4 deletions Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ version = "0.17.0"
dependencies = [
"openzeppelin_access",
"openzeppelin_introspection",
"openzeppelin_test_common",
"openzeppelin_testing",
"openzeppelin_utils",
"snforge_std",
Expand All @@ -69,6 +70,7 @@ dependencies = [
name = "openzeppelin_introspection"
version = "0.17.0"
dependencies = [
"openzeppelin_test_common",
"snforge_std",
]

Expand Down Expand Up @@ -99,6 +101,7 @@ dependencies = [
name = "openzeppelin_security"
version = "0.17.0"
dependencies = [
"openzeppelin_test_common",
"openzeppelin_testing",
"snforge_std",
]
Expand All @@ -110,6 +113,8 @@ dependencies = [
"openzeppelin_access",
"openzeppelin_account",
"openzeppelin_finance",
"openzeppelin_introspection",
"openzeppelin_security",
"openzeppelin_testing",
"openzeppelin_token",
"openzeppelin_upgrades",
Expand Down Expand Up @@ -150,21 +155,22 @@ dependencies = [
name = "openzeppelin_utils"
version = "0.17.0"
dependencies = [
"openzeppelin_test_common",
"openzeppelin_testing",
"snforge_std",
]

[[package]]
name = "snforge_scarb_plugin"
version = "0.2.0"
version = "0.31.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:2e4ce3ebe3f49548bd26908391b5d78537a765d827df0d96c32aeb88941d0d67"
checksum = "sha256:1fce075fcbf7fce1b0935f6f9a034549704837fb221da212d3b6e9134cebfdaa"

[[package]]
name = "snforge_std"
version = "0.30.0"
version = "0.31.0"
source = "registry+https://scarbs.xyz/"
checksum = "sha256:2f3c4846881813ac0f5d1460981249c9f5e2a6831e752beedf9b70975495b4ec"
checksum = "sha256:60ac980b297281f9a59a5f1668cb56bdea1b28fd2f8008008270f9a3c91ad3ba"
dependencies = [
"snforge_scarb_plugin",
]
11 changes: 5 additions & 6 deletions Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ keywords.workspace = true
[workspace.package]
version = "0.17.0"
edition = "2024_07"
cairo-version = "2.8.2"
scarb-version = "2.8.3"
cairo-version = "2.8.4"
scarb-version = "2.8.4"
authors = ["OpenZeppelin Community <maintainers@openzeppelin.org>"]
description = "OpenZeppelin Contracts written in Cairo for Starknet, a decentralized ZK Rollup"
documentation = "https://docs.openzeppelin.com/contracts-cairo"
Expand All @@ -40,9 +40,9 @@ keywords = [
]

[workspace.dependencies]
assert_macros = "2.8.2"
starknet = "2.8.2"
snforge_std = "0.30.0"
assert_macros = "2.8.4"
starknet = "2.8.4"
snforge_std = "0.31.0"

[dependencies]
starknet.workspace = true
Expand All @@ -59,7 +59,6 @@ openzeppelin_upgrades = { path = "packages/upgrades" }
openzeppelin_utils = { path = "packages/utils" }

[dev-dependencies]
assert_macros.workspace = true
snforge_std.workspace = true
openzeppelin_test_common = { path = "packages/test_common" }
openzeppelin_testing = { path = "packages/testing" }
Expand Down
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ before proceeding, and run the following command to check that the installation
----
$ scarb --version
scarb 2.8.3 (54938ce3b 2024-09-26)
cairo: 2.8.2 (https://crates.io/crates/cairo-lang-compiler/2.8.2)
scarb 2.8.4 (2aa4e193e 2024-10-07)
cairo: 2.8.4 (https://crates.io/crates/cairo-lang-compiler/2.8.4)
sierra: 1.6.0
----

Expand Down
3 changes: 2 additions & 1 deletion packages/access/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod accesscontrol;
pub mod ownable;

pub mod tests;
#[cfg(test)]
mod tests;
5 changes: 0 additions & 5 deletions packages/access/src/tests.cairo
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
pub(crate) mod mocks;

#[cfg(test)]
mod test_accesscontrol;
#[cfg(test)]
mod test_ownable;
#[cfg(test)]
mod test_ownable_twostep;
2 changes: 0 additions & 2 deletions packages/access/src/tests/mocks.cairo

This file was deleted.

39 changes: 0 additions & 39 deletions packages/access/src/tests/mocks/accesscontrol_mocks.cairo

This file was deleted.

60 changes: 0 additions & 60 deletions packages/access/src/tests/mocks/ownable_mocks.cairo

This file was deleted.

2 changes: 1 addition & 1 deletion packages/access/src/tests/test_accesscontrol.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::accesscontrol::AccessControlComponent::{
};
use crate::accesscontrol::interface::{IAccessControl, IAccessControlCamel, IACCESSCONTROL_ID};
use crate::accesscontrol::{AccessControlComponent, DEFAULT_ADMIN_ROLE};
use crate::tests::mocks::accesscontrol_mocks::DualCaseAccessControlMock;
use openzeppelin_introspection::interface::ISRC5;
use openzeppelin_test_common::mocks::access::DualCaseAccessControlMock;
use openzeppelin_testing::constants::{
ADMIN, AUTHORIZED, OTHER, OTHER_ADMIN, ROLE, OTHER_ROLE, ZERO
};
Expand Down
3 changes: 1 addition & 2 deletions packages/access/src/tests/test_ownable.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use core::num::traits::Zero;
use crate::ownable::OwnableComponent::InternalTrait;
use crate::ownable::OwnableComponent;
use crate::ownable::interface::{IOwnable, IOwnableCamelOnly};
use crate::tests::mocks::ownable_mocks::DualCaseOwnableMock;

use openzeppelin_test_common::mocks::access::DualCaseOwnableMock;
use openzeppelin_test_common::ownable::OwnableSpyHelpers;
use openzeppelin_testing::constants::{ZERO, OTHER, OWNER, RECIPIENT};
use snforge_std::{spy_events, test_address, start_cheat_caller_address};
Expand Down
2 changes: 1 addition & 1 deletion packages/access/src/tests/test_ownable_twostep.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::num::traits::Zero;
use crate::ownable::OwnableComponent::{InternalTrait, OwnershipTransferStarted};
use crate::ownable::OwnableComponent;
use crate::ownable::interface::{IOwnableTwoStep, IOwnableTwoStepCamelOnly};
use crate::tests::mocks::ownable_mocks::DualCaseTwoStepOwnableMock;
use openzeppelin_test_common::mocks::access::DualCaseTwoStepOwnableMock;
use openzeppelin_test_common::ownable::OwnableSpyHelpers;
use openzeppelin_testing::constants::{ZERO, OWNER, OTHER, NEW_OWNER};
use openzeppelin_testing::events::EventSpyExt;
Expand Down
9 changes: 9 additions & 0 deletions packages/account/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,12 @@ openzeppelin_test_common = { path = "../test_common" }
allowed-libfuncs-list.name = "experimental"
sierra = true
casm = false

[[test]]
name = "openzeppelin_account_unittest"
build-external-contracts = [
"openzeppelin_test_common::mocks::account::DualCaseAccountMock",
"openzeppelin_test_common::mocks::account::DualCaseEthAccountMock",
"openzeppelin_test_common::mocks::src9::SRC9AccountMock",
"openzeppelin_test_common::mocks::simple::SimpleMock",
]
3 changes: 2 additions & 1 deletion packages/account/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ pub mod eth_account;
pub mod extensions;
pub mod interface;

pub mod tests;
#[cfg(test)]
mod tests;
pub mod utils;

pub use account::AccountComponent;
Expand Down
5 changes: 0 additions & 5 deletions packages/account/src/tests.cairo
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
mod extensions;
pub(crate) mod mocks;

#[cfg(test)]
mod test_account;
#[cfg(test)]
mod test_eth_account;
#[cfg(test)]
mod test_secp256k1;
#[cfg(test)]
mod test_signature;
2 changes: 0 additions & 2 deletions packages/account/src/tests/extensions.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
#[cfg(test)]
mod test_snip12_utils;
#[cfg(test)]
mod test_src9;
2 changes: 1 addition & 1 deletion packages/account/src/tests/extensions/test_src9.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::extensions::SRC9Component;
use crate::extensions::src9::interface::{ISRC9_V2Dispatcher, ISRC9_V2DispatcherTrait};
use crate::extensions::src9::interface::{OutsideExecution, ISRC9_V2_ID};
use crate::extensions::src9::snip12_utils::OutsideExecutionStructHash;
use crate::tests::mocks::src9_mocks::SRC9AccountMock;
use openzeppelin_introspection::interface::{ISRC5, ISRC5_ID};
use openzeppelin_test_common::mocks::src9::SRC9AccountMock;
use openzeppelin_testing as utils;
use openzeppelin_testing::constants::{RECIPIENT, OWNER, OTHER, FELT_VALUE};
use openzeppelin_utils::cryptography::snip12::OffchainMessageHash;
Expand Down
4 changes: 0 additions & 4 deletions packages/account/src/tests/mocks.cairo

This file was deleted.

45 changes: 0 additions & 45 deletions packages/account/src/tests/mocks/account_mocks.cairo

This file was deleted.

Loading

0 comments on commit 1cbef43

Please sign in to comment.