Commit d58512e9 authored by ben-chain's avatar ben-chain

test structure in place

parent 203907a1
......@@ -6,13 +6,15 @@ import {
NON_NULL_BYTES32,
REVERT_FLAGS,
VERIFIED_EMPTY_CONTRACT_HASH,
NUISANCE_GAS_COSTS,
Helper_TestRunner_BYTELEN,
} from '../../../../helpers'
const DUMMY_REVERT_DATA =
'0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420'
const test_nuisanceGas: TestDefinition = {
name: 'Basic tests for ovmCALL',
name: 'Basic tests for nuisance gas',
preState: {
ExecutionManager: {
ovmStateManager: '$OVM_STATE_MANAGER',
......@@ -41,7 +43,7 @@ import {
},
subTests: [
{
name: 'Nuisance gas is consumed up to ovmCALL gas limit',
name: 'ovmCALL consumes nuisance gas of CODESIZE * NUISANCE_GAS_PER_CONTRACT_BYTE',
postState: {
ExecutionManager: {
messageRecord: {
......@@ -51,33 +53,15 @@ import {
},
parameters: [
{
name: 'ovmCALL => ovmCALL(evmINVALID)',
name: 'single ovmCALL',
focus: true,
steps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: GAS_LIMIT / 2,
target: '$DUMMY_OVM_ADDRESS_1',
subSteps: [
{
functionName: 'ovmCALL',
functionParams: {
gasLimit: GAS_LIMIT,
target: '$DUMMY_OVM_ADDRESS_2',
subSteps: [
{
functionName: 'evmINVALID',
}
]
},
expectedReturnStatus: true,
expectedReturnValue: {
ovmSuccess: false,
returnData: '0x'
}
},
],
target: '$DUMMY_OVM_ADDRESS_2',
subSteps: []
},
expectedReturnStatus: true,
},
......
......@@ -13,7 +13,8 @@ export const DEFAULT_ACCOUNTS_BUIDLER = defaultAccounts.map((account) => {
}
})
export const GAS_LIMIT = 1_000_000_000
export const GAS_LIMIT = 10_000_000
export const RUN_OVM_TEST_GAS = 20_000_000
export const NULL_BYTES32 = makeHexString('00', 32)
export const NON_NULL_BYTES32 = makeHexString('11', 32)
......@@ -22,3 +23,13 @@ export const NON_ZERO_ADDRESS = makeAddress('11')
export const VERIFIED_EMPTY_CONTRACT_HASH =
'0x00004B1DC0DE000000004B1DC0DE000000004B1DC0DE000000004B1DC0DE0000'
export const NUISANCE_GAS_COSTS = {
NUISANCE_GAS_SLOAD: 20000,
NUISANCE_GAS_SSTORE: 20000,
NUISANCE_GAS_PER_CONTRACT_BYTE: 100,
MIN_GAS_FOR_INVALID_STATE_ACCESS: 30000,
}
// TODO: get this exported/imported somehow in a way that we can do math on it. unfortunately using require('.....artifacts/contract.json') is erroring...
export const Helper_TestRunner_BYTELEN = 3686
\ No newline at end of file
......@@ -29,7 +29,7 @@ import {
} from './test.types'
import { encodeRevertData } from '../codec'
import { getModifiableStorageFactory } from '../storage/contract-storage'
import { GAS_LIMIT, NON_NULL_BYTES32 } from '../constants'
import { GAS_LIMIT, RUN_OVM_TEST_GAS, NON_NULL_BYTES32 } from '../constants'
export class ExecutionManagerTestRunner {
private snapshot: string
......@@ -216,16 +216,18 @@ export class ExecutionManagerTestRunner {
gasLimit: step.functionParams.gasLimit,
data: calldata,
},
this.contracts.OVM_StateManager.address
this.contracts.OVM_StateManager.address,
{ gasLimit: RUN_OVM_TEST_GAS}
)
} else {
await this.contracts.OVM_ExecutionManager.ovmCALL(
GAS_LIMIT / 2,
GAS_LIMIT,
this.contracts.Helper_TestRunner.address,
this.contracts.Helper_TestRunner.interface.encodeFunctionData(
'runSingleTestStep',
[this.parseTestStep(step)]
)
),
{ gasLimit: RUN_OVM_TEST_GAS}
)
}
}
......
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