Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): migrate unit tests to the new motsu layout #423

Draft
wants to merge 89 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
64cb1ec
add storage guard
qalisander Oct 17, 2024
e2fafe8
comment non erc721 unit test
qalisander Nov 21, 2024
02d3468
++
qalisander Nov 22, 2024
d126f0e
++
qalisander Nov 22, 2024
ef905e5
++
qalisander Nov 22, 2024
7883a64
add ping pong test case
qalisander Nov 22, 2024
f49daf5
add test router
qalisander Nov 22, 2024
1dc7519
add call shim
qalisander Nov 22, 2024
092a370
++
qalisander Nov 22, 2024
e5028fc
add msg::value
qalisander Nov 22, 2024
c03429d
fix deadlock
qalisander Nov 22, 2024
0c5ac77
ping pong works
qalisander Nov 22, 2024
924e72e
++
qalisander Nov 22, 2024
59cc1a2
++
qalisander Nov 22, 2024
110d340
++
qalisander Nov 22, 2024
aa577f2
++
qalisander Nov 22, 2024
01401e8
comment erc721 tests
qalisander Nov 23, 2024
0cd4299
add erc721 receiver test
qalisander Nov 23, 2024
2b944ce
use contract wrapper in motsu params
qalisander Nov 28, 2024
0aaa81e
add msg sender mock
qalisander Nov 28, 2024
b920606
Merge remote-tracking branch 'origin/main' into unit-tests/multiple-c…
qalisander Nov 28, 2024
33454f6
++
qalisander Nov 28, 2024
299ecc4
++
qalisander Nov 29, 2024
acc631f
Merge remote-tracking branch 'origin/main' into unit-tests/multiple-c…
qalisander Dec 2, 2024
4a747f1
comment test not ported test cases
qalisander Dec 2, 2024
73c5792
remove motsu from default members, since we're going to split this li…
qalisander Dec 2, 2024
abfbbb9
have cargo hack just for contracts
qalisander Dec 2, 2024
f4a74c5
++
qalisander Dec 2, 2024
2b688ce
build: bump Stylus SDK and alloy versions
bidzyyys Nov 29, 2024
ddef560
fix: move const value in AccessControl
bidzyyys Nov 29, 2024
1d27f6c
ref: move interfaces to base modules
bidzyyys Dec 2, 2024
c3cc640
ref: fix AccessControl example
bidzyyys Dec 2, 2024
e0e71ba
fix: add missing Vec imports
bidzyyys Dec 2, 2024
b24bcdf
build: use koba with updated alloy
bidzyyys Dec 4, 2024
0f40dc4
build: update E2E crate with new alloy
bidzyyys Dec 3, 2024
3c909bf
ref: extract v as u8 from Signature
bidzyyys Dec 3, 2024
1acaa4c
fix: use proper data type for U96
bidzyyys Dec 3, 2024
fa476f1
fix: benches
bidzyyys Dec 3, 2024
1078a12
fix: constrain storage ints
bidzyyys Dec 4, 2024
a9c3fbe
build: update koba to v0.3.0
bidzyyys Dec 5, 2024
94cb034
remove not used Provider
qalisander Dec 6, 2024
06945d6
add stylus-sdk patch for external calls
qalisander Dec 6, 2024
3a6e6bd
retrieve tx hashes for block timestamp
qalisander Dec 7, 2024
d33bdc3
fix run_check_release test for vesting_wallet
qalisander Dec 7, 2024
a580f98
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 7, 2024
eb5cc95
update alloy to 0.8.14
qalisander Dec 9, 2024
378da95
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 10, 2024
e7d074f
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 11, 2024
c255a90
++
qalisander Dec 11, 2024
f8b7645
import alloc::vec::Vec for permit
qalisander Dec 11, 2024
0f2a246
remove unused code
qalisander Dec 11, 2024
a5d40c1
Merge remote-tracking branch 'origin/main' into unit-tests/multiple-c…
qalisander Dec 11, 2024
843ded7
Merge branch 'build/stylus-v0.7.0-beta.1' into unit-tests/multiple-co…
qalisander Dec 11, 2024
f27aed9
++
qalisander Dec 11, 2024
f0f94ac
++
qalisander Dec 11, 2024
32ad8fd
test ping_pong_works pass with msg::sender()
qalisander Dec 11, 2024
0b31370
remove context msg_sender
qalisander Dec 11, 2024
74b4672
Merge remote-tracking branch 'origin/main' into build/stylus-v0.7.0-b…
qalisander Dec 13, 2024
b6898fc
post merge fix
qalisander Dec 13, 2024
a16de97
++
qalisander Dec 13, 2024
acd843a
++
qalisander Dec 13, 2024
47a3aa3
Merge branch 'build/stylus-v0.7.0-beta.1' into unit-tests/multiple-co…
qalisander Dec 13, 2024
9a84c14
post merge fix
qalisander Dec 13, 2024
ed41209
alloy-primitives 0.8.14 -> 0.8.13
qalisander Dec 18, 2024
780c6ec
++
qalisander Dec 23, 2024
1487ee0
Merge branch 'unit-tests/multiple-contract-deployment-v0.7.0-beta' in…
qalisander Dec 23, 2024
4c3366a
Merge remote-tracking branch 'origin/main' into unit-tests/multiple-c…
qalisander Dec 23, 2024
297b574
patch motsu
qalisander Dec 23, 2024
267289c
++
qalisander Dec 31, 2024
6f71be6
++
qalisander Dec 31, 2024
425cf63
++
qalisander Dec 31, 2024
0ecc2a3
++
qalisander Dec 31, 2024
7ee9dc1
++
qalisander Dec 31, 2024
6e3bf2b
++
qalisander Dec 31, 2024
c302a60
++
qalisander Dec 31, 2024
4b135dd
erc721 uri storage tests
qalisander Jan 6, 2025
c455196
erc20 tests
qalisander Jan 7, 2025
0ac0b28
bump stylus sdk v0.7.0
qalisander Jan 7, 2025
e8fd4aa
Merge remote-tracking branch 'origin/main' into unit-tests/multiple-c…
qalisander Jan 15, 2025
2d29ce0
++
qalisander Jan 15, 2025
7b39a37
++
qalisander Jan 15, 2025
5c0ef1a
++
qalisander Jan 15, 2025
f6c71b5
++
qalisander Jan 15, 2025
00b1fce
Merge remote-tracking branch 'origin/main' into unit-tests/multiple-c…
qalisander Jan 15, 2025
2b042a7
++
qalisander Jan 16, 2025
1aba40b
++
qalisander Jan 16, 2025
eedad10
++
qalisander Jan 16, 2025
75176c3
++
qalisander Jan 16, 2025
09944a7
++
qalisander Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
# target in this context means one of `--lib`, `--bin`, etc, and not the
# target triple.
- name: Cargo hack
run: cargo hack check --feature-powerset --depth 2 --release --target wasm32-unknown-unknown --skip std --workspace --exclude e2e --exclude basic-example-script --exclude benches
run: cargo hack check --feature-powerset --depth 2 --release --target wasm32-unknown-unknown --skip std --package openzeppelin-stylus
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want this change?

typos:
runs-on: ubuntu-latest
name: ubuntu / stable / typos
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ default-members = [
"contracts",
"contracts-proc",
"lib/crypto",
"lib/motsu",
"lib/motsu-proc",
"lib/e2e-proc",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we are removing lib/motsu and lib/motsu-proc this line also should be removed.

"examples/erc20",
"examples/erc20-permit",
Expand Down
3 changes: 2 additions & 1 deletion contracts/src/access/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
}
}

#[public]

Check warning on line 117 in contracts/src/access/control.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unexpected `cfg` condition value: `export-abi`

Check warning on line 117 in contracts/src/access/control.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unexpected `cfg` condition value: `export-abi`
impl AccessControl {
/// The default admin role. `[0; 32]` by default.
pub const DEFAULT_ADMIN_ROLE: [u8; 32] = [0; 32];
Expand Down Expand Up @@ -365,7 +365,7 @@
}
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, Address};
Expand Down Expand Up @@ -593,3 +593,4 @@
assert_eq!(role_revoked, false);
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/access/ownable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
fn renounce_ownership(&mut self) -> Result<(), Self::Error>;
}

#[public]

Check warning on line 123 in contracts/src/access/ownable.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unexpected `cfg` condition value: `export-abi`

Check warning on line 123 in contracts/src/access/ownable.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unexpected `cfg` condition value: `export-abi`
impl IOwnable for Ownable {
type Error = Error;

Expand Down Expand Up @@ -191,7 +191,7 @@
evm::log(OwnershipTransferred { previous_owner, new_owner });
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, Address};
Expand Down Expand Up @@ -264,3 +264,4 @@
assert_eq!(owner, ALICE);
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/access/ownable_two_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
fn renounce_ownership(&mut self) -> Result<(), Self::Error>;
}

#[public]

Check warning on line 143 in contracts/src/access/ownable_two_step.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unexpected `cfg` condition value: `export-abi`

Check warning on line 143 in contracts/src/access/ownable_two_step.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unexpected `cfg` condition value: `export-abi`
impl IOwnable2Step for Ownable2Step {
type Error = Error;

Expand Down Expand Up @@ -208,7 +208,7 @@
self._ownable._transfer_ownership(new_owner);
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, Address};
Expand Down Expand Up @@ -351,3 +351,4 @@
assert_eq!(contract.owner(), msg::sender());
}
}
*/
4 changes: 2 additions & 2 deletions contracts/src/finance/vesting_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
) -> Result<U256, Self::Error>;
}

#[public]

Check warning on line 346 in contracts/src/finance/vesting_wallet.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unexpected `cfg` condition value: `export-abi`

Check warning on line 346 in contracts/src/finance/vesting_wallet.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unexpected `cfg` condition value: `export-abi`
impl IVestingWallet for VestingWallet {
type Error = Error;

Expand Down Expand Up @@ -511,7 +511,7 @@

#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256, U64};
/*use alloy_primitives::{address, uint, Address, U256, U64};
use stylus_sdk::block;

use super::{IVestingWallet, VestingWallet};
Expand Down Expand Up @@ -607,5 +607,5 @@
);
assert_eq!(two, contract.vesting_schedule(two, start));
assert_eq!(two, contract.vesting_schedule(two, start + U64::from(1)));
}
}*/
}
2 changes: 2 additions & 0 deletions contracts/src/token/erc1155/extensions/burnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl Erc1155 {

#[cfg(all(test, feature = "std"))]
mod tests {
/*
use alloy_primitives::{address, Address, U256};
use stylus_sdk::msg;

Expand Down Expand Up @@ -348,4 +349,5 @@ mod tests {
}) if sender == alice && balance == values[0] && needed == to_burn[0] && token_id == token_ids[0]
));
}
*/
}
4 changes: 2 additions & 2 deletions contracts/src/token/erc1155/extensions/metadata_uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
fn uri(&self, id: U256) -> String;
}

#[public]

Check warning on line 51 in contracts/src/token/erc1155/extensions/metadata_uri.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unexpected `cfg` condition value: `export-abi`

Check warning on line 51 in contracts/src/token/erc1155/extensions/metadata_uri.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unexpected `cfg` condition value: `export-abi`
impl IErc1155MetadataUri for Erc1155MetadataUri {
/// This implementation returns the same URI for all token types.
/// Clients calling this function must replace the `id` substring with
Expand All @@ -68,7 +68,7 @@

#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::U256;
/*use alloy_primitives::U256;

use super::{Erc1155MetadataUri, IErc1155MetadataUri, IErc165};

Expand Down Expand Up @@ -98,5 +98,5 @@
let actual = <Erc1155MetadataUri as IErc165>::INTERFACE_ID;
let expected = 0x01ffc9a7;
assert_eq!(actual, expected);
}
}*/
}
3 changes: 2 additions & 1 deletion contracts/src/token/erc1155/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@
) -> Result<(), Self::Error>;
}

#[public]

Check warning on line 387 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unexpected `cfg` condition value: `export-abi`

Check warning on line 387 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unexpected `cfg` condition value: `export-abi`
impl IErc1155 for Erc1155 {
type Error = Error;

Expand Down Expand Up @@ -1177,7 +1177,7 @@
/// * `values` - Array of all amount of tokens being transferred.
Batch { ids: Vec<U256>, values: Vec<U256> },
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256};
Expand Down Expand Up @@ -2203,3 +2203,4 @@
assert_eq!(actual, expected);
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/token/erc20/extensions/burnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl IErc20Burnable for Erc20 {
self._burn(account, value)
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256};
Expand Down Expand Up @@ -184,3 +184,4 @@ mod tests {
assert!(matches!(result, Err(Error::InsufficientAllowance(_))));
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/token/erc20/extensions/capped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
}
}

#[public]

Check warning on line 46 in contracts/src/token/erc20/extensions/capped.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

unexpected `cfg` condition value: `export-abi`

Check warning on line 46 in contracts/src/token/erc20/extensions/capped.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unexpected `cfg` condition value: `export-abi`
impl Capped {
/// Returns the cap on the token's total supply.
pub fn cap(&self) -> U256 {
self._cap.get()
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::uint;
Expand All @@ -68,3 +68,4 @@
assert_eq!(contract.cap(), value);
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/token/erc20/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ impl Erc20 {
Ok(())
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256};
Expand Down Expand Up @@ -925,3 +925,4 @@ mod tests {
assert_eq!(actual, expected);
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/token/erc20/utils/safe_erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
) -> Result<(), Self::Error>;
}

#[public]

Check warning on line 231 in contracts/src/token/erc20/utils/safe_erc20.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

unexpected `cfg` condition value: `export-abi`
impl ISafeErc20 for SafeErc20 {
type Error = Error;

Expand Down Expand Up @@ -394,7 +394,7 @@
})
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use super::SafeErc20;
Expand Down Expand Up @@ -437,3 +437,4 @@
);
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/token/erc721/extensions/burnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl IErc721Burnable for Erc721 {
Ok(())
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address};
Expand Down Expand Up @@ -223,3 +223,4 @@ mod tests {
));
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/token/erc721/extensions/consecutive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl Erc721Consecutive {
Ok(owner)
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256};
Expand Down Expand Up @@ -1333,3 +1333,4 @@ mod tests {
));
}
}
*/
13 changes: 7 additions & 6 deletions contracts/src/token/erc721/extensions/enumerable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl Erc721Enumerable {
}
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256};
Expand Down Expand Up @@ -454,7 +454,7 @@ mod tests {
assert_eq!(owner, alice);

let res =
contract._add_token_to_owner_enumeration(alice, token_id, &erc721);
contract._add_token_to_owner_enumeration(alice, token_id, &*erc721);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need additional *?

assert!(res.is_ok());

let test_token_id = contract
Expand Down Expand Up @@ -483,7 +483,7 @@ mod tests {
assert_eq!(owner, alice);

let res =
contract._add_token_to_owner_enumeration(alice, token_id, &erc721);
contract._add_token_to_owner_enumeration(alice, token_id, &*erc721);
assert!(res.is_ok());

let err =
Expand Down Expand Up @@ -525,7 +525,7 @@ mod tests {
assert_eq!(owner, alice);

let res =
contract._add_token_to_owner_enumeration(alice, token_id, &erc721);
contract._add_token_to_owner_enumeration(alice, token_id, &*erc721);
assert!(res.is_ok());

// Transfer the token from ALICE to BOB.
Expand All @@ -538,11 +538,11 @@ mod tests {
assert_eq!(owner, BOB);

let res = contract
._remove_token_from_owner_enumeration(alice, token_id, &erc721);
._remove_token_from_owner_enumeration(alice, token_id, &*erc721);
assert!(res.is_ok());

let res =
contract._add_token_to_owner_enumeration(BOB, token_id, &erc721);
contract._add_token_to_owner_enumeration(BOB, token_id, &*erc721);
assert!(res.is_ok());

let test_token_id = contract
Expand All @@ -563,3 +563,4 @@ mod tests {
assert_eq!(actual, expected);
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/token/erc721/extensions/uri_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Erc721UriStorage {
Ok(uri)
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::U256;
Expand Down Expand Up @@ -181,3 +181,4 @@ mod tests {
);
}
}
*/
Loading
Loading