Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
4704a0a2
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,体验更适合开发者的 AI 搜索 >>
提交
4704a0a2
编写于
1月 13, 2015
作者:
O
obscuren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove pre compiled for tests
上级
5b561f43
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
32 deletion
+41
-32
tests/helper/vm.go
tests/helper/vm.go
+5
-0
tests/vm/gh_test.go
tests/vm/gh_test.go
+5
-6
vm/address.go
vm/address.go
+31
-26
未找到文件。
tests/helper/vm.go
浏览文件 @
4704a0a2
...
...
@@ -116,6 +116,8 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
price
=
ethutil
.
Big
(
exec
[
"gasPrice"
])
value
=
ethutil
.
Big
(
exec
[
"value"
])
)
// Reset the pre-compiled contracts for VM tests.
vm
.
Precompiled
=
make
(
map
[
string
]
*
vm
.
PrecompiledAccount
)
caller
:=
state
.
GetOrNewStateObject
(
from
)
...
...
@@ -138,6 +140,9 @@ func RunState(statedb *state.StateDB, env, tx map[string]string) ([]byte, state.
caddr
=
FromHex
(
env
[
"currentCoinbase"
])
)
// Set pre compiled contracts
vm
.
Precompiled
=
vm
.
PrecompiledContracts
()
coinbase
:=
statedb
.
GetOrNewStateObject
(
caddr
)
coinbase
.
SetGasPool
(
ethutil
.
Big
(
env
[
"currentGasLimit"
]))
...
...
tests/vm/gh_test.go
浏览文件 @
4704a0a2
...
...
@@ -79,6 +79,7 @@ func RunVmTest(p string, t *testing.T) {
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
//helper.Log.Infoln("Running", name)
db
,
_
:=
ethdb
.
NewMemDatabase
()
statedb
:=
state
.
New
(
nil
,
db
)
for
addr
,
account
:=
range
test
.
Pre
{
...
...
@@ -116,12 +117,6 @@ func RunVmTest(p string, t *testing.T) {
ret
,
logs
,
gas
,
err
=
helper
.
RunState
(
statedb
,
env
,
test
.
Transaction
)
}
// Log the error if there is one. Error does not mean failing test.
// A test fails if err != nil and post params are specified in the test.
if
err
!=
nil
{
helper
.
Log
.
Infof
(
"%s's: %v
\n
"
,
name
,
err
)
}
rexp
:=
helper
.
FromHex
(
test
.
Out
)
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
t
.
Errorf
(
"%s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
...
...
@@ -129,10 +124,14 @@ func RunVmTest(p string, t *testing.T) {
if
isVmTest
{
if
len
(
test
.
Gas
)
==
0
&&
err
==
nil
{
// Log VM err
helper
.
Log
.
Infof
(
"%s's: %v
\n
"
,
name
,
err
)
t
.
Errorf
(
"%s's gas unspecified, indicating an error. VM returned (incorrectly) successfull"
,
name
)
}
else
{
gexp
:=
ethutil
.
Big
(
test
.
Gas
)
if
gexp
.
Cmp
(
gas
)
!=
0
{
// Log VM err
helper
.
Log
.
Infof
(
"%s's: %v
\n
"
,
name
,
err
)
t
.
Errorf
(
"%s's gas failed. Expected %v, got %v
\n
"
,
name
,
gexp
,
gas
)
}
}
...
...
vm/address.go
浏览文件 @
4704a0a2
...
...
@@ -20,32 +20,37 @@ func (self PrecompiledAccount) Call(in []byte) []byte {
return
self
.
fn
(
in
)
}
var
Precompiled
=
map
[
string
]
*
PrecompiledAccount
{
// ECRECOVER
string
(
ethutil
.
LeftPadBytes
([]
byte
{
1
},
20
))
:
&
PrecompiledAccount
{
func
(
l
int
)
*
big
.
Int
{
return
GasEcrecover
},
ecrecoverFunc
},
// SHA256
string
(
ethutil
.
LeftPadBytes
([]
byte
{
2
},
20
))
:
&
PrecompiledAccount
{
func
(
l
int
)
*
big
.
Int
{
n
:=
big
.
NewInt
(
int64
(
l
+
31
)
/
32
+
1
)
n
.
Mul
(
n
,
GasSha256
)
return
n
},
sha256Func
},
// RIPEMD160
string
(
ethutil
.
LeftPadBytes
([]
byte
{
3
},
20
))
:
&
PrecompiledAccount
{
func
(
l
int
)
*
big
.
Int
{
n
:=
big
.
NewInt
(
int64
(
l
+
31
)
/
32
+
1
)
n
.
Mul
(
n
,
GasRipemd
)
return
n
},
ripemd160Func
},
string
(
ethutil
.
LeftPadBytes
([]
byte
{
4
},
20
))
:
&
PrecompiledAccount
{
func
(
l
int
)
*
big
.
Int
{
n
:=
big
.
NewInt
(
int64
(
l
+
31
)
/
32
+
1
)
n
.
Mul
(
n
,
GasMemCpy
)
return
n
},
memCpy
},
var
Precompiled
=
PrecompiledContracts
()
// XXX Could set directly. Testing requires resetting and setting of pre compiled contracts.
func
PrecompiledContracts
()
map
[
string
]
*
PrecompiledAccount
{
return
map
[
string
]
*
PrecompiledAccount
{
// ECRECOVER
string
(
ethutil
.
LeftPadBytes
([]
byte
{
1
},
20
))
:
&
PrecompiledAccount
{
func
(
l
int
)
*
big
.
Int
{
return
GasEcrecover
},
ecrecoverFunc
},
// SHA256
string
(
ethutil
.
LeftPadBytes
([]
byte
{
2
},
20
))
:
&
PrecompiledAccount
{
func
(
l
int
)
*
big
.
Int
{
n
:=
big
.
NewInt
(
int64
(
l
+
31
)
/
32
+
1
)
n
.
Mul
(
n
,
GasSha256
)
return
n
},
sha256Func
},
// RIPEMD160
string
(
ethutil
.
LeftPadBytes
([]
byte
{
3
},
20
))
:
&
PrecompiledAccount
{
func
(
l
int
)
*
big
.
Int
{
n
:=
big
.
NewInt
(
int64
(
l
+
31
)
/
32
+
1
)
n
.
Mul
(
n
,
GasRipemd
)
return
n
},
ripemd160Func
},
string
(
ethutil
.
LeftPadBytes
([]
byte
{
4
},
20
))
:
&
PrecompiledAccount
{
func
(
l
int
)
*
big
.
Int
{
n
:=
big
.
NewInt
(
int64
(
l
+
31
)
/
32
+
1
)
n
.
Mul
(
n
,
GasMemCpy
)
return
n
},
memCpy
},
}
}
func
sha256Func
(
in
[]
byte
)
[]
byte
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录