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

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

Merged
merged 133 commits into from
Feb 11, 2025

Conversation

qalisander
Copy link
Member

@qalisander qalisander commented Nov 28, 2024

This pr contains migration of unit test to the new layout of motsu unit tests, that will be introduced in OpenZeppelin/stylus-test-helpers#8 and OpenZeppelin/stylus-test-helpers#12

Resolves #470

PR Checklist

  • Tests
  • Documentation
  • Changelog

Copy link

netlify bot commented Nov 28, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit dd46a36
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/67ab77d4d5462d00087e99bb

Comment on lines 2547 to 2562
#[motsu::test]
fn on_erc721_received(
erc721: Contract<Erc721>,
receiver: Contract<Erc721ReceiverMock>,
) {
let alice = Account::random();
let token_id = random_token_id();
erc721
.sender(alice)
._safe_mint(receiver.address(), token_id, vec![0, 1, 2, 3].into())
.unwrap();

let received_token_id = receiver.sender(alice).received_token_id();

assert_eq!(received_token_id, token_id);
}
Copy link
Member Author

@qalisander qalisander Nov 28, 2024

Choose a reason for hiding this comment

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

Overall the test case for Erc721Receiver can look like this

@qalisander qalisander marked this pull request as ready for review November 28, 2024 05:59
@bidzyyys bidzyyys linked an issue Feb 5, 2025 that may be closed by this pull request
1 task
@bidzyyys bidzyyys marked this pull request as ready for review February 6, 2025 09:28
@bidzyyys bidzyyys changed the title feat(test): migrate unit tests to the new motsu layout refactor(test): migrate unit tests to the new motsu layout Feb 6, 2025
Copy link
Collaborator

@0xNeshi 0xNeshi left a comment

Choose a reason for hiding this comment

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

This PR looks like it took quite a bit of time, kudos to you both!

Comment on lines +407 to +408
let (token_ids, values) =
contract.init(alice, |contract| init(contract, bob, 1));
Copy link
Collaborator

@0xNeshi 0xNeshi Feb 6, 2025

Choose a reason for hiding this comment

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

Tbh this looks less clear compared to doing the same manually:

        let mut callable = contract.sender(alice);
        let (token_ids, values) = init(&mut callable, bob, 1);

@0xNeshi
Copy link
Collaborator

0xNeshi commented Feb 11, 2025

I think it's safe to merge this PR, as it doesn't rely on e2e tests, only on unit tests (which pass)

@bidzyyys bidzyyys merged commit e735e3d into main Feb 11, 2025
25 checks passed
@bidzyyys bidzyyys deleted the unit-tests/multiple-contract-deployment branch February 11, 2025 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Feature]: Un-ignore and Fix Erc20FlashMint Unit Tests
3 participants