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

Unit test cases for progressStakeWithProof #578

Merged
merged 10 commits into from
Jan 18, 2019
Merged

Conversation

deepesh-kn
Copy link
Contributor

This PR includes the unit test for EIP20Gateway.progressStakeWithProof.
The proof data is added.
fixes: #424

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 🎊

Please see questions/remarks in-line.

test/gateway/eip20_gateway/progress_stake_with_proof.js Outdated Show resolved Hide resolved
gasLimit: new BN(stakeParams.gasLimit, 16),
nonce: new BN(stakeParams.nonce, 16),
hashLock: stakeParams.hashLock,
messageHash: proofData.gateway.stake.return_value.returned_value.messageHash_,
Copy link
Contributor

Choose a reason for hiding this comment

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

That's deep 😳

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, any suggestion?
I can store the values in some variable in before each.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would just move the deepness somewhere else. I don't know how to solve this, I don't know the scope of proof data.

test/gateway/eip20_gateway/progress_stake_with_proof.js Outdated Show resolved Hide resolved
test/gateway/eip20_gateway/progress_stake_with_proof.js Outdated Show resolved Hide resolved
test/gateway/eip20_gateway/progress_stake_with_proof.js Outdated Show resolved Hide resolved
test/gateway/eip20_gateway/progress_stake_with_proof.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.

Nice work 🏇 🙌
Few comments inline.
Please add a test for message bus for below scenario.
It should progress outbox if the target message is progressed and source message status is revocation declared

redeemer_ = message.sender;
redeemerNonce_ = message.nonce;
amount_ = unstakes[_messageHash].amount;

// delete the unstake data
delete unstakes[_messageHash];
Copy link
Contributor

Choose a reason for hiding this comment

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

General question, we delete stakes/unstakes mapping in progress/progressRevert, but not message mapping. Messages are deleted when new messages are created. why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After progress and revert you may not be able to do anything with stakes/unstakes mapping else so its deleted. Message state is not deleted because it may be used for merkle proof.

But in fact, I am thinking not to delete the message state.

  1. Stake
  2. ConfirmStake
  3. ProgressMintWithProof. (deletes the mints stuct data, the proof was not generated)
  4. redeem (deletes the message status)
  5. ProgressStakeWithProof (Now the proof will not be generated.)

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand we can't clean message status mapping and it has valid reason.
My point was for message mapping. Messages can be deleted with stake, mint, redeem and unstakes mapping.

If you and @schemar agree on this, seperate ticket can be created for this.

contracts/lib/MessageBus.sol Show resolved Hide resolved
test/gateway/eip20_gateway/progress_stake_with_proof.js Outdated Show resolved Hide resolved

});

it('should fail when storage proof is invalid', 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.

I dont think this test is needed. This test is asserting failure of RLP library which is out of scope of this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As progressStakeWithProof is not an ideal unit test. It has integration with messagebus library and gatewayLib, I am considering all this as one unit. I would prefer to keep this.

test/gateway/eip20_gateway/progress_stake_with_proof.js Outdated Show resolved Hide resolved
test/gateway/eip20_gateway/progress_stake_with_proof.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.

LGTM, only @sarvesh-ost 's comments remaining. 🎇

@deepesh-kn
Copy link
Contributor Author

Please add a test for message bus for below scenario.
It should progress outbox if the target message is progressed and source message status is revocation declared

This will be coved in #526

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.

Almost ⚡️ 🗿
Some feedbacks and open conversation pending.

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 d3f6094 into OpenST:develop Jan 18, 2019
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.

Gateway: Unit test for EIP20Gateway progressStakingWithProof()
3 participants