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

Add .on('error') test for reverted contract methods #6194

Merged
merged 6 commits into from
Jun 21, 2023

Conversation

spacesailor24
Copy link
Contributor

This PR just adds two tests that verify we receive the revert error using .on('error') when calling a contract method that reverts

related to #5670

@spacesailor24 spacesailor24 added the 4.x 4.0 related label Jun 13, 2023
@spacesailor24 spacesailor24 self-assigned this Jun 13, 2023
@github-actions
Copy link

Bundle Stats

Hey there, this message comes from a github action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Asset Old size New size Diff Diff %
Total 638 KB 638 KB 0 0.00%
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset Old size New size Diff Diff %
web3.min.js 621 KB 621 KB 0 0.00%
../lib/commonjs/index.d.ts 8.56 KB 8.56 KB 0 0.00%
../lib/commonjs/accounts.d.ts 3.67 KB 3.67 KB 0 0.00%
../lib/commonjs/types.d.ts 2.37 KB 2.37 KB 0 0.00%
../lib/commonjs/abi.d.ts 1000 bytes 1000 bytes 0 0.00%
../lib/commonjs/web3.d.ts 811 bytes 811 bytes 0 0.00%
../lib/commonjs/eth.exports.d.ts 280 bytes 280 bytes 0 0.00%
../lib/commonjs/providers.exports.d.ts 148 bytes 148 bytes 0 0.00%
../lib/commonjs/version.d.ts 60 bytes 60 bytes 0 0.00%

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jun 13, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0603716
Status: ✅  Deploy successful!
Preview URL: https://635265bb.web3-js-docs.pages.dev
Branch Preview URL: https://wyatt-4-x-5670-contract-meth.web3-js-docs.pages.dev

View logs

@codecov
Copy link

codecov bot commented Jun 13, 2023

Codecov Report

Merging #6194 (0603716) into 4.x (023f02d) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##              4.x    #6194   +/-   ##
=======================================
  Coverage   87.46%   87.46%           
=======================================
  Files         197      197           
  Lines        7557     7557           
  Branches     2060     2060           
=======================================
  Hits         6610     6610           
  Misses        947      947           
Flag Coverage Δ
UnitTests 87.46% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
web3 ∅ <ø> (∅)
web3-core ∅ <ø> (∅)
web3-errors ∅ <ø> (∅)
web3-eth ∅ <ø> (∅)
web3-eth-abi ∅ <ø> (∅)
web3-eth-accounts ∅ <ø> (∅)
web3-eth-contract ∅ <ø> (∅)
web3-eth-ens ∅ <ø> (∅)
web3-eth-iban ∅ <ø> (∅)
web3-eth-personal ∅ <ø> (∅)
web3-net ∅ <ø> (∅)
web3-providers-http ∅ <ø> (∅)
web3-providers-ipc ∅ <ø> (∅)
web3-providers-ws ∅ <ø> (∅)
web3-rpc-methods ∅ <ø> (∅)
web3-utils ∅ <ø> (∅)
web3-validator ∅ <ø> (∅)

@spacesailor24 spacesailor24 marked this pull request as ready for review June 13, 2023 20:59
Copy link
Contributor

@Muhammad-Altabba Muhammad-Altabba left a comment

Choose a reason for hiding this comment

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

Sounds good.
Just, please, consider the comments.
Thanks,

@@ -75,6 +75,27 @@ describe('contract errors', () => {
});
});

it('should catch Unauthorized error PromiEvent.on("error")', async () => {
const expectedThrownError = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be nice if we have this const expectedThrownError = {... above and we use it inside the 2 related test cases which related to the Unauthorized() error.

@@ -101,5 +122,27 @@ describe('contract errors', () => {
},
});
});

it('should catch error with parameter using PromiEvent.on("error")', async () => {
const expectedThrownError = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be nice if we have this const expectedThrownError = {... above and we use it inside the 2 related test cases which related to the CustomError error.

spacesailor24 and others added 3 commits June 20, 2023 05:52
…rrors.test.ts

Co-authored-by: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com>
…rrors.test.ts

Co-authored-by: Muhammad Altabba <24407834+Muhammad-Altabba@users.noreply.github.com>
@spacesailor24 spacesailor24 merged commit a2a232f into 4.x Jun 21, 2023
@spacesailor24 spacesailor24 deleted the wyatt/4.x/5670-contract-method-error-tests branch June 21, 2023 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants