Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Conversation

@nazarhussain
Copy link
Contributor

Description

Fixes #5130

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
  • I ran npm run test:cov and my test cases cover all the lines and branches of the added code.
  • I ran npm run build with success.
  • I have tested the built dist/web3.min.js in a browser.
  • I have tested my code on the live network.
  • I have checked the Deploy Preview and it looks correct.
  • I have updated the CHANGELOG.md file in the root folder.

@nazarhussain nazarhussain self-assigned this Jun 16, 2022
@nazarhussain nazarhussain added the 4.x 4.0 related label Jun 16, 2022
@nazarhussain nazarhussain linked an issue Jun 16, 2022 that may be closed by this pull request
13 tasks
@nazarhussain nazarhussain force-pushed the nh/5125-optional-constructor branch from 8634f35 to d7a9d08 Compare June 16, 2022 10:49
Base automatically changed from nh/5128-default-return-type to 4.x June 21, 2022 20:42
Copy link
Contributor

@jdevcs jdevcs left a comment

Choose a reason for hiding this comment

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

Also need to fix tests in CI

it('should be able use functionality with web3 object not dependant on provider', () => {
web3 = new Web3();

expect(web3.utils.hexToNumber('0x5')).toBe(5);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems ok, but I was thinking we should have test that goes through multiple scenarios without provider. Like we should add ABI encoding without provider :

  const web3 = new Web3();
  const contract = new web3.eth.Contract(ContractABI);
   await contract.methods.Func(12).encodeABI(); // and see it works

This will cover more scenarios, web3 instance creation, contract instance creation, encoding etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Such behaviour is better candidate for unit tests, not the integration. I had added one test case though in the integration tests.

Copy link
Contributor

@jdevcs jdevcs Jun 22, 2022

Choose a reason for hiding this comment

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

Only encoding param can be yes, but for scenarios that involve multiple packages, integration tests are more good. like abi encoding for eth_call of specific function of contract without provider or creating tx and offline signing etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These functions pure functions, have no dependency on any related code that can effect the behavior. So these functions can be better tested in unit tests with all possible input/output. If those functions had any state which are preserved in the class then we would have gone for integration tests.

@nazarhussain nazarhussain merged commit 80b07dd into 4.x Jun 22, 2022
@nazarhussain nazarhussain deleted the nh/5125-optional-constructor branch June 22, 2022 12:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

4.x 4.0 related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improvements to make 4.x compatible with different projects

5 participants