Use bytes32 explicitly for Create2.computeAddress() (#2088)

* Use bytes32 explicitly for Create2.computeAddress(), to force users cache hash of the bytecode

* Remove only from test :)
This commit is contained in:
Anton Bukov
2020-03-09 19:02:14 +03:00
committed by GitHub
parent ca19cea05e
commit e2813df879
3 changed files with 8 additions and 30 deletions

View File

@ -22,7 +22,7 @@ describe('Create2', function () {
it('should compute the correct contract address', async function () {
const onChainComputed = await this.factory
.computeAddress(saltHex, constructorByteCode);
.computeAddress(saltHex, web3.utils.keccak256(constructorByteCode));
const offChainComputed =
computeCreate2Address(saltHex, constructorByteCode, this.factory.address);
expect(onChainComputed).to.equal(offChainComputed);
@ -30,17 +30,7 @@ describe('Create2', function () {
it('should compute the correct contract address with deployer', async function () {
const onChainComputed = await this.factory
.methods['computeAddress(bytes32,bytes,address)'](saltHex, constructorByteCode, deployerAccount);
const offChainComputed =
computeCreate2Address(saltHex, constructorByteCode, deployerAccount);
expect(onChainComputed).to.equal(offChainComputed);
});
it('should compute the correct contract address with deployer and bytecode hash', async function () {
const onChainComputed = await this.factory
.methods['computeAddress(bytes32,bytes32,address)'](
saltHex, web3.utils.keccak256(constructorByteCode), deployerAccount
);
.computeAddressWithDeployer(saltHex, web3.utils.keccak256(constructorByteCode), deployerAccount);
const offChainComputed =
computeCreate2Address(saltHex, constructorByteCode, deployerAccount);
expect(onChainComputed).to.equal(offChainComputed);