-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Add ECRecoveryMock contract #635
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
Add ECRecoveryMock contract #635
Conversation
d0e3069
to
664c4d3
Compare
test/ECRecovery.test.js
Outdated
// 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()); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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!
There was a problem hiding this 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
test/ECRecovery.test.js
Outdated
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')); |
There was a problem hiding this comment.
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'
test/ECRecovery.test.js
Outdated
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. |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
although it looks like it needs a merge/rebase to get up to date |
774f433
to
c73861d
Compare
@shrugs rebased with master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add ECRecoveryMock contract
Add a mock contract to tests the ECRecovery lib as an extension of
bytes32
variables using: