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
317028c9
Unverified
Commit
317028c9
authored
Jun 27, 2023
by
protolambda
Committed by
inphi
Jun 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cannon: TestEVM run oracle.bin
parent
cea0b130
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
evm.go
cannon/mipsevm/evm.go
+1
-1
evm_test.go
cannon/mipsevm/evm_test.go
+13
-2
No files found.
cannon/mipsevm/evm.go
View file @
317028c9
...
@@ -48,7 +48,7 @@ func LoadContractsFromFiles() (*Contracts, error) {
...
@@ -48,7 +48,7 @@ func LoadContractsFromFiles() (*Contracts, error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
oracle
,
err
:=
LoadContract
(
"Oracle"
)
oracle
,
err
:=
LoadContract
(
"
Preimage
Oracle"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
cannon/mipsevm/evm_test.go
View file @
317028c9
...
@@ -58,8 +58,9 @@ func TestEVM(t *testing.T) {
...
@@ -58,8 +58,9 @@ func TestEVM(t *testing.T) {
for
_
,
f
:=
range
testFiles
{
for
_
,
f
:=
range
testFiles
{
t
.
Run
(
f
.
Name
(),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
f
.
Name
(),
func
(
t
*
testing
.
T
)
{
var
oracle
PreimageOracle
if
f
.
Name
()
==
"oracle.bin"
{
if
f
.
Name
()
==
"oracle.bin"
{
t
.
Skip
(
"oracle test needs to be updated to use syscall pre-image oracle"
)
oracle
=
staticOracle
(
t
,
[]
byte
(
"hello world"
)
)
}
}
env
,
evmState
:=
NewEVMEnv
(
contracts
,
addrs
)
env
,
evmState
:=
NewEVMEnv
(
contracts
,
addrs
)
...
@@ -75,7 +76,7 @@ func TestEVM(t *testing.T) {
...
@@ -75,7 +76,7 @@ func TestEVM(t *testing.T) {
// set the return address ($ra) to jump into when test completes
// set the return address ($ra) to jump into when test completes
state
.
Registers
[
31
]
=
endAddr
state
.
Registers
[
31
]
=
endAddr
us
:=
NewInstrumentedState
(
state
,
nil
,
os
.
Stdout
,
os
.
Stderr
)
us
:=
NewInstrumentedState
(
state
,
oracle
,
os
.
Stdout
,
os
.
Stderr
)
for
i
:=
0
;
i
<
1000
;
i
++
{
for
i
:=
0
;
i
<
1000
;
i
++
{
if
us
.
state
.
PC
==
endAddr
{
if
us
.
state
.
PC
==
endAddr
{
...
@@ -91,6 +92,16 @@ func TestEVM(t *testing.T) {
...
@@ -91,6 +92,16 @@ func TestEVM(t *testing.T) {
// we take a snapshot so we can clean up the state, and isolate the logs of this instruction run.
// we take a snapshot so we can clean up the state, and isolate the logs of this instruction run.
snap
:=
env
.
StateDB
.
Snapshot
()
snap
:=
env
.
StateDB
.
Snapshot
()
// prepare pre-image oracle data, if any
if
stepWitness
.
HasPreimage
()
{
t
.
Logf
(
"reading preimage key %x at offset %d"
,
stepWitness
.
PreimageKey
,
stepWitness
.
PreimageOffset
)
poInput
,
err
:=
stepWitness
.
EncodePreimageOracleInput
()
require
.
NoError
(
t
,
err
,
"encode preimage oracle input"
)
_
,
leftOverGas
,
err
:=
env
.
Call
(
vm
.
AccountRef
(
addrs
.
Sender
),
addrs
.
Oracle
,
poInput
,
startingGas
,
big
.
NewInt
(
0
))
require
.
NoErrorf
(
t
,
err
,
"evm should not fail, took %d gas"
,
startingGas
-
leftOverGas
)
}
ret
,
leftOverGas
,
err
:=
env
.
Call
(
vm
.
AccountRef
(
sender
),
addrs
.
MIPS
,
input
,
startingGas
,
big
.
NewInt
(
0
))
ret
,
leftOverGas
,
err
:=
env
.
Call
(
vm
.
AccountRef
(
sender
),
addrs
.
MIPS
,
input
,
startingGas
,
big
.
NewInt
(
0
))
require
.
NoError
(
t
,
err
,
"evm should not fail"
)
require
.
NoError
(
t
,
err
,
"evm should not fail"
)
require
.
Len
(
t
,
ret
,
32
,
"expecting 32-byte state hash"
)
require
.
Len
(
t
,
ret
,
32
,
"expecting 32-byte state hash"
)
...
...
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