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): unit test external call mock #423

Open
wants to merge 68 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
68 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
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
33 changes: 32 additions & 1 deletion Cargo.lock

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

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`

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`

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`

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());
}
}
*/
3 changes: 2 additions & 1 deletion contracts/src/token/erc1155/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@
) -> Result<(), Self::Error>;
}

#[public]

Check warning on line 379 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 379 in contracts/src/token/erc1155/mod.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

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

Check warning on line 379 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 @@ -1167,7 +1167,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 @@ -2193,3 +2193,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`

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 @@ -253,7 +253,7 @@
) -> Result<bool, Self::Error>;
}

#[public]

Check warning on line 256 in contracts/src/token/erc20/mod.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

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

Check warning on line 256 in contracts/src/token/erc20/mod.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

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

Check warning on line 256 in contracts/src/token/erc20/mod.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

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

Expand Down Expand Up @@ -573,7 +573,7 @@
Ok(())
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256};
Expand Down Expand Up @@ -925,3 +925,4 @@
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 @@ -222,7 +222,7 @@
) -> Result<(), Self::Error>;
}

#[public]

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

View workflow job for this annotation

GitHub Actions / nightly / doc

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

Check warning on line 225 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`

Check warning on line 225 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 @@ -388,7 +388,7 @@
})
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use super::SafeErc20;
Expand Down Expand Up @@ -431,3 +431,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 @@ -137,7 +137,7 @@

// ************** ERC-721 External **************

#[public]

Check warning on line 140 in contracts/src/token/erc721/extensions/consecutive.rs

View workflow job for this annotation

GitHub Actions / nightly / doc

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

Check warning on line 140 in contracts/src/token/erc721/extensions/consecutive.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

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

Check warning on line 140 in contracts/src/token/erc721/extensions/consecutive.rs

View workflow job for this annotation

GitHub Actions / ubuntu / beta

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

Expand Down Expand Up @@ -793,7 +793,7 @@
Ok(owner)
}
}

/*
#[cfg(all(test, feature = "std"))]
mod tests {
use alloy_primitives::{address, uint, Address, U256};
Expand Down Expand Up @@ -1333,3 +1333,4 @@
));
}
}
*/
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);
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