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

Added unit tests for coin.js #1150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Rohan-Dah
Copy link

Line 52:
Each assertion here will throw an error if input type is not valid. For example, version must be a number

Line 61:
Here we are calculating number of confirmations for a transaction output based on current block height. In the case used here, if the coin height is 100 and current block height is 99, the depth should be 0. If the current block height is 101, the depth should be 2.

Line 77:
Here firstly a coin object is created with all the valid attributes such as version, height etc. It then converts the coin object to JSON format using .toJSON() and then creates new coin object by converting JSON back using .fromJSON. This makes sure serialization and deserialization functions are working properly.

Line 95:
Here we are creating a new coin object using the input object ‘options’. Here assert statements are checking if coin objects are having correct values for each property.

Line 52:
Each assertion here will throw an error if input type is not valid. For example, version must be a number

Line 61:
Here we are calculating number of confirmations for a transaction output based on current block height. In the case used here, if the coin height is 100 and current block height is 99, the depth should be 0. If the current block height is 101, the depth should be 2.

Line 77: 
Here firstly a coin object is created with all the valid attributes such as version, height etc. It then converts the coin object to JSON format using .toJSON() and then creates new coin object by converting JSON back using .fromJSON. This makes sure serialization and deserialization functions are working properly.

Line 95:
Here we are creating a new coin object using the input object ‘options’. Here assert statements are checking if coin objects are having correct values for each property.
@Rohan-Dah Rohan-Dah changed the title Added unit tests for coin,js Added unit tests for coin.js May 6, 2023
@masterchief164
Copy link
Collaborator

Please don't use the fromOptions method explicitly as that is supposed to be private. Instead use the constructor to pass values while instantiating the object.

Also please add all the field while writing assert.throws() like assert.throws(() => new Coin({ version: '1' }), assert.AssertionError, 'Version must be a uint32.');

@masterchief164
Copy link
Collaborator

The rest seems fine. Please fix the lining issue and please run the main and the linting tests once on your machine.

@Rohan-Dah
Copy link
Author

Rohan-Dah commented May 9, 2023 via email

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

Successfully merging this pull request may close these issues.

2 participants