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
82390b3a
Commit
82390b3a
authored
Sep 23, 2020
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Linting and storage mod cleanup
parent
a7760482
Changes
26
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
231 additions
and
267 deletions
+231
-267
.gitignore
packages/contracts/.gitignore
+1
-0
package.json
packages/contracts/package.json
+2
-1
run.spec.ts
.../contracts/OVM/execution/OVM_ExecutionManager/run.spec.ts
+0
-3
OVM_SafetyChecker.spec.ts
...ts/test/contracts/OVM/execution/OVM_SafetyChecker.spec.ts
+1
-1
index.ts
packages/contracts/test/data/index.ts
+0
-0
create2.test.json
packages/contracts/test/data/json/create2.test.json
+0
-0
rlp.test.json
packages/contracts/test/data/json/rlp.test.json
+0
-0
safety-checker.test.json
packages/contracts/test/data/json/safety-checker.test.json
+0
-0
revert-flags.ts
packages/contracts/test/helpers/codec/revert-flags.ts
+1
-3
constants.ts
packages/contracts/test/helpers/constants.ts
+1
-1
accounts.ts
packages/contracts/test/helpers/dummy/accounts.ts
+1
-1
index.ts
packages/contracts/test/helpers/index.ts
+4
-4
mock-binding.ts
packages/contracts/test/helpers/mocks/mock-binding.ts
+1
-1
mock-generation.ts
packages/contracts/test/helpers/mocks/mock-generation.ts
+1
-1
compilation.ts
packages/contracts/test/helpers/solidity/compilation.ts
+0
-0
index.ts
packages/contracts/test/helpers/solidity/index.ts
+1
-0
contract-storage.ts
packages/contracts/test/helpers/storage/contract-storage.ts
+159
-247
index.ts
packages/contracts/test/helpers/storage/index.ts
+1
-0
index.ts
packages/contracts/test/helpers/test-runner/index.ts
+0
-0
test-runner.ts
packages/contracts/test/helpers/test-runner/test-runner.ts
+4
-4
test.types.ts
packages/contracts/test/helpers/test-runner/test.types.ts
+0
-0
ovm-types.ts
packages/contracts/test/helpers/types/ovm-types.ts
+5
-0
buffer-utils.ts
packages/contracts/test/helpers/utils/buffer-utils.ts
+10
-0
byte-utils.ts
packages/contracts/test/helpers/utils/byte-utils.ts
+31
-0
index.ts
packages/contracts/test/helpers/utils/index.ts
+2
-0
yarn.lock
packages/contracts/yarn.lock
+5
-0
No files found.
packages/contracts/.gitignore
View file @
82390b3a
node_modules/
artifacts/
cache/
yarn-error.log
\ No newline at end of file
packages/contracts/package.json
View file @
82390b3a
...
...
@@ -7,7 +7,7 @@
"build"
:
"yarn run build:contracts"
,
"build:contracts"
:
"buidler compile"
,
"test"
:
"yarn run test:contracts"
,
"test:contracts"
:
"buidler test
\"
test/contracts/OVM/execution/OVM_ExecutionManager/context-opcodes.spec.ts
\"
"
,
"test:contracts"
:
"buidler test"
,
"lint"
:
"tslint --format stylish --project ."
,
"fix"
:
"prettier --config prettier-config.json --write
\"
buidler.config.ts
\"
\"
{src,test}/**/*.ts
\"
"
},
...
...
@@ -16,6 +16,7 @@
"@nomiclabs/buidler-ethers"
:
"^2.0.0"
,
"@nomiclabs/buidler-waffle"
:
"^2.0.0"
,
"@types/chai"
:
"^4.2.12"
,
"@types/lodash"
:
"^4.14.161"
,
"@types/mocha"
:
"^8.0.3"
,
"@types/node"
:
"^14.6.0"
,
"assert"
:
"^2.0.0"
,
...
...
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/run.spec.ts
View file @
82390b3a
...
...
@@ -4,13 +4,10 @@ import {
TestDefinition
,
OVM_TX_GAS_LIMIT
,
NON_NULL_BYTES32
,
REVERT_FLAGS
,
ZERO_ADDRESS
,
VERIFIED_EMPTY_CONTRACT_HASH
,
}
from
'
../../../../helpers
'
const
DUMMY_REVERT_DATA
=
'
0xdeadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420deadbeef1e5420
'
const
GAS_METADATA_ADDRESS
=
'
0x06a506a506a506a506a506a506a506a506a506a5
'
enum
GasMetadataKey
{
...
...
packages/contracts/test/contracts/OVM/execution/OVM_SafetyChecker.spec.ts
View file @
82390b3a
...
...
@@ -5,7 +5,7 @@ import { ethers } from '@nomiclabs/buidler'
import
{
Contract
}
from
'
ethers
'
/* Internal Imports */
import
{
SAFETY_CHECKER_TEST_JSON
}
from
'
../../../
helpers
'
import
{
SAFETY_CHECKER_TEST_JSON
}
from
'
../../../
data
'
describe
(
'
OVM_SafetyChecker
'
,
()
=>
{
let
OVM_SafetyChecker
:
Contract
...
...
packages/contracts/test/
helpers/
data/index.ts
→
packages/contracts/test/data/index.ts
View file @
82390b3a
File moved
packages/contracts/test/
helpers/
data/json/create2.test.json
→
packages/contracts/test/data/json/create2.test.json
View file @
82390b3a
File moved
packages/contracts/test/
helpers/
data/json/rlp.test.json
→
packages/contracts/test/data/json/rlp.test.json
View file @
82390b3a
File moved
packages/contracts/test/
helpers/
data/json/safety-checker.test.json
→
packages/contracts/test/data/json/safety-checker.test.json
View file @
82390b3a
File moved
packages/contracts/test/helpers/codec/revert-flags.ts
View file @
82390b3a
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
hexZeroPad
}
from
'
ethers/lib/utils
'
export
const
encodeRevertData
=
(
flag
:
number
,
...
...
@@ -15,8 +15,6 @@ export const encodeRevertData = (
}
export
const
decodeRevertData
=
(
revertData
:
string
):
any
=>
{
// const length: number = revertData.length/2 - 1
// const reencodedRevertData = '0x' + hexZeroPad('0x' + length.toString(16), 32) + revertData.slice(2)
const
decoded
=
ethers
.
utils
.
defaultAbiCoder
.
decode
(
[
'
uint256
'
,
'
uint256
'
,
'
uint256
'
,
'
bytes
'
],
revertData
...
...
packages/contracts/test/helpers/constants.ts
View file @
82390b3a
...
...
@@ -3,7 +3,7 @@ import { ethers } from 'ethers'
import
{
defaultAccounts
}
from
'
ethereum-waffle
'
/* Internal Imports */
import
{
makeHexString
,
makeAddress
}
from
'
./
byte-
utils
'
import
{
makeHexString
,
makeAddress
}
from
'
./utils
'
export
const
DEFAULT_ACCOUNTS
=
defaultAccounts
export
const
DEFAULT_ACCOUNTS_BUIDLER
=
defaultAccounts
.
map
((
account
)
=>
{
...
...
packages/contracts/test/helpers/dummy/accounts.ts
View file @
82390b3a
/* Internal Imports */
import
{
DUMMY_BYTES32
}
from
'
./bytes32
'
import
{
ZERO_ADDRESS
,
NON_ZERO_ADDRESS
}
from
'
../constants
'
import
{
makeAddress
}
from
'
../
byte-
utils
'
import
{
makeAddress
}
from
'
../utils
'
import
{
OVMAccount
}
from
'
../types/ovm-types
'
export
const
DUMMY_ACCOUNTS
:
Array
<
{
...
...
packages/contracts/test/helpers/index.ts
View file @
82390b3a
...
...
@@ -3,8 +3,8 @@ export * from './types'
export
*
from
'
./constants
'
export
*
from
'
./proxy
'
export
*
from
'
./mocks
'
export
*
from
'
./buffer-utils
'
export
*
from
'
./byte-utils
'
export
*
from
'
./utils
'
export
*
from
'
./codec
'
export
*
from
'
./data
'
export
*
from
'
./test-utils
'
export
*
from
'
./test-runner
'
export
*
from
'
./storage
'
export
*
from
'
./solidity
'
packages/contracts/test/helpers/mocks/mock-binding.ts
View file @
82390b3a
...
...
@@ -3,7 +3,7 @@ import bre from '@nomiclabs/buidler'
import
{
ethers
,
Contract
,
ContractFactory
}
from
'
ethers
'
/* Internal Imports */
import
{
toHexString
,
fromHexString
}
from
'
../
buffer-
utils
'
import
{
toHexString
,
fromHexString
}
from
'
../utils
'
import
{
MockContract
,
MockContractFunction
}
from
'
./mock-contract.types
'
/**
...
...
packages/contracts/test/helpers/mocks/mock-generation.ts
View file @
82390b3a
...
...
@@ -6,7 +6,7 @@ import { FunctionFragment, ParamType } from 'ethers/lib/utils'
/* Internal Imports */
import
{
MockContract
,
MockContractFunction
}
from
'
./mock-contract.types
'
import
{
bindMockContractToVM
,
bindMockWatcherToVM
}
from
'
./mock-binding
'
import
{
SolidityCompiler
,
getDefaultCompiler
,
compile
}
from
'
../
compilation
'
import
{
SolidityCompiler
,
getDefaultCompiler
,
compile
}
from
'
../
solidity
'
/**
* Generates contract code for a mock contract.
...
...
packages/contracts/test/helpers/compilation.ts
→
packages/contracts/test/helpers/
solidity/
compilation.ts
View file @
82390b3a
File moved
packages/contracts/test/helpers/solidity/index.ts
0 → 100644
View file @
82390b3a
export
*
from
'
./compilation
'
packages/contracts/test/helpers/storage/contract-storage.ts
View file @
82390b3a
This diff is collapsed.
Click to expand it.
packages/contracts/test/helpers/storage/index.ts
0 → 100644
View file @
82390b3a
export
*
from
'
./contract-storage
'
packages/contracts/test/helpers/test-
utils
/index.ts
→
packages/contracts/test/helpers/test-
runner
/index.ts
View file @
82390b3a
File moved
packages/contracts/test/helpers/test-
utils
/test-runner.ts
→
packages/contracts/test/helpers/test-
runner
/test-runner.ts
View file @
82390b3a
...
...
@@ -28,7 +28,7 @@ import {
isTestStep_REVERT
,
}
from
'
./test.types
'
import
{
encodeRevertData
}
from
'
../codec
'
import
{
getModifiableStorageFactory
}
from
'
../storage
/contract-storage
'
import
{
getModifiableStorageFactory
}
from
'
../storage
'
import
{
OVM_TX_GAS_LIMIT
,
RUN_OVM_TEST_GAS
,
...
...
@@ -226,10 +226,10 @@ export class ExecutionManagerTestRunner {
await
this
.
contracts
.
OVM_ExecutionManager
.
run
(
{
timestamp
:
step
.
functionParams
.
timestamp
,
queueOrigin
:
step
.
functionParams
.
queueOrigin
,
number
:
0
,
l1QueueOrigin
:
step
.
functionParams
.
queueOrigin
,
l1Txorigin
:
step
.
functionParams
.
origin
,
entrypoint
:
step
.
functionParams
.
entrypoint
,
origin
:
step
.
functionParams
.
origin
,
msgSender
:
step
.
functionParams
.
msgSender
,
gasLimit
:
step
.
functionParams
.
gasLimit
,
data
:
calldata
,
},
...
...
packages/contracts/test/helpers/test-
utils
/test.types.ts
→
packages/contracts/test/helpers/test-
runner
/test.types.ts
View file @
82390b3a
File moved
packages/contracts/test/helpers/types/ovm-types.ts
View file @
82390b3a
...
...
@@ -6,6 +6,11 @@ export interface OVMAccount {
ethAddress
:
string
}
/**
* Converts a raw ethers result to an OVM account.
* @param result Raw ethers transaction result.
* @returns Converted OVM account.
*/
export
const
toOVMAccount
=
(
result
:
any
[]):
OVMAccount
=>
{
return
{
nonce
:
result
[
0
].
toNumber
(),
...
...
packages/contracts/test/helpers/buffer-utils.ts
→
packages/contracts/test/helpers/
utils/
buffer-utils.ts
View file @
82390b3a
/**
* Converts a string or buffer to a '0x'-prefixed hex string.
* @param buf String or buffer to convert.
* @returns '0x'-prefixed string.
*/
export
const
toHexString
=
(
buf
:
Buffer
|
string
):
string
=>
{
return
'
0x
'
+
fromHexString
(
buf
).
toString
(
'
hex
'
)
}
/**
* Converts a '0x'-prefixed string to a buffer.
* @param str '0x'-prefixed string to convert.
* @returns Hex buffer.
*/
export
const
fromHexString
=
(
str
:
string
|
Buffer
):
Buffer
=>
{
if
(
typeof
str
===
'
string
'
&&
str
.
startsWith
(
'
0x
'
))
{
return
Buffer
.
from
(
str
.
slice
(
2
),
'
hex
'
)
...
...
packages/contracts/test/helpers/byte-utils.ts
→
packages/contracts/test/helpers/
utils/
byte-utils.ts
View file @
82390b3a
/**
* Generates a hex string of repeated bytes.
* @param byte Byte to repeat.
* @param len Number of times to repeat the byte.
* @return '0x'-prefixed hex string filled with the provided byte.
*/
export
const
makeHexString
=
(
byte
:
string
,
len
:
number
):
string
=>
{
return
'
0x
'
+
byte
.
repeat
(
len
)
}
/**
* Genereates an address with a repeated byte.
* @param byte Byte to repeat in the address.
* @return Address filled with the repeated byte.
*/
export
const
makeAddress
=
(
byte
:
string
):
string
=>
{
return
makeHexString
(
byte
,
20
)
}
/**
* Removes '0x' from a hex string.
* @param str Hex string to remove '0x' from.
* @returns String without the '0x' prefix.
*/
export
const
remove0x
=
(
str
:
string
):
string
=>
{
if
(
str
.
startsWith
(
'
0x
'
))
{
return
str
.
slice
(
2
)
...
...
packages/contracts/test/helpers/utils/index.ts
0 → 100644
View file @
82390b3a
export
*
from
'
./buffer-utils
'
export
*
from
'
./byte-utils
'
packages/contracts/yarn.lock
View file @
82390b3a
...
...
@@ -655,6 +655,11 @@
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0"
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==
"@types/lodash@^4.14.161":
version "4.14.161"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.161.tgz#a21ca0777dabc6e4f44f3d07f37b765f54188b18"
integrity sha512-EP6O3Jkr7bXvZZSZYlsgt5DIjiGr0dXP1/jVEwVLTFgg0d+3lWVQkRavYVQszV7dYUwvg0B8R0MBDpcmXg7XIA==
"@types/lru-cache@^5.1.0":
version "5.1.0"
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.0.tgz#57f228f2b80c046b4a1bd5cac031f81f207f4f03"
...
...
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