Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
347cb272
G
go-ethereum
项目概览
whqwjb
/
go-ethereum
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
go-ethereum
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
347cb272
编写于
3月 12, 2015
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed ethtest
上级
d1c872ba
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
13 deletion
+21
-13
cmd/ethtest/main.go
cmd/ethtest/main.go
+3
-1
state/statedb.go
state/statedb.go
+9
-9
tests/vm/gh_test.go
tests/vm/gh_test.go
+6
-0
vm/vm.go
vm/vm.go
+3
-3
未找到文件。
cmd/ethtest/main.go
浏览文件 @
347cb272
...
...
@@ -38,6 +38,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
"github.com/ethereum/go-ethereum/vm"
)
type
Log
struct
{
...
...
@@ -164,7 +165,7 @@ func RunVmTest(r io.Reader) (failed int) {
}
if
!
bytes
.
Equal
(
ethutil
.
Hex2Bytes
(
test
.
PostStateRoot
),
statedb
.
Root
())
{
fmt
.
Printf
(
"%s's : Post state root error. Expected %s, got %x"
,
name
,
test
.
PostStateRoot
,
statedb
.
Root
())
fmt
.
Printf
(
"%s's : Post state root error. Expected %s, got %x
\n
"
,
name
,
test
.
PostStateRoot
,
statedb
.
Root
())
failed
=
1
}
...
...
@@ -194,6 +195,7 @@ func RunVmTest(r io.Reader) (failed int) {
func
main
()
{
helper
.
Logger
.
SetLogLevel
(
5
)
vm
.
Debug
=
true
if
len
(
os
.
Args
)
>
1
{
os
.
Exit
(
RunVmTest
(
strings
.
NewReader
(
os
.
Args
[
1
])))
...
...
state/statedb.go
浏览文件 @
347cb272
...
...
@@ -54,7 +54,7 @@ func (self *StateDB) Refund(addr []byte, gas *big.Int) {
// Retrieve the balance from the given address or 0 if object not found
func
(
self
*
StateDB
)
GetBalance
(
addr
[]
byte
)
*
big
.
Int
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
return
stateObject
.
balance
}
...
...
@@ -63,14 +63,14 @@ func (self *StateDB) GetBalance(addr []byte) *big.Int {
}
func
(
self
*
StateDB
)
AddBalance
(
addr
[]
byte
,
amount
*
big
.
Int
)
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
stateObject
.
AddBalance
(
amount
)
}
}
func
(
self
*
StateDB
)
GetNonce
(
addr
[]
byte
)
uint64
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
return
stateObject
.
nonce
}
...
...
@@ -79,7 +79,7 @@ func (self *StateDB) GetNonce(addr []byte) uint64 {
}
func
(
self
*
StateDB
)
GetCode
(
addr
[]
byte
)
[]
byte
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
return
stateObject
.
code
}
...
...
@@ -88,7 +88,7 @@ func (self *StateDB) GetCode(addr []byte) []byte {
}
func
(
self
*
StateDB
)
GetState
(
a
,
b
[]
byte
)
[]
byte
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
a
)
stateObject
:=
self
.
GetStateObject
(
a
)
if
stateObject
!=
nil
{
return
stateObject
.
GetState
(
b
)
.
Bytes
()
}
...
...
@@ -97,28 +97,28 @@ func (self *StateDB) GetState(a, b []byte) []byte {
}
func
(
self
*
StateDB
)
SetNonce
(
addr
[]
byte
,
nonce
uint64
)
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
stateObject
.
SetNonce
(
nonce
)
}
}
func
(
self
*
StateDB
)
SetCode
(
addr
,
code
[]
byte
)
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
stateObject
.
SetCode
(
code
)
}
}
func
(
self
*
StateDB
)
SetState
(
addr
,
key
[]
byte
,
value
interface
{})
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
stateObject
.
SetState
(
key
,
ethutil
.
NewValue
(
value
))
}
}
func
(
self
*
StateDB
)
Delete
(
addr
[]
byte
)
bool
{
stateObject
:=
self
.
Get
OrNew
StateObject
(
addr
)
stateObject
:=
self
.
GetStateObject
(
addr
)
if
stateObject
!=
nil
{
stateObject
.
MarkForDeletion
()
stateObject
.
balance
=
new
(
big
.
Int
)
...
...
tests/vm/gh_test.go
浏览文件 @
347cb272
...
...
@@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
"github.com/ethereum/go-ethereum/vm"
)
type
Account
struct
{
...
...
@@ -80,6 +81,11 @@ func RunVmTest(p string, t *testing.T) {
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
vm
.
Debug
=
true
helper
.
Logger
.
SetLogLevel
(
4
)
if
name
!=
"signextend_Overflow_dj42"
{
continue
}
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
nil
,
db
)
for
addr
,
account
:=
range
test
.
Pre
{
...
...
vm/vm.go
浏览文件 @
347cb272
...
...
@@ -235,9 +235,9 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
stack
.
push
(
base
)
case
SIGNEXTEND
:
back
:=
stack
.
pop
()
.
Uint64
()
if
back
<
31
{
bit
:=
uint
(
back
*
8
+
7
)
back
:=
stack
.
pop
()
if
back
.
Cmp
(
big
.
NewInt
(
31
))
<
0
{
bit
:=
uint
(
back
.
Uint64
()
*
8
+
7
)
num
:=
stack
.
pop
()
mask
:=
new
(
big
.
Int
)
.
Lsh
(
ethutil
.
Big1
,
bit
)
mask
.
Sub
(
mask
,
ethutil
.
Big1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录