Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
d58512e9
Commit
d58512e9
authored
Sep 21, 2020
by
ben-chain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test structure in place
parent
203907a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
28 deletions
+25
-28
nuisance-gas.spec.ts
...s/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts
+7
-23
constants.ts
packages/contracts/test/helpers/constants.ts
+12
-1
test-runner.ts
packages/contracts/test/helpers/test-utils/test-runner.ts
+6
-4
No files found.
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts
View file @
d58512e9
...
...
@@ -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
,
},
...
...
packages/contracts/test/helpers/constants.ts
View file @
d58512e9
...
...
@@ -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
packages/contracts/test/helpers/test-utils/test-runner.ts
View file @
d58512e9
...
...
@@ -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
}
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment