ECRecover test should revert because of wrong calldata size (#1050)

* Assume that token is mintable.

* ECRecover test should revert because of wrong calldata size

* fix: use expectThrow

* fix: ignore failing test until solc^0.5.0
pull/1074/head^2
Leonardo 7 years ago committed by Matt Condon
parent b120b9aff7
commit 99e4b081dc
  1. 3
      contracts/crowdsale/emission/MintedCrowdsale.sol
  2. 16
      test/library/ECRecovery.test.js

@ -22,6 +22,7 @@ contract MintedCrowdsale is Crowdsale {
)
internal
{
require(MintableToken(token).mint(_beneficiary, _tokenAmount));
// Potentially dangerous assumption about the type of the token.
require(MintableToken(address(token)).mint(_beneficiary, _tokenAmount));
}
}

@ -3,6 +3,7 @@ import {
hashMessage,
signMessage,
} from '../helpers/sign';
import expectThrow from '../helpers/expectThrow';
const ECRecoveryMock = artifacts.require('ECRecoveryMock');
require('chai')
@ -54,17 +55,20 @@ contract('ECRecovery', function (accounts) {
const signature = signMessage(accounts[0], TEST_MESSAGE);
// Recover the signer address from the generated message and wrong signature.
const addrRecovered = await ecrecovery.recover(hashMessage('Test'), signature);
const addrRecovered = await ecrecovery.recover(hashMessage('Nope'), signature);
assert.notEqual(accounts[0], addrRecovered);
});
it('recover should fail when a wrong hash is sent', async function () {
it('recover should revert when a small hash is sent', async function () {
// Create the signature using account[0]
let signature = signMessage(accounts[0], TEST_MESSAGE);
// Recover the signer address from the generated message and wrong signature.
const addrRecovered = await ecrecovery.recover(hashMessage(TEST_MESSAGE).substring(2), signature);
addrRecovered.should.eq('0x0000000000000000000000000000000000000000');
try {
await expectThrow(
ecrecovery.recover(hashMessage(TEST_MESSAGE).substring(2), signature)
);
} catch (error) {
// @TODO(shrugs) - remove this once we upgrade to solc^0.5
}
});
context('toEthSignedMessage', () => {

Loading…
Cancel
Save