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

Remove param address _facilitator from GatewayRedeemInterface.redeem and EIP20CoGateway.redeem #517

Conversation

gulshanvasnani
Copy link
Contributor

@gulshanvasnani gulshanvasnani commented Dec 5, 2018

Removed facilitator param from redeem method in GatewayRedeemInterface and EIP20CoGateway contracts.
Also,facilitator has been removed from redeem and stake struct.
It contains unit test-cases to test redeem method.
Burn method in utilitytoken is in sync with UtilityTokenInterface.
Fixes:- #475

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.

🙌 LGTM

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 👍
Just a few inline comments.

*
* @notice Used for test only.
*/
contract MockEIP20CoGateway 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.

Rename this as TestEIP20CoGateway, since it's not mocking the functions but uses addition functions to set data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This contract is removed.


/* Public functions */

function setOutboxStatus(bytes32 messageHash) public {
Copy link
Contributor

Choose a reason for hiding this comment

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

Documentation is missing.
We should also add a dev note why this function was needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
await utilityToken.approve(
eip20CoGateway.address,
new BN(1000),
{from: accounts[7]},
Copy link
Contributor

Choose a reason for hiding this comment

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

{from: accounts[7]} -> {form: staker}

test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
assert.strictEqual(
((await utilityToken.balanceOf(accounts[7])).cmp(
new BN(stakerBalance - amount))),
0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.


it('should deactivate if activated', async function () {

assert((await gateway.deactivateGateway.call({from: organisation})));
Copy link
Contributor

Choose a reason for hiding this comment

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

we can

  • split this to be more readable.
  • use assert.strictEqual.
  • add assert fail reason.

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 changes were introduced when i pulled the below branch to sync up :-
https://github.com/OpenSTFoundation/mosaic-contracts/pull/518/files

);
});

it('should deactivated by organization only', async function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

should fail to deactivated when the caller is not an organization address.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

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.

🐎 Almost done.
There are few tests missing.
Added inline comment for some cleanups.

contracts/gateway/EIP20CoGateway.sol Show resolved Hide resolved
contracts/gateway/EIP20CoGateway.sol Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved

});

});
Copy link
Contributor

Choose a reason for hiding this comment

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

newline at the end of the file.

I think there can be more test cases.

  • should fail when the coGateway is not approved
  • should fail when the redeemer has balance less than the bounty amount
  • should fail when the redeemer balance is less than the redeem amount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you.
I have added all the above test-cases.

test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
@@ -957,19 +948,19 @@ contract EIP20CoGateway is GatewayBase {
require(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't test this condition.
Please recommend how to test it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think that moving this condition to line 920 makes sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have moved it at 920 line number.

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 🙌 🚀

This is almost done. Few comments inline.

contracts/gateway/GatewayRedeemInterface.sol Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js 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.

LGTM 🚀⚡️🌀 🎊
Nice work 🙌

There 2 changes required in unit test cases:

  1. should fail when the redeemer 's base token balance is less than the bounty amount : This should assert this "Payable amount should be equal to the bounty amount."

  2. Please add this test : should fail if the previous process is in revocation declared state

test/gateway/eip20_cogateway/redeem.js 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.

Thank you for adding test cases. Redeem test cases really looks good to me. 🥇 💯 👍

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.

Just few comments, it will be good to go.

@@ -957,19 +948,19 @@ contract EIP20CoGateway is GatewayBase {
require(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think that moving this condition to line 920 makes sense?

contracts/test/TestEIP20CoGateway.sol 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
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved

it('should fail when cogateway is not approved with redeem amount', async function () {

let testEIP20CoGateway2 = await TestEIP20CoGateway.new(
Copy link
Contributor

Choose a reason for hiding this comment

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

Why create a new object?
This can be done in 2 ways:

  • Change the redeemer address.
  • Increase the redeem amount.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you.
I have increased the amount.

test/gateway/eip20_cogateway/redeem.js Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.js Outdated Show resolved Hide resolved
test/gateway/eip20_cogateway/redeem.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 ✈️

@deepesh-kn deepesh-kn merged commit 84ae349 into OpenST:develop Dec 13, 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