Skip to content

test: Increase code coverage #792

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

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
672f7aa
test: increase ownable code cov.
0xNeshi Aug 13, 2025
2b1e39b
test: comment out enumset
0xNeshi Aug 13, 2025
c357f7a
test: improve enumerable.rs coverage
0xNeshi Aug 13, 2025
dc5158f
test: increase vesting wallet coverage
0xNeshi Aug 13, 2025
2dacd0e
test: improve proxy code cov.
0xNeshi Aug 13, 2025
73d0d43
test: increase vesting wallet coverage
0xNeshi Aug 13, 2025
a46afe6
test: increase address utils code cov.
0xNeshi Aug 13, 2025
e1d3fc6
test: increase proxy utils code cov.
0xNeshi Aug 13, 2025
a6586c0
test: increase safeerc20 code cov.
0xNeshi Aug 13, 2025
4ac45a4
test: increase erc1155 code cov.
0xNeshi Aug 13, 2025
a82ddc6
Merge branch 'main' into access-code-cov
0xNeshi Aug 13, 2025
d56cd34
test: use descriptive names for receiver
0xNeshi Aug 13, 2025
4b18ebb
test: Apply suggestions from code review
0xNeshi Aug 13, 2025
400539a
test: remove coverage attr
0xNeshi Aug 13, 2025
6f2ec4d
Revert "test: comment out enumset"
0xNeshi Aug 13, 2025
e1f3ad8
test: remove redundant attr
0xNeshi Aug 15, 2025
107d929
test: increase erc1155supply code cov
0xNeshi Aug 15, 2025
acb8125
test: increase erc1155supply code cov to 100%
0xNeshi Aug 15, 2025
a1f060b
test: erc20 code cov to 100%
0xNeshi Aug 15, 2025
24c93f3
test: improve test comments
0xNeshi Aug 15, 2025
31ce669
test: slightly improve safeerc20 code cov
0xNeshi Aug 15, 2025
73fee68
test: slightly improve erc721 code cov
0xNeshi Aug 15, 2025
34c167f
test : ignore enumset tests
0xNeshi Aug 15, 2025
1e99573
test: use constructor in consecutive
0xNeshi Aug 15, 2025
e575ed7
test: improve erc721consecutive code cov
0xNeshi Aug 15, 2025
991b9cf
test: improve erc721enumerable code cov
0xNeshi Aug 15, 2025
adb5d14
test: improve erc721metadata code cov
0xNeshi Aug 15, 2025
c36c6f0
test: improve erc721uristorage code cov
0xNeshi Aug 15, 2025
2ac1805
test: improve erc721wrapper code cov
0xNeshi Aug 15, 2025
af7c220
test: improve proxies' code cov
0xNeshi Aug 15, 2025
07a3b99
docs: fmt
0xNeshi Aug 15, 2025
089a7b4
Revert "test : ignore enumset tests"
0xNeshi Aug 15, 2025
70804b2
test: increase test coverage for more contracts
0xNeshi Aug 15, 2025
e0a723c
test: cover revert flows in flash_mint
0xNeshi Aug 15, 2025
6f8365f
test: increase code cov for flash_mint
0xNeshi Aug 15, 2025
d7b71bd
test: fmt
0xNeshi Aug 15, 2025
53c0116
test: remove ignored test from coverage
0xNeshi Aug 15, 2025
6fccdf1
test: cover Trace::at panic flow
0xNeshi Aug 18, 2025
97f901f
test: cover EnumerableSet::clear 100%
0xNeshi Aug 18, 2025
80d5179
test: alloy to 100%
0xNeshi Aug 18, 2025
4f0f8b8
test: acdsa to 100%
0xNeshi Aug 18, 2025
32bbf40
test: merkle to 100% code cov
0xNeshi Aug 18, 2025
b162f3b
test: hash to 100% code cov
0xNeshi Aug 18, 2025
81f5abb
test: signing_key_creation_is_idempotent
0xNeshi Aug 18, 2025
74c8a13
test: uint default code cov
0xNeshi Aug 18, 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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ syn = { version = "2.0.58", features = ["full"] }
proc-macro2 = "1.0.79"
quote = "1.0.35"

paste = "1.0.15"

motsu = "=0.10.0"

# members
Expand Down
1 change: 1 addition & 0 deletions contracts/src/access/control/extensions/enumerable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ mod tests {
}
}

#[cfg_attr(coverage_nightly, coverage(off))]
#[public]
impl IAccessControl for AccessControlEnumerableExample {
type Error = control::Error;
Expand Down
57 changes: 40 additions & 17 deletions contracts/src/access/ownable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ impl IErc165 for Ownable {

#[cfg(test)]
mod tests {
use core::ops::{Deref, DerefMut};

use motsu::prelude::*;
use stylus_sdk::{alloy_primitives::Address, prelude::*};

Expand All @@ -295,7 +297,7 @@ mod tests {
fn constructor(contract: Contract<Ownable>, alice: Address) {
contract.sender(alice).constructor(alice).unwrap();

let owner = contract.sender(alice).owner();
let owner = IOwnable::owner(contract.sender(alice).deref());
assert_eq!(owner, alice);

contract.assert_emitted(&OwnershipTransferred {
Expand Down Expand Up @@ -326,9 +328,7 @@ mod tests {
) {
contract.sender(alice).constructor(alice).unwrap();

contract
.sender(alice)
.transfer_ownership(bob)
IOwnable::transfer_ownership(contract.sender(alice).deref_mut(), bob)
.expect("should transfer ownership");
let owner = contract.sender(alice).owner();
assert_eq!(owner, bob);
Expand All @@ -347,8 +347,19 @@ mod tests {
) {
contract.sender(alice).constructor(bob).unwrap();

let err = contract.sender(alice).transfer_ownership(bob).unwrap_err();
assert!(matches!(err, Error::UnauthorizedAccount(_)));
let err = IOwnable::transfer_ownership(
contract.sender(alice).deref_mut(),
bob,
)
.motsu_unwrap_err();

assert_eq!(
err,
Error::UnauthorizedAccount(OwnableUnauthorizedAccount {
account: alice
})
.encode()
);
}

#[motsu::test]
Expand All @@ -358,12 +369,17 @@ mod tests {
) {
contract.sender(alice).constructor(alice).unwrap();

let err = contract
.sender(alice)
.transfer_ownership(Address::ZERO)
.unwrap_err();
let err = IOwnable::transfer_ownership(
contract.sender(alice).deref_mut(),
Address::ZERO,
)
.motsu_unwrap_err();

assert!(matches!(err, Error::InvalidOwner(_)));
assert_eq!(
err,
Error::InvalidOwner(OwnableInvalidOwner { owner: Address::ZERO })
.encode()
);
}

#[motsu::test]
Expand All @@ -373,10 +389,8 @@ mod tests {
) {
contract.sender(alice).constructor(alice).unwrap();

contract
.sender(alice)
.renounce_ownership()
.expect("should renounce ownership");
IOwnable::renounce_ownership(contract.sender(alice).deref_mut())
.motsu_expect("should renounce ownership");
let owner = contract.sender(alice).owner();
assert_eq!(owner, Address::ZERO);

Expand All @@ -394,8 +408,17 @@ mod tests {
) {
contract.sender(alice).constructor(bob).unwrap();

let err = contract.sender(alice).renounce_ownership().unwrap_err();
assert!(matches!(err, Error::UnauthorizedAccount(_)));
let err =
IOwnable::renounce_ownership(contract.sender(alice).deref_mut())
.motsu_unwrap_err();

assert_eq!(
err,
Error::UnauthorizedAccount(OwnableUnauthorizedAccount {
account: alice
})
.encode()
);
}

#[motsu::test]
Expand Down
Loading
Loading