Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
8923325d
Commit
8923325d
authored
Aug 24, 2016
by
Nick Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
internal/ethapi: Fix bug in opCodeWrapper usage
parent
a2b2c8ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
tracer.go
internal/ethapi/tracer.go
+3
-1
tracer_test.go
internal/ethapi/tracer_test.go
+20
-5
No files found.
internal/ethapi/tracer.go
View file @
8923325d
...
...
@@ -284,8 +284,10 @@ func (jst *JavascriptTracer) CaptureState(env vm.Environment, pc uint64, op vm.O
jst
.
stack
.
stack
=
stack
jst
.
db
.
db
=
env
.
Db
()
ocw
:=
&
opCodeWrapper
{
op
}
jst
.
log
[
"pc"
]
=
pc
jst
.
log
[
"op"
]
=
&
opCodeWrapper
{
op
}
jst
.
log
[
"op"
]
=
ocw
.
toValue
(
jst
.
vm
)
jst
.
log
[
"gas"
]
=
gas
.
Int64
()
jst
.
log
[
"gasPrice"
]
=
cost
.
Int64
()
jst
.
log
[
"memory"
]
=
jst
.
memvalue
...
...
internal/ethapi/tracer_test.go
View file @
8923325d
...
...
@@ -19,6 +19,7 @@ package ethapi
import
(
"errors"
"math/big"
"reflect"
"testing"
"time"
...
...
@@ -140,12 +141,26 @@ func TestStack(t *testing.T) {
t
.
Fatal
(
err
)
}
value
,
ok
:=
ret
.
([]
int
)
if
!
ok
{
t
.
Errorf
(
"Expected return value to be []int, was %T"
,
ret
)
expected
:=
[]
int
{
0
,
1
,
2
}
if
!
reflect
.
DeepEqual
(
ret
,
expected
)
{
t
.
Errorf
(
"Expected return value to be %#v, got %#v"
,
expected
,
ret
)
}
}
func
TestOpcodes
(
t
*
testing
.
T
)
{
tracer
,
err
:=
NewJavascriptTracer
(
"{opcodes: [], step: function(log) { this.opcodes.push(log.op.toString()); }, result: function() { return this.opcodes; }}"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
len
(
value
)
!=
3
||
value
[
0
]
!=
0
||
value
[
1
]
!=
1
||
value
[
2
]
!=
2
{
t
.
Errorf
(
"Expected return value to be [0 1 2], got %v"
,
value
)
ret
,
err
:=
runTrace
(
tracer
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
expected
:=
[]
string
{
"PUSH1"
,
"PUSH1"
,
"STOP"
}
if
!
reflect
.
DeepEqual
(
ret
,
expected
)
{
t
.
Errorf
(
"Expected return value to be %#v, got %#v"
,
expected
,
ret
)
}
}
...
...
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