Commit cc209be1 authored by Maurelian's avatar Maurelian Committed by GitHub

test(contracts): easily set storageXOR values in prestate (#879)

parent 5b7e13c6
...@@ -37,7 +37,7 @@ import { ...@@ -37,7 +37,7 @@ import {
} from '../constants' } from '../constants'
import { getStorageXOR } from '../' import { getStorageXOR } from '../'
import { UNSAFE_BYTECODE } from '../dummy' import { UNSAFE_BYTECODE } from '../dummy'
import { getContractFactory } from '../../../src' import { getContractFactory, predeploys } from '../../../src'
export class ExecutionManagerTestRunner { export class ExecutionManagerTestRunner {
private snapshot: string private snapshot: string
...@@ -64,24 +64,25 @@ export class ExecutionManagerTestRunner { ...@@ -64,24 +64,25 @@ export class ExecutionManagerTestRunner {
StateManager: { StateManager: {
owner: '$OVM_EXECUTION_MANAGER', owner: '$OVM_EXECUTION_MANAGER',
accounts: { accounts: {
['0x4200000000000000000000000000000000000002']: { [predeploys.OVM_DeployerWhitelist]: {
codeHash: NON_NULL_BYTES32, codeHash: NON_NULL_BYTES32,
ethAddress: '$OVM_DEPLOYER_WHITELIST', ethAddress: '$OVM_DEPLOYER_WHITELIST',
}, },
['0x4200000000000000000000000000000000000009']: { [predeploys.OVM_ProxyEOA]: {
codeHash: NON_NULL_BYTES32, codeHash: NON_NULL_BYTES32,
ethAddress: '$OVM_PROXY_EOA', ethAddress: '$OVM_PROXY_EOA',
}, },
}, },
contractStorage: { contractStorage: {
['0x4200000000000000000000000000000000000002']: { [predeploys.OVM_DeployerWhitelist]: {
'0x0000000000000000000000000000000000000000000000000000000000000000': getStorageXOR( '0x0000000000000000000000000000000000000000000000000000000000000000': {
ethers.constants.HashZero getStorageXOR: true,
), value: ethers.constants.HashZero,
},
}, },
}, },
verifiedContractStorage: { verifiedContractStorage: {
['0x4200000000000000000000000000000000000002']: { [predeploys.OVM_DeployerWhitelist]: {
'0x0000000000000000000000000000000000000000000000000000000000000000': true, '0x0000000000000000000000000000000000000000000000000000000000000000': true,
}, },
}, },
...@@ -296,6 +297,14 @@ export class ExecutionManagerTestRunner { ...@@ -296,6 +297,14 @@ export class ExecutionManagerTestRunner {
return this.setPlaceholderStrings(element) return this.setPlaceholderStrings(element)
}) })
} else if (typeof ret === 'object' && ret !== null) { } else if (typeof ret === 'object' && ret !== null) {
if (ret.getStorageXOR) {
// Special case allowing us to set prestate with an object which will be
// padded to 32 bytes and XORd with STORAGE_XOR_VALUE
return getStorageXOR(
ethers.utils.hexZeroPad(getReplacementString(ret.value), 32)
)
}
for (const key of Object.keys(ret)) { for (const key of Object.keys(ret)) {
const replacedKey = getReplacementString(key) const replacedKey = getReplacementString(key)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment