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

ref: Add/Sub Assignment Operations + e2e-tests.sh #467

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

0xNeshi
Copy link
Collaborator

@0xNeshi 0xNeshi commented Dec 26, 2024

Resolves #445, Resolves #444

PR Checklist

  • Tests
  • Documentation
  • Changelog

@0xNeshi 0xNeshi self-assigned this Dec 26, 2024
Copy link

netlify bot commented Dec 26, 2024

Deploy Preview for contracts-stylus canceled.

Name Link
🔨 Latest commit c5c7be5
🔍 Latest deploy log https://app.netlify.com/sites/contracts-stylus/deploys/6773bc6601658c0008e64e64

Copy link

codecov bot commented Dec 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.6%. Comparing base (3205fc7) to head (c5c7be5).

Additional details and impacted files
Files with missing lines Coverage Δ
contracts/src/access/control.rs 98.5% <ø> (ø)
contracts/src/access/ownable.rs 94.1% <ø> (ø)
contracts/src/access/ownable_two_step.rs 99.2% <ø> (ø)
contracts/src/finance/vesting_wallet.rs 55.6% <ø> (ø)
...racts/src/token/erc1155/extensions/metadata_uri.rs 78.5% <ø> (ø)
contracts/src/token/erc1155/extensions/supply.rs 81.1% <ø> (ø)
...tracts/src/token/erc1155/extensions/uri_storage.rs 98.2% <ø> (ø)
contracts/src/token/erc1155/mod.rs 96.9% <ø> (ø)
contracts/src/token/erc20/extensions/capped.rs 83.3% <ø> (ø)
contracts/src/token/erc20/extensions/metadata.rs 22.2% <ø> (ø)
... and 12 more

@0xNeshi 0xNeshi requested a review from ggonzalez94 December 26, 2024 18:39
cargo test --features std,e2e --test "*"
else
cargo test --features std,e2e "$@"
fi
Copy link
Collaborator Author

@0xNeshi 0xNeshi Dec 26, 2024

Choose a reason for hiding this comment

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

The script can now be called in the following ways:

  • if no arguments are passed, the behavior is the same as before
  • otherwise, pass whatever arguments are present to cargo test directly

We can now easily filter for even unit tests with this script.

This should cover most of our testing needs.

NOTE: feel free to suggest or add any additional feature you think might be useful.
NOTE 2: we don't seem to be needing std feature for e2e tests.

Copy link
Collaborator Author

@0xNeshi 0xNeshi Dec 27, 2024

Choose a reason for hiding this comment

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

Another option is to omit the if-statement, and just call cargo test --features e2e "$@", passing whatever arguments to the command. In our e2e workflow, we'd then call the script like ./scripts/e2e-tests.sh --test "*".

I'd be more in favor of this approach, but my first instinct was to keep the existing behavior as much as possible, and only change it after discussing it with you guys.

At this point it's really a matter of taste

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's leave right now the current behaviour.

Copy link
Member

@qalisander qalisander Dec 30, 2024

Choose a reason for hiding this comment

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

I'm curious what will be different in devex with these changes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically, it lets you call this script as if you were to call cargo test, meaning it enables you to do all the funky filtering stuff

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The current implementation is the simplest one, with the most straightforward way to use.

Updating the script to support invocations like:

./scripts/e2e-tests.sh erc721 error_when_minting_token_id_twice

Would make it very complex if we also wanted to support passing other valid args/flags to cargo test, or to the test binary.

But actually what I like very much in your approach, is that if we spell ./scripts/e2e-tests.sh --help it will print docs for cargo sub commands. So no need to bother ourselves with script's documentation

Can you clarify the last sentence?

Copy link
Member

@qalisander qalisander Dec 31, 2024

Choose a reason for hiding this comment

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

Let's keep your changes

Copy link
Member

@qalisander qalisander Dec 31, 2024

Choose a reason for hiding this comment

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

Can you clarify the last sentence?

I mean, that we can print valid documentation for e2e-test.sh script, since we're just forwarding arguments to cargo test:

./scripts/e2e-tests.sh --help

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Does the script then have your blessing? 😄

Copy link
Member

Choose a reason for hiding this comment

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

bless:D

Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

I believe we can apply #[allow(clippy::used_underscore_binding)] for the whole contracts library

@bidzyyys bidzyyys self-requested a review December 27, 2024 08:36
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

Left some comments, good job @0xNeshi

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
contracts/src/utils/nonces.rs Outdated Show resolved Hide resolved
contracts/src/utils/nonces.rs Outdated Show resolved Hide resolved
contracts/src/utils/nonces.rs Outdated Show resolved Hide resolved
contracts/src/utils/nonces.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@bidzyyys bidzyyys self-requested a review December 27, 2024 11:04
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

Almost ready to merge!

contracts/src/utils/nonces.rs Outdated Show resolved Hide resolved
contracts/src/utils/nonces.rs Outdated Show resolved Hide resolved
contracts/src/access/control.rs Show resolved Hide resolved
@0xNeshi 0xNeshi requested a review from bidzyyys December 30, 2024 07:57
Copy link
Collaborator

@bidzyyys bidzyyys left a comment

Choose a reason for hiding this comment

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

LGTM!

contracts/src/finance/vesting_wallet.rs Show resolved Hide resolved
cargo test --features std,e2e --test "*"
else
cargo test --features std,e2e "$@"
fi
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's leave right now the current behaviour.

Copy link
Member

@qalisander qalisander left a comment

Choose a reason for hiding this comment

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

Good job!

cargo test --features std,e2e --test "*"
else
cargo test --features std,e2e "$@"
fi
Copy link
Member

@qalisander qalisander Dec 30, 2024

Choose a reason for hiding this comment

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

I'm curious what will be different in devex with these changes?

scripts/e2e-tests.sh Show resolved Hide resolved
examples/erc20/src/lib.rs Show resolved Hide resolved
contracts/src/utils/math/storage.rs Outdated Show resolved Hide resolved
contracts/src/access/control.rs Show resolved Hide resolved
@0xNeshi 0xNeshi requested a review from qalisander December 31, 2024 07:34
Copy link
Member

@qalisander qalisander left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants