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
468e8d19
Commit
468e8d19
authored
Oct 29, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
should fix tests
parent
544b641e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
13 deletions
+18
-13
compare_evmchain_test.go
mipsevm/compare_evmchain_test.go
+1
-1
compare_unievm_test.go
mipsevm/compare_unievm_test.go
+1
-1
main.go
mipsevm/main.go
+1
-1
mips_run_test.go
mipsevm/mips_run_test.go
+1
-1
unicorn.go
mipsevm/unicorn.go
+14
-9
No files found.
mipsevm/compare_evmchain_test.go
View file @
468e8d19
...
@@ -27,7 +27,7 @@ func LoadRam() map[uint32](uint32) {
...
@@ -27,7 +27,7 @@ func LoadRam() map[uint32](uint32) {
// go test -run TestCompareEvmChain
// go test -run TestCompareEvmChain
func
TestCompareEvmChain
(
t
*
testing
.
T
)
{
func
TestCompareEvmChain
(
t
*
testing
.
T
)
{
totalSteps
:=
5
0
totalSteps
:=
2
0
cchain
:=
make
(
chan
common
.
Hash
,
1
)
cchain
:=
make
(
chan
common
.
Hash
,
1
)
cuni
:=
make
(
chan
common
.
Hash
,
1
)
cuni
:=
make
(
chan
common
.
Hash
,
1
)
...
...
mipsevm/compare_unievm_test.go
View file @
468e8d19
...
@@ -49,7 +49,7 @@ func TestCompareUnicornEvm(t *testing.T) {
...
@@ -49,7 +49,7 @@ func TestCompareUnicornEvm(t *testing.T) {
})
})
uniram
:=
make
(
map
[
uint32
](
uint32
))
uniram
:=
make
(
map
[
uint32
](
uint32
))
go
RunUnicorn
(
fn
,
uniram
,
steps
,
true
,
func
(
step
int
,
mu
uc
.
Unicorn
,
ram
map
[
uint32
](
uint32
))
{
go
RunUnicorn
(
fn
,
uniram
,
steps
,
true
,
f
alse
,
f
unc
(
step
int
,
mu
uc
.
Unicorn
,
ram
map
[
uint32
](
uint32
))
{
SyncRegs
(
mu
,
ram
)
SyncRegs
(
mu
,
ram
)
cuni
<-
RegSerialize
(
ram
)
cuni
<-
RegSerialize
(
ram
)
done
.
Lock
()
done
.
Lock
()
...
...
mipsevm/main.go
View file @
468e8d19
...
@@ -66,7 +66,7 @@ func main() {
...
@@ -66,7 +66,7 @@ func main() {
RunMinigeth
(
os
.
Args
[
1
],
steps
,
debug
)
RunMinigeth
(
os
.
Args
[
1
],
steps
,
debug
)
}
else
if
os
.
Args
[
1
]
==
"unicorn"
{
}
else
if
os
.
Args
[
1
]
==
"unicorn"
{
uniram
:=
make
(
map
[
uint32
](
uint32
))
uniram
:=
make
(
map
[
uint32
](
uint32
))
RunUnicorn
(
os
.
Args
[
2
],
uniram
,
steps
,
false
,
nil
)
RunUnicorn
(
os
.
Args
[
2
],
uniram
,
steps
,
false
,
false
,
nil
)
}
else
{
}
else
{
runTest
(
os
.
Args
[
1
],
20
,
2
)
runTest
(
os
.
Args
[
1
],
20
,
2
)
}
}
...
...
mipsevm/mips_run_test.go
View file @
468e8d19
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
func
TestMinigethUnicorn
(
t
*
testing
.
T
)
{
func
TestMinigethUnicorn
(
t
*
testing
.
T
)
{
uniram
:=
make
(
map
[
uint32
](
uint32
))
uniram
:=
make
(
map
[
uint32
](
uint32
))
RunUnicorn
(
"../mipigo/minigeth.bin"
,
uniram
,
-
1
,
false
,
nil
)
RunUnicorn
(
"../mipigo/minigeth.bin"
,
uniram
,
-
1
,
false
,
true
,
nil
)
}
}
func
TestSimpleEVM
(
t
*
testing
.
T
)
{
func
TestSimpleEVM
(
t
*
testing
.
T
)
{
...
...
mipsevm/unicorn.go
View file @
468e8d19
...
@@ -71,7 +71,7 @@ func SyncRegs(mu uc.Unicorn, ram map[uint32](uint32)) {
...
@@ -71,7 +71,7 @@ func SyncRegs(mu uc.Unicorn, ram map[uint32](uint32)) {
}
}
// reimplement simple.py in go
// reimplement simple.py in go
func
RunUnicorn
(
fn
string
,
ram
map
[
uint32
](
uint32
),
totalSteps
int
,
slowMode
bool
,
callback
func
(
int
,
uc
.
Unicorn
,
map
[
uint32
](
uint32
)))
{
func
RunUnicorn
(
fn
string
,
ram
map
[
uint32
](
uint32
),
totalSteps
int
,
slowMode
bool
,
c
heckIO
bool
,
c
allback
func
(
int
,
uc
.
Unicorn
,
map
[
uint32
](
uint32
)))
{
mu
,
err
:=
uc
.
NewUnicorn
(
uc
.
ARCH_MIPS
,
uc
.
MODE_32
|
uc
.
MODE_BIG_ENDIAN
)
mu
,
err
:=
uc
.
NewUnicorn
(
uc
.
ARCH_MIPS
,
uc
.
MODE_32
|
uc
.
MODE_BIG_ENDIAN
)
check
(
err
)
check
(
err
)
...
@@ -185,16 +185,21 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
...
@@ -185,16 +185,21 @@ func RunUnicorn(fn string, ram map[uint32](uint32), totalSteps int, slowMode boo
inputs
,
_
:=
ioutil
.
ReadFile
(
inputFile
)
inputs
,
_
:=
ioutil
.
ReadFile
(
inputFile
)
mu
.
MemWrite
(
0xB0000000
,
inputs
[
0
:
0xc0
])
mu
.
MemWrite
(
0xB0000000
,
inputs
[
0
:
0xc0
])
LoadMappedFile
(
fn
,
ram
,
0
)
// load into ram
LoadMappedFile
(
inputFile
,
ram
,
0xB0000000
)
LoadData
(
dat
,
ram
,
0
)
if
checkIO
{
LoadData
(
inputs
[
0
:
0xc0
],
ram
,
0xB0000000
)
}
mu
.
Start
(
0
,
0x5ead0004
)
mu
.
Start
(
0
,
0x5ead0004
)
real
:=
append
([]
byte
{
0x13
,
0x37
,
0xf0
,
0x0d
},
inputs
[
0xc0
:
]
...
)
if
checkIO
{
output
,
_
:=
mu
.
MemRead
(
0xB0000800
,
0x44
)
real
:=
append
([]
byte
{
0x13
,
0x37
,
0xf0
,
0x0d
},
inputs
[
0xc0
:
]
...
)
if
bytes
.
Compare
(
real
,
output
)
!=
0
{
output
,
_
:=
mu
.
MemRead
(
0xB0000800
,
0x44
)
log
.
Fatal
(
"mismatch output"
)
if
bytes
.
Compare
(
real
,
output
)
!=
0
{
}
else
{
log
.
Fatal
(
"mismatch output"
)
fmt
.
Println
(
"output match"
)
}
else
{
fmt
.
Println
(
"output match"
)
}
}
}
}
}
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