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
954e87cd
Commit
954e87cd
authored
Sep 15, 2020
by
Kelvin Fichter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restored old tests
parent
528f57f7
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
1239 additions
and
0 deletions
+1239
-0
OVM_ExecutionManager.opcodes.calling.spec.ts
...ager/opcodes/OVM_ExecutionManager.opcodes.calling.spec.ts
+343
-0
OVM_ExecutionManager.opcodes.code.spec.ts
...Manager/opcodes/OVM_ExecutionManager.opcodes.code.spec.ts
+387
-0
OVM_ExecutionManager.opcodes.creation.spec.ts
...ger/opcodes/OVM_ExecutionManager.opcodes.creation.spec.ts
+15
-0
OVM_ExecutionManager.opcodes.halting.spec.ts
...ager/opcodes/OVM_ExecutionManager.opcodes.halting.spec.ts
+76
-0
OVM_ExecutionManager.opcodes.storage.spec.ts
...ager/opcodes/OVM_ExecutionManager.opcodes.storage.spec.ts
+188
-0
OVM_StateManager.spec.ts
...cts/test/contracts/OVM/execution/OVM_StateManager.spec.ts
+169
-0
Proxy_Forwarder.spec.ts
...es/contracts/test/contracts/proxy/Proxy_Forwarder.spec.ts
+11
-0
Proxy_Manager.spec.ts
...ages/contracts/test/contracts/proxy/Proxy_Manager.spec.ts
+39
-0
Proxy_Resolver.spec.ts
...ges/contracts/test/contracts/proxy/Proxy_Resolver.spec.ts
+11
-0
No files found.
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/opcodes/OVM_ExecutionManager.opcodes.calling.spec.ts
0 → 100644
View file @
954e87cd
This diff is collapsed.
Click to expand it.
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/opcodes/OVM_ExecutionManager.opcodes.code.spec.ts
0 → 100644
View file @
954e87cd
This diff is collapsed.
Click to expand it.
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/opcodes/OVM_ExecutionManager.opcodes.creation.spec.ts
0 → 100644
View file @
954e87cd
import
{
expect
}
from
'
../../../../../setup
'
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
,
ContractFactory
}
from
'
ethers
'
describe
(
'
OVM_ExecutionManager:opcodes:creation
'
,
()
=>
{
describe
(
'
ovmCREATE
'
,
()
=>
{
})
describe
(
'
ovmCREATE2
'
,
()
=>
{
})
})
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/opcodes/OVM_ExecutionManager.opcodes.halting.spec.ts
0 → 100644
View file @
954e87cd
import
{
expect
}
from
'
../../../../../setup
'
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
,
ContractFactory
}
from
'
ethers
'
/* Internal Imports */
import
{
getProxyManager
,
encodeRevertData
,
REVERT_FLAGS
}
from
'
../../../../../helpers
'
describe
(
'
OVM_ExecutionManager:opcodes:halting
'
,
()
=>
{
let
Proxy_Manager
:
Contract
before
(
async
()
=>
{
Proxy_Manager
=
await
getProxyManager
()
})
let
Factory__OVM_ExecutionManager
:
ContractFactory
before
(
async
()
=>
{
Factory__OVM_ExecutionManager
=
await
ethers
.
getContractFactory
(
'
OVM_ExecutionManager
'
)
})
let
OVM_ExecutionManager
:
Contract
beforeEach
(
async
()
=>
{
OVM_ExecutionManager
=
await
Factory__OVM_ExecutionManager
.
deploy
(
Proxy_Manager
.
address
)
})
let
Helper_RevertDataViewer
:
Contract
beforeEach
(
async
()
=>
{
const
Factory__Helper_RevertDataViewer
=
await
ethers
.
getContractFactory
(
'
Helper_RevertDataViewer
'
)
Helper_RevertDataViewer
=
await
Factory__Helper_RevertDataViewer
.
deploy
(
OVM_ExecutionManager
.
address
)
})
describe
(
'
ovmREVERT
'
,
()
=>
{
it
(
'
should revert with the provided data prefixed by the intentional revert flag
'
,
async
()
=>
{
const
revertdata
=
'
12345678
'
.
repeat
(
10
)
const
calldata
=
OVM_ExecutionManager
.
interface
.
encodeFunctionData
(
'
ovmREVERT
'
,
[
'
0x
'
+
revertdata
]
)
await
Helper_RevertDataViewer
.
fallback
({
data
:
calldata
})
expect
(
await
Helper_RevertDataViewer
.
revertdata
()
).
to
.
equal
(
encodeRevertData
(
REVERT_FLAGS
.
INTENTIONAL_REVERT
,
'
0x
'
+
revertdata
))
})
it
(
'
should revert with the intentional revert flag if no data is provided
'
,
async
()
=>
{
const
calldata
=
OVM_ExecutionManager
.
interface
.
encodeFunctionData
(
'
ovmREVERT
'
,
[
'
0x
'
]
)
await
Helper_RevertDataViewer
.
fallback
({
data
:
calldata
})
expect
(
await
Helper_RevertDataViewer
.
revertdata
()
).
to
.
equal
(
encodeRevertData
(
REVERT_FLAGS
.
INTENTIONAL_REVERT
))
})
})
})
packages/contracts/test/contracts/OVM/execution/OVM_ExecutionManager/opcodes/OVM_ExecutionManager.opcodes.storage.spec.ts
0 → 100644
View file @
954e87cd
import
{
expect
}
from
'
../../../../../setup
'
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
,
ContractFactory
}
from
'
ethers
'
/* Internal Imports */
import
{
getProxyManager
,
MockContract
,
getMockContract
,
DUMMY_ACCOUNTS
,
setProxyTarget
,
ZERO_ADDRESS
,
fromHexString
,
toHexString
,
makeHexString
,
NULL_BYTES32
,
DUMMY_BYTES32
,
encodeRevertData
,
REVERT_FLAGS
,
NON_ZERO_ADDRESS
}
from
'
../../../../../helpers
'
describe
(
'
OVM_ExecutionManager:opcodes:storage
'
,
()
=>
{
let
Proxy_Manager
:
Contract
before
(
async
()
=>
{
Proxy_Manager
=
await
getProxyManager
()
})
let
Mock__OVM_StateManager
:
MockContract
before
(
async
()
=>
{
Mock__OVM_StateManager
=
await
getMockContract
(
'
OVM_StateManager
'
)
await
setProxyTarget
(
Proxy_Manager
,
'
OVM_StateManager
'
,
Mock__OVM_StateManager
)
})
let
Factory__OVM_ExecutionManager
:
ContractFactory
before
(
async
()
=>
{
Factory__OVM_ExecutionManager
=
await
ethers
.
getContractFactory
(
'
OVM_ExecutionManager
'
)
})
let
OVM_ExecutionManager
:
Contract
beforeEach
(
async
()
=>
{
OVM_ExecutionManager
=
await
Factory__OVM_ExecutionManager
.
deploy
(
Proxy_Manager
.
address
)
})
let
Helper_RevertDataViewer
:
Contract
beforeEach
(
async
()
=>
{
const
Factory__Helper_RevertDataViewer
=
await
ethers
.
getContractFactory
(
'
Helper_RevertDataViewer
'
)
Helper_RevertDataViewer
=
await
Factory__Helper_RevertDataViewer
.
deploy
(
OVM_ExecutionManager
.
address
)
})
const
DUMMY_SLOT_KEY
=
DUMMY_BYTES32
[
0
]
const
DUMMY_SLOT_VALUE
=
DUMMY_BYTES32
[
1
]
describe
(
'
ovmSLOAD
'
,
()
=>
{
before
(()
=>
{
Mock__OVM_StateManager
.
setReturnValues
(
'
getContractStorage
'
,
()
=>
{
return
[
DUMMY_SLOT_VALUE
]
})
})
describe
(
'
when the OVM_StateManager has the corresponding storage slot
'
,
()
=>
{
before
(()
=>
{
Mock__OVM_StateManager
.
setReturnValues
(
'
hasContractStorage
'
,
[
true
])
})
describe
(
'
when the OVM_StateManager has already loaded the storage slot
'
,
()
=>
{
before
(()
=>
{
Mock__OVM_StateManager
.
setReturnValues
(
'
testAndSetContractStorageLoaded
'
,
[
true
])
})
it
(
'
should return the value of the storage slot
'
,
async
()
=>
{
expect
(
await
OVM_ExecutionManager
.
callStatic
.
ovmSLOAD
(
DUMMY_SLOT_KEY
)
).
to
.
equal
(
DUMMY_SLOT_VALUE
)
})
})
describe
(
'
when the OVM_StateManager has not already loaded the storage slot
'
,
()
=>
{
before
(()
=>
{
Mock__OVM_StateManager
.
setReturnValues
(
'
testAndSetContractStorageLoaded
'
,
[
false
])
})
it
(
'
should revert with the EXCEEDS_NUISANCE_GAS flag
'
,
async
()
=>
{
const
calldata
=
OVM_ExecutionManager
.
interface
.
encodeFunctionData
(
'
ovmSLOAD
'
,
[
DUMMY_SLOT_KEY
]
)
await
Helper_RevertDataViewer
.
fallback
({
data
:
calldata
})
expect
(
await
Helper_RevertDataViewer
.
revertdata
()
).
to
.
equal
(
encodeRevertData
(
REVERT_FLAGS
.
EXCEEDS_NUISANCE_GAS
))
})
})
})
describe
(
'
when the OVM_StateManager does not have the corresponding storage slot
'
,
()
=>
{
before
(()
=>
{
Mock__OVM_StateManager
.
setReturnValues
(
'
hasContractStorage
'
,
[
false
])
})
it
(
'
should revert with the INVALID_STATE_ACCESS flag
'
,
async
()
=>
{
const
calldata
=
OVM_ExecutionManager
.
interface
.
encodeFunctionData
(
'
ovmSLOAD
'
,
[
DUMMY_SLOT_KEY
]
)
await
Helper_RevertDataViewer
.
fallback
({
data
:
calldata
})
expect
(
await
Helper_RevertDataViewer
.
revertdata
()
).
to
.
equal
(
encodeRevertData
(
REVERT_FLAGS
.
INVALID_STATE_ACCESS
))
})
})
})
describe
(
'
ovmSSTORE
'
,
()
=>
{
describe
(
'
when the OVM_StateManager has already changed the storage slot
'
,
()
=>
{
before
(()
=>
{
Mock__OVM_StateManager
.
setReturnValues
(
'
testAndSetContractStorageChanged
'
,
[
true
])
})
it
(
'
should modify the storage slot value
'
,
async
()
=>
{
await
expect
(
OVM_ExecutionManager
.
ovmSSTORE
(
DUMMY_SLOT_KEY
,
DUMMY_SLOT_VALUE
)
).
to
.
not
.
be
.
reverted
expect
(
Mock__OVM_StateManager
.
getCallData
(
'
putContractStorage
'
,
0
)
).
to
.
deep
.
equal
(
[
ZERO_ADDRESS
,
DUMMY_SLOT_KEY
,
DUMMY_SLOT_VALUE
]
)
})
})
describe
(
'
when the OVM_StateManager has not already changed the storage slot
'
,
()
=>
{
before
(()
=>
{
Mock__OVM_StateManager
.
setReturnValues
(
'
testAndSetContractStorageChanged
'
,
[
false
])
})
it
(
'
should revert with the EXCEEDS_NUISANCE_GAS flag
'
,
async
()
=>
{
const
calldata
=
OVM_ExecutionManager
.
interface
.
encodeFunctionData
(
'
ovmSSTORE
'
,
[
DUMMY_SLOT_KEY
,
DUMMY_SLOT_VALUE
]
)
await
Helper_RevertDataViewer
.
fallback
({
data
:
calldata
})
expect
(
await
Helper_RevertDataViewer
.
revertdata
()
).
to
.
equal
(
encodeRevertData
(
REVERT_FLAGS
.
EXCEEDS_NUISANCE_GAS
))
})
})
})
})
packages/contracts/test/contracts/OVM/execution/OVM_StateManager.spec.ts
0 → 100644
View file @
954e87cd
import
{
expect
}
from
'
../../../setup
'
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
,
ContractFactory
}
from
'
ethers
'
/* Internal Imports */
import
{
DUMMY_ACCOUNTS
,
DUMMY_BYTES32
,
toOVMAccount
}
from
'
../../../helpers
'
describe
(
'
OVM_StateManager
'
,
()
=>
{
let
Factory__OVM_StateManager
:
ContractFactory
before
(
async
()
=>
{
Factory__OVM_StateManager
=
await
ethers
.
getContractFactory
(
'
OVM_StateManager
'
)
})
let
OVM_StateManager
:
Contract
beforeEach
(
async
()
=>
{
OVM_StateManager
=
await
Factory__OVM_StateManager
.
deploy
()
})
describe
(
'
putAccount
'
,
()
=>
{
it
(
'
should be able to store an OVM account
'
,
async
()
=>
{
await
expect
(
OVM_StateManager
.
putAccount
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_ACCOUNTS
[
0
].
data
)
).
to
.
not
.
be
.
reverted
})
it
(
'
should be able to overwrite an OVM account
'
,
async
()
=>
{
await
OVM_StateManager
.
putAccount
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_ACCOUNTS
[
0
].
data
)
await
expect
(
OVM_StateManager
.
putAccount
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_ACCOUNTS
[
1
].
data
)
).
to
.
not
.
be
.
reverted
})
})
describe
(
'
getAccount
'
,
()
=>
{
it
(
'
should be able to retrieve an OVM account
'
,
async
()
=>
{
await
OVM_StateManager
.
putAccount
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_ACCOUNTS
[
0
].
data
)
expect
(
toOVMAccount
(
await
OVM_StateManager
.
callStatic
.
getAccount
(
DUMMY_ACCOUNTS
[
0
].
address
)
)
).
to
.
deep
.
equal
(
DUMMY_ACCOUNTS
[
0
].
data
)
})
it
(
'
should be able to retrieve an overwritten OVM account
'
,
async
()
=>
{
await
OVM_StateManager
.
putAccount
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_ACCOUNTS
[
0
].
data
)
await
OVM_StateManager
.
putAccount
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_ACCOUNTS
[
1
].
data
)
expect
(
toOVMAccount
(
await
OVM_StateManager
.
callStatic
.
getAccount
(
DUMMY_ACCOUNTS
[
0
].
address
)
)
).
to
.
deep
.
equal
(
DUMMY_ACCOUNTS
[
1
].
data
)
})
})
describe
(
'
hasAccount
'
,
()
=>
{
it
(
'
should return true if an account exists
'
,
async
()
=>
{
await
OVM_StateManager
.
putAccount
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_ACCOUNTS
[
0
].
data
)
expect
(
await
OVM_StateManager
.
callStatic
.
hasAccount
(
DUMMY_ACCOUNTS
[
0
].
address
)
).
to
.
equal
(
true
)
})
it
(
'
should return false if the account does not exist
'
,
async
()
=>
{
expect
(
await
OVM_StateManager
.
callStatic
.
hasAccount
(
DUMMY_ACCOUNTS
[
0
].
address
)
).
to
.
equal
(
false
)
})
})
describe
(
'
putContractStorage
'
,
()
=>
{
it
(
'
should be able to insert a storage slot for a given contract
'
,
async
()
=>
{
await
expect
(
OVM_StateManager
.
putContractStorage
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_BYTES32
[
0
],
DUMMY_BYTES32
[
1
],
)
).
to
.
not
.
be
.
reverted
})
it
(
'
should be able to overwrite a storage slot for a given contract
'
,
async
()
=>
{
await
OVM_StateManager
.
putContractStorage
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_BYTES32
[
0
],
DUMMY_BYTES32
[
1
],
)
await
expect
(
OVM_StateManager
.
putContractStorage
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_BYTES32
[
0
],
DUMMY_BYTES32
[
2
],
)
).
to
.
not
.
be
.
reverted
})
})
describe
(
'
getContractStorage
'
,
()
=>
{
it
(
'
should be able to retrieve a storage slot for a given contract
'
,
async
()
=>
{
await
OVM_StateManager
.
putContractStorage
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_BYTES32
[
0
],
DUMMY_BYTES32
[
1
],
)
expect
(
await
OVM_StateManager
.
callStatic
.
getContractStorage
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_BYTES32
[
0
]
)
).
to
.
equal
(
DUMMY_BYTES32
[
1
])
})
it
(
'
should be able to retrieve an overwritten storage slot for a given contract
'
,
async
()
=>
{
await
OVM_StateManager
.
putContractStorage
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_BYTES32
[
0
],
DUMMY_BYTES32
[
1
],
)
await
OVM_StateManager
.
putContractStorage
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_BYTES32
[
0
],
DUMMY_BYTES32
[
2
],
)
expect
(
await
OVM_StateManager
.
callStatic
.
getContractStorage
(
DUMMY_ACCOUNTS
[
0
].
address
,
DUMMY_BYTES32
[
0
]
)
).
to
.
equal
(
DUMMY_BYTES32
[
2
])
})
})
})
packages/contracts/test/contracts/proxy/Proxy_Forwarder.spec.ts
0 → 100644
View file @
954e87cd
import
{
expect
}
from
'
../../setup
'
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
,
ContractFactory
}
from
'
ethers
'
describe
(
'
Proxy_Forwarder
'
,
()
=>
{
describe
(
'
fallback
'
,
()
=>
{
})
})
packages/contracts/test/contracts/proxy/Proxy_Manager.spec.ts
0 → 100644
View file @
954e87cd
import
{
expect
}
from
'
../../setup
'
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
,
ContractFactory
}
from
'
ethers
'
describe
(
'
Proxy_Manager
'
,
()
=>
{
describe
(
'
setProxy
'
,
()
=>
{
})
describe
(
'
getProxy
'
,
()
=>
{
})
describe
(
'
hasProxy
'
,
()
=>
{
})
describe
(
'
isProxy
'
,
()
=>
{
})
describe
(
'
setTarget
'
,
()
=>
{
})
describe
(
'
getTarget
'
,
()
=>
{
})
describe
(
'
hasTarget
'
,
()
=>
{
})
describe
(
'
isTarget
'
,
()
=>
{
})
})
packages/contracts/test/contracts/proxy/Proxy_Resolver.spec.ts
0 → 100644
View file @
954e87cd
import
{
expect
}
from
'
../../setup
'
/* External Imports */
import
{
ethers
}
from
'
@nomiclabs/buidler
'
import
{
Contract
,
ContractFactory
}
from
'
ethers
'
describe
(
'
Proxy_Resolver
'
,
()
=>
{
describe
(
'
resolve
'
,
()
=>
{
})
})
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