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

Reward calculation clean up for zero gas. #527

Conversation

gulshanvasnani
Copy link
Contributor

@gulshanvasnani gulshanvasnani commented Dec 6, 2018

Modified progressMintInternal method of EIP20CoGateway to not transfer reward to facilitator if reward is 0.
Unit test-cases to verify mint was called are also added.

Fixes #495
Fixes #433

Copy link
Contributor

@schemar schemar left a comment

Choose a reason for hiding this comment

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

Nice 🎆
A test would be nice. You could use a "spy" or similar to see when mint is called and when it is not called.

Copy link
Contributor

@deepesh-kn deepesh-kn left a comment

Choose a reason for hiding this comment

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

Nice👍
I just have a suggestion see inline.
Tests are missing.
Also please document your finding of the points mentioned in the #495

contracts/gateway/EIP20CoGateway.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@0xsarvesh 0xsarvesh left a comment

Choose a reason for hiding this comment

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

Nice 🙌
Few comments inline.
Also, it seems you are testing progressMint not progressMintInternal. Please add remaining test cases for progressMint

contracts/gateway/EIP20CoGateway.sol Show resolved Hide resolved
contracts/test/MockUtilityToken.sol Outdated Show resolved Hide resolved
contracts/test/TestEIP20CoGateway.sol Outdated Show resolved Hide resolved
contracts/test/TestEIP20CoGateway.sol Outdated Show resolved Hide resolved
contracts/test/TestEIP20CoGateway.sol Outdated Show resolved Hide resolved
contracts/test/TestEIP20CoGateway.sol Outdated Show resolved Hide resolved
contracts/test/MockUtilityToken.sol Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint_internal.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint_internal.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint_internal.js Outdated Show resolved Hide resolved
Copy link
Contributor

@schemar schemar left a comment

Choose a reason for hiding this comment

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

I added some comments in-line. I don't have the required knowledge to approve this PR. Summoning @deepesh-kn and @sarvesh-ost

contracts/gateway/EIP20Gateway.sol Show resolved Hide resolved
* @notice This is for testing purpose.
*
*/
contract MockUtilityToken is UtilityToken {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call this a spy and not a mock?

/cc @deepesh-kn @sarvesh-ost

Should we clean up our test doubles naming in a separate ticket?

Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, it should not be MockUtilityToken. For such a case, we use TestUtilityToken.
Mock... is to completely mock a contract. Test.. is to Test the existing contract and has some way to set data (for testing)

contracts/test/TestEIP20CoGateway.sol Outdated Show resolved Hide resolved
*
* @notice This is used for testing purpose.
*/
contract TestEIP20CoGateway is EIP20CoGateway {
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we currently differentiate between Test... and Mock...?

/cc @deepesh-kn @sarvesh-ost

Copy link
Contributor

Choose a reason for hiding this comment

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

Mock... is to completely mock a contract.
Test.. is to test existing contract function, and has some functions to set data (for testing)

test/gateway/eip20_cogateway/helpers/helper.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/helpers/helper.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
symbol = "OST",
name = "Simple Token",
decimals = 18,
helper;
Copy link
Contributor

Choose a reason for hiding this comment

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

The length of these declarations looks unhealthy. Did we mess up with the architecture?

Copy link
Contributor Author

@gulshanvasnani gulshanvasnani Dec 17, 2018

Choose a reason for hiding this comment

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

Is it fine to keep these declarations as of now ? Do you have any strong opinion against it.
This makes writing the tests easy.

test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
Copy link
Contributor

@deepesh-kn deepesh-kn left a comment

Choose a reason for hiding this comment

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

🍷 nice.
Almost complete. Few tests are missing.

contracts/gateway/EIP20Gateway.sol Show resolved Hide resolved
contracts/test/MockUtilityToken.sol Outdated Show resolved Hide resolved
contracts/test/MockUtilityToken.sol Outdated Show resolved Hide resolved
* @notice This is for testing purpose.
*
*/
contract MockUtilityToken is UtilityToken {
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, it should not be MockUtilityToken. For such a case, we use TestUtilityToken.
Mock... is to completely mock a contract. Test.. is to Test the existing contract and has some way to set data (for testing)

)
public
UtilityToken(_symbol, _name, _decimals, _valueToken)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

{ }

test/gateway/eip20_cogateway/helpers/helper.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
Copy link
Contributor

@deepesh-kn deepesh-kn left a comment

Choose a reason for hiding this comment

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

LGTM 🛫
@sarvesh-ost, please to go through the tests once.

Copy link
Contributor

@0xsarvesh 0xsarvesh left a comment

Choose a reason for hiding this comment

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

Nice, almost done. 🙌 🥇

Some feedbacks inline.

There should be supporting unit test cases for reward calculation, as progressMint calculates reward as well.

test/gateway/eip20_cogateway/helpers/helper.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/helpers/helper.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/progress_mint.js Outdated Show resolved Hide resolved
@gulshanvasnani gulshanvasnani force-pushed the gulshan/gh_495_reward_calculation_cleanup_zero_gas branch from c57443c to b167ec9 Compare December 18, 2018 17:33
Copy link
Contributor

@0xsarvesh 0xsarvesh left a comment

Choose a reason for hiding this comment

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

LGTM 🎉 💯

@0xsarvesh 0xsarvesh merged commit f50b058 into OpenST:develop Dec 19, 2018
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.

5 participants