Skip to content

Conversation

AugustoL
Copy link
Contributor

@AugustoL AugustoL commented Jan 2, 2018

Add a mock contract to tests the ECRecovery lib as an extension of bytes32 variables using:

using ECRecovery for bytes32;

@AugustoL AugustoL added the tests label Jan 2, 2018
@AugustoL AugustoL self-assigned this Jan 2, 2018
@AugustoL AugustoL force-pushed the test/ECRecoveryMock branch from d0e3069 to 664c4d3 Compare January 2, 2018 20:01
// Recover the signer address form the generated message and wrong signature.
assert.notEqual(web3.eth.accounts[0], await ecrecovery.recover(hashMessage('Test'), signature));
await ecrecovery.recover(hashMessage('Test'), signature);
assert.notEqual(web3.eth.accounts[0], await ecrecovery.addrRecovered());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Maybe better to use accounts rather than web3.eth.accounts?

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! it should be accounts, my bad, changing it!

Copy link
Contributor

@shrugs shrugs left a comment

Choose a reason for hiding this comment

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

just some nitpicks, otherwise LGTM

it('recover using web3.eth.sign()', async function () {
// Create the signature using account[0]
const signature = web3.eth.sign(web3.eth.accounts[0], web3.sha3('OpenZeppelin'));
const signature = web3.eth.sign(accounts[0], web3.sha3('OpenZeppelin'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we replace this magic string ("OpenZeppelin") with a constant defined at the top of the file?

const TEST_MESSAGE = 'OpenZeppelin'

const signature = web3.eth.sign(web3.eth.accounts[0], web3.sha3('OpenZeppelin'));
const signature = web3.eth.sign(accounts[0], web3.sha3('OpenZeppelin'));

// Recover the signer address form the generated message and signature.
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: can we update these typos while we're at it? namely form to from both here and in other places in this file. I know that's annoying, but it'd be appreciated :D

shrugs
shrugs previously approved these changes Jan 4, 2018
Copy link
Contributor

@shrugs shrugs left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@shrugs
Copy link
Contributor

shrugs commented Jan 4, 2018

although it looks like it needs a merge/rebase to get up to date

@AugustoL
Copy link
Contributor Author

AugustoL commented Jan 4, 2018

@shrugs rebased with master

shrugs
shrugs previously approved these changes Jan 4, 2018
@shrugs shrugs added next and removed next labels Jan 4, 2018
Copy link
Contributor

@federicobond federicobond left a comment

Choose a reason for hiding this comment

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

LGTM

@federicobond federicobond merged commit 6af6efc into OpenZeppelin:master Jan 5, 2018
@AugustoL AugustoL removed the review label Jan 5, 2018
@AugustoL AugustoL deleted the test/ECRecoveryMock branch January 5, 2018 17:35
ProphetDaniel pushed a commit to classicdelta/Smart-Contracts that referenced this pull request Mar 9, 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