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
3013627d
Commit
3013627d
authored
Sep 21, 2020
by
ben-chain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start adding back
parent
69b705fd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
424 additions
and
10 deletions
+424
-10
package.json
packages/contracts/package.json
+1
-1
context-opcodes.spec.ts
...VM/execution/OVM_ExecutionManager/context-opcodes.spec.ts
+148
-0
nuisance-gas.spec.ts
...s/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts
+272
-0
test-runner.ts
packages/contracts/test/helpers/test-utils/test-runner.ts
+3
-9
No files found.
packages/contracts/package.json
View file @
3013627d
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
"build"
:
"yarn run build:contracts"
,
"build"
:
"yarn run build:contracts"
,
"build:contracts"
:
"buidler compile"
,
"build:contracts"
:
"buidler compile"
,
"test"
:
"yarn run test:contracts"
,
"test"
:
"yarn run test:contracts"
,
"test:contracts"
:
"buidler test
\"
test/contracts/OVM/execution/OVM_ExecutionManager/
run
.spec.ts
\"
"
,
"test:contracts"
:
"buidler test
\"
test/contracts/OVM/execution/OVM_ExecutionManager/
nuisance-gas
.spec.ts
\"
"
,
"lint"
:
"tslint --format stylish --project ."
,
"lint"
:
"tslint --format stylish --project ."
,
"fix"
:
"prettier --config prettier-config.json --write
\"
buidler.config.ts
\"
\"
{src,test}/**/*.ts
\"
"
"fix"
:
"prettier --config prettier-config.json --write
\"
buidler.config.ts
\"
\"
{src,test}/**/*.ts
\"
"
},
},
...
...
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/context-opcodes.spec.ts
0 → 100644
View file @
3013627d
/* Internal Imports */
import
{
runExecutionManagerTest
,
TestDefinition
,
GAS_LIMIT
,
NULL_BYTES32
,
NON_NULL_BYTES32
,
REVERT_FLAGS
,
DUMMY_BYTECODE
,
}
from
'
../../../../helpers
'
const
globalContext
=
{
ovmCHAINID
:
420
}
const
transactionContext
=
{
ovmTIMESTAMP
:
12341234
,
ovmGASLIMIT
:
45674567
,
ovmTXGASLIMIT
:
78907890
,
ovmL1QUEUEORIGIN
:
1
,
ovmL1TXORIGIN
:
'
0x1234123412341234123412341234123412341234
'
}
const
messageContext
=
{
ovmCALLER
:
'
0x6789678967896789678967896789678967896789
'
,
ovmADDRESS
:
'
0x4567456745674567456745674567456745674567
'
}
const
test_ovmContextOpcodes
:
TestDefinition
=
{
name
:
'
unit tests for basic getter opcodes
'
,
preState
:
{
ExecutionManager
:
{
globalContext
,
transactionContext
,
messageContext
},
},
parameters
:
[
{
name
:
'
gets ovmCALLER
'
,
parameters
:
[
{
steps
:
[
{
functionName
:
'
ovmCALLER
'
,
functionParams
:
[],
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
messageContext
.
ovmCALLER
]
}
],
},
],
},
{
name
:
'
gets ovmADDRESS
'
,
parameters
:
[
{
steps
:
[
{
functionName
:
'
ovmADDRESS
'
,
functionParams
:
[],
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
messageContext
.
ovmADDRESS
]
}
],
},
],
},
{
name
:
'
gets ovmTIMESTAMP
'
,
parameters
:
[
{
steps
:
[
{
functionName
:
'
ovmTIMESTAMP
'
,
functionParams
:
[],
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
transactionContext
.
ovmTIMESTAMP
]
}
],
},
],
},
{
name
:
'
gets ovmGASLIMIT
'
,
parameters
:
[
{
steps
:
[
{
functionName
:
'
ovmGASLIMIT
'
,
functionParams
:
[],
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
transactionContext
.
ovmGASLIMIT
]
}
],
},
],
},
{
name
:
'
gets ovmQUEUEORIGIN
'
,
parameters
:
[
{
steps
:
[
{
functionName
:
'
ovmL1QUEUEORIGIN
'
,
functionParams
:
[],
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
transactionContext
.
ovmL1QUEUEORIGIN
]
}
],
},
],
},
{
name
:
'
gets ovmL1TXORIGIN
'
,
parameters
:
[
{
steps
:
[
{
functionName
:
'
ovmL1TXORIGIN
'
,
functionParams
:
[],
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
transactionContext
.
ovmL1TXORIGIN
]
}
],
},
],
},
{
name
:
'
gets ovmCHAINID
'
,
parameters
:
[
{
steps
:
[
{
functionName
:
'
ovmCHAINID
'
,
functionParams
:
[],
expectedReturnStatus
:
true
,
expectedReturnValues
:
[
globalContext
.
ovmCHAINID
]
}
],
},
],
},
],
}
runExecutionManagerTest
(
test_ovmContextOpcodes
)
\ No newline at end of file
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/nuisance-gas.spec.ts
0 → 100644
View file @
3013627d
/* Internal Imports */
import
{
ExecutionManagerTestRunner
,
TestDefinition
,
GAS_LIMIT
,
NON_NULL_BYTES32
,
REVERT_FLAGS
,
VERIFIED_EMPTY_CONTRACT_HASH
,
}
from
'
../../../../helpers
'
const
DUMMY_REVERT_DATA
=
'
0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420
'
const
test_nuisanceGas
:
TestDefinition
=
{
name
:
'
Basic tests for ovmCALL
'
,
preState
:
{
ExecutionManager
:
{
ovmStateManager
:
'
$OVM_STATE_MANAGER
'
,
ovmSafetyChecker
:
'
$OVM_SAFETY_CHECKER
'
,
messageRecord
:
{
nuisanceGasLeft
:
GAS_LIMIT
,
},
},
StateManager
:
{
owner
:
'
$OVM_EXECUTION_MANAGER
'
,
accounts
:
{
$DUMMY_OVM_ADDRESS_1
:
{
codeHash
:
NON_NULL_BYTES32
,
ethAddress
:
'
$OVM_CALL_HELPER
'
,
},
$DUMMY_OVM_ADDRESS_2
:
{
codeHash
:
NON_NULL_BYTES32
,
ethAddress
:
'
$OVM_CALL_HELPER
'
,
},
$DUMMY_OVM_ADDRESS_3
:
{
codeHash
:
VERIFIED_EMPTY_CONTRACT_HASH
,
ethAddress
:
'
0x
'
+
'
00
'
.
repeat
(
20
),
},
},
},
},
subTests
:
[
{
name
:
'
Nuisance gas is consumed up to ovmCALL gas limit
'
,
postState
:
{
ExecutionManager
:
{
messageRecord
:
{
nuisanceGasLeft
:
GAS_LIMIT
/
2
}
}
},
parameters
:
[
{
name
:
'
ovmCALL => ovmCALL(evmINVALID)
'
,
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
'
}
},
],
},
expectedReturnStatus
:
true
,
},
],
}
]
}
],
parameters
:
[
{
name
:
'
ovmCALL(ADDRESS_1) => ovmSSTORE
'
,
steps
:
[
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_1
'
,
subSteps
:
[
{
functionName
:
'
ovmSSTORE
'
,
functionParams
:
{
key
:
NON_NULL_BYTES32
,
value
:
NON_NULL_BYTES32
,
},
expectedReturnStatus
:
true
,
},
],
},
expectedReturnStatus
:
true
,
},
],
},
{
name
:
'
ovmCALL(ADDRESS_1) => ovmSSTORE + ovmSLOAD, ovmCALL(ADDRESS_1) => ovmSLOAD
'
,
steps
:
[
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_1
'
,
subSteps
:
[
{
functionName
:
'
ovmSSTORE
'
,
functionParams
:
{
key
:
NON_NULL_BYTES32
,
value
:
NON_NULL_BYTES32
,
},
expectedReturnStatus
:
true
,
},
{
functionName
:
'
ovmSLOAD
'
,
functionParams
:
{
key
:
NON_NULL_BYTES32
,
},
expectedReturnStatus
:
true
,
expectedReturnValue
:
NON_NULL_BYTES32
,
},
],
},
expectedReturnStatus
:
true
,
},
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_1
'
,
subSteps
:
[
{
functionName
:
'
ovmSLOAD
'
,
functionParams
:
{
key
:
NON_NULL_BYTES32
,
},
expectedReturnStatus
:
true
,
expectedReturnValue
:
NON_NULL_BYTES32
,
},
],
},
expectedReturnStatus
:
true
,
},
],
},
{
name
:
'
ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmADDRESS + ovmCALLER
'
,
steps
:
[
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_1
'
,
subSteps
:
[
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_2
'
,
subSteps
:
[
{
functionName
:
'
ovmADDRESS
'
,
expectedReturnValue
:
'
$DUMMY_OVM_ADDRESS_2
'
,
},
{
functionName
:
'
ovmCALLER
'
,
expectedReturnValue
:
'
$DUMMY_OVM_ADDRESS_1
'
,
},
],
},
expectedReturnStatus
:
true
,
},
],
},
expectedReturnStatus
:
true
,
},
],
},
{
name
:
'
ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_3)
'
,
steps
:
[
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_1
'
,
subSteps
:
[
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_3
'
,
calldata
:
'
0x
'
,
},
expectedReturnStatus
:
true
,
},
],
},
expectedReturnStatus
:
true
,
expectedReturnValue
:
'
0x
'
,
},
],
},
{
name
:
'
ovmCALL(ADDRESS_1) => INTENTIONAL_REVERT
'
,
steps
:
[
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_1
'
,
subSteps
:
[
{
functionName
:
'
evmREVERT
'
,
returnData
:
{
flag
:
REVERT_FLAGS
.
INTENTIONAL_REVERT
,
data
:
DUMMY_REVERT_DATA
,
},
},
],
},
expectedReturnStatus
:
false
,
expectedReturnValue
:
DUMMY_REVERT_DATA
,
},
],
},
{
name
:
'
ovmCALL(ADDRESS_1) => EXCEEDS_NUISANCE_GAS
'
,
steps
:
[
{
functionName
:
'
ovmCALL
'
,
functionParams
:
{
gasLimit
:
GAS_LIMIT
,
target
:
'
$DUMMY_OVM_ADDRESS_1
'
,
subSteps
:
[
{
functionName
:
'
evmREVERT
'
,
returnData
:
{
flag
:
REVERT_FLAGS
.
EXCEEDS_NUISANCE_GAS
,
},
},
],
},
expectedReturnStatus
:
false
,
expectedReturnValue
:
'
0x
'
,
},
],
},
],
}
const
runner
=
new
ExecutionManagerTestRunner
()
runner
.
run
(
test_nuisanceGas
)
\ No newline at end of file
packages/contracts/test/helpers/test-utils/test-runner.ts
View file @
3013627d
...
@@ -3,7 +3,7 @@ import { expect } from '../../setup'
...
@@ -3,7 +3,7 @@ import { expect } from '../../setup'
/* External Imports */
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
,
BigNumber
,
ContractFactory
}
from
'
ethers
'
import
{
Contract
,
BigNumber
,
ContractFactory
}
from
'
ethers
'
import
{
cloneDeep
}
from
'
lodash
'
import
{
cloneDeep
,
merge
}
from
'
lodash
'
/* Internal Imports */
/* Internal Imports */
import
{
import
{
...
@@ -55,14 +55,8 @@ export class ExecutionManagerTestRunner {
...
@@ -55,14 +55,8 @@ export class ExecutionManagerTestRunner {
test
.
subTests
?.
map
((
subTest
)
=>
{
test
.
subTests
?.
map
((
subTest
)
=>
{
this
.
run
({
this
.
run
({
...
subTest
,
...
subTest
,
preState
:
{
preState
:
merge
(
cloneDeep
(
test
.
preState
),
cloneDeep
(
subTest
.
preState
)),
...
test
.
preState
,
postState
:
merge
(
cloneDeep
(
test
.
postState
),
cloneDeep
(
subTest
.
postState
))
...
subTest
.
preState
,
},
postState
:
{
...
test
.
postState
,
...
subTest
.
postState
,
},
})
})
})
})
...
...
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