Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
83877a0f
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,发现更多精彩内容 >>
提交
83877a0f
编写于
3月 21, 2016
作者:
F
Felix Lange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests: remove eth, node, accounts dependencies
Unlocking the accounts in the test doesn't help with anything.
上级
8627680e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
56 deletion
+18
-56
cmd/gethrpctest/main.go
cmd/gethrpctest/main.go
+1
-1
crypto/crypto.go
crypto/crypto.go
+0
-13
tests/block_test_util.go
tests/block_test_util.go
+17
-42
未找到文件。
cmd/gethrpctest/main.go
浏览文件 @
83877a0f
...
...
@@ -123,7 +123,7 @@ func MakeSystemNode(keydir string, privkey string, test *tests.BlockTest) (*node
}
// Initialize and register the Ethereum protocol
db
,
_
:=
ethdb
.
NewMemDatabase
()
if
_
,
err
:=
test
.
InsertPreState
(
db
,
accman
);
err
!=
nil
{
if
_
,
err
:=
test
.
InsertPreState
(
db
);
err
!=
nil
{
return
nil
,
err
}
ethConf
:=
&
eth
.
Config
{
...
...
crypto/crypto.go
浏览文件 @
83877a0f
...
...
@@ -217,19 +217,6 @@ func Decrypt(prv *ecdsa.PrivateKey, ct []byte) ([]byte, error) {
return
key
.
Decrypt
(
rand
.
Reader
,
ct
,
nil
,
nil
)
}
// Used only by block tests.
func
ImportBlockTestKey
(
privKeyBytes
[]
byte
)
error
{
ks
:=
NewKeyStorePassphrase
(
common
.
DefaultDataDir
()
+
"/keystore"
,
LightScryptN
,
LightScryptP
)
ecKey
:=
ToECDSA
(
privKeyBytes
)
key
:=
&
Key
{
Id
:
uuid
.
NewRandom
(),
Address
:
PubkeyToAddress
(
ecKey
.
PublicKey
),
PrivateKey
:
ecKey
,
}
err
:=
ks
.
StoreKey
(
key
,
""
)
return
err
}
// creates a Key and stores that in the given KeyStore by decrypting a presale key JSON
func
ImportPreSaleKey
(
keyStore
KeyStore
,
keyJSON
[]
byte
,
password
string
)
(
*
Key
,
error
)
{
key
,
err
:=
decryptPreSaleKey
(
keyJSON
,
password
)
...
...
tests/block_test_util.go
浏览文件 @
83877a0f
...
...
@@ -22,23 +22,18 @@ import (
"fmt"
"io"
"math/big"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"
"github.com/ethereum/
go-ethereum/accounts
"
"github.com/ethereum/
ethash
"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rlp"
)
...
...
@@ -160,45 +155,39 @@ func runBlockTests(homesteadBlock *big.Int, bt map[string]*BlockTest, skipTests
}
return
nil
}
func
runBlockTest
(
homesteadBlock
*
big
.
Int
,
test
*
BlockTest
)
error
{
ks
:=
crypto
.
NewKeyStorePassphrase
(
filepath
.
Join
(
common
.
DefaultDataDir
(),
"keystore"
),
crypto
.
StandardScryptN
,
crypto
.
StandardScryptP
)
am
:=
accounts
.
NewManager
(
ks
)
db
,
_
:=
ethdb
.
NewMemDatabase
()
func
runBlockTest
(
homesteadBlock
*
big
.
Int
,
test
*
BlockTest
)
error
{
// import pre accounts & construct test genesis block & state root
_
,
err
:=
test
.
InsertPreState
(
db
,
am
)
if
err
!=
nil
{
db
,
_
:=
ethdb
.
NewMemDatabase
(
)
if
_
,
err
:=
test
.
InsertPreState
(
db
);
err
!=
nil
{
return
fmt
.
Errorf
(
"InsertPreState: %v"
,
err
)
}
cfg
:=
&
eth
.
Config
{
ChainConfig
:
&
core
.
ChainConfig
{
HomesteadBlock
:
homesteadBlock
},
TestGenesisState
:
db
,
TestGenesisBlock
:
test
.
Genesis
,
Etherbase
:
common
.
Address
{},
AccountManager
:
am
,
PowShared
:
true
,
}
ethereum
,
err
:=
eth
.
New
(
&
node
.
ServiceContext
{
EventMux
:
new
(
event
.
TypeMux
)},
cfg
)
core
.
WriteTd
(
db
,
test
.
Genesis
.
Hash
(),
test
.
Genesis
.
Difficulty
())
core
.
WriteBlock
(
db
,
test
.
Genesis
)
core
.
WriteCanonicalHash
(
db
,
test
.
Genesis
.
Hash
(),
test
.
Genesis
.
NumberU64
())
core
.
WriteHeadBlockHash
(
db
,
test
.
Genesis
.
Hash
())
evmux
:=
new
(
event
.
TypeMux
)
config
:=
&
core
.
ChainConfig
{
HomesteadBlock
:
homesteadBlock
}
chain
,
err
:=
core
.
NewBlockChain
(
db
,
config
,
ethash
.
NewShared
(),
evmux
)
if
err
!=
nil
{
return
err
}
cm
:=
ethereum
.
BlockChain
()
//vm.Debug = true
validBlocks
,
err
:=
test
.
TryBlocksInsert
(
c
m
)
validBlocks
,
err
:=
test
.
TryBlocksInsert
(
c
hain
)
if
err
!=
nil
{
return
err
}
lastblockhash
:=
common
.
HexToHash
(
test
.
lastblockhash
)
cmlast
:=
c
m
.
LastBlockHash
()
cmlast
:=
c
hain
.
LastBlockHash
()
if
lastblockhash
!=
cmlast
{
return
fmt
.
Errorf
(
"lastblockhash validation mismatch: want: %x, have: %x"
,
lastblockhash
,
cmlast
)
}
newDB
,
err
:=
c
m
.
State
()
newDB
,
err
:=
c
hain
.
State
()
if
err
!=
nil
{
return
err
}
...
...
@@ -206,21 +195,17 @@ func runBlockTest(homesteadBlock *big.Int, test *BlockTest) error {
return
fmt
.
Errorf
(
"post state validation failed: %v"
,
err
)
}
return
test
.
ValidateImportedHeaders
(
c
m
,
validBlocks
)
return
test
.
ValidateImportedHeaders
(
c
hain
,
validBlocks
)
}
// InsertPreState populates the given database with the genesis
// accounts defined by the test.
func
(
t
*
BlockTest
)
InsertPreState
(
db
ethdb
.
Database
,
am
*
accounts
.
Manager
)
(
*
state
.
StateDB
,
error
)
{
func
(
t
*
BlockTest
)
InsertPreState
(
db
ethdb
.
Database
)
(
*
state
.
StateDB
,
error
)
{
statedb
,
err
:=
state
.
New
(
common
.
Hash
{},
db
)
if
err
!=
nil
{
return
nil
,
err
}
for
addrString
,
acct
:=
range
t
.
preAccounts
{
addr
,
err
:=
hex
.
DecodeString
(
addrString
)
if
err
!=
nil
{
return
nil
,
err
}
code
,
err
:=
hex
.
DecodeString
(
strings
.
TrimPrefix
(
acct
.
Code
,
"0x"
))
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -233,16 +218,6 @@ func (t *BlockTest) InsertPreState(db ethdb.Database, am *accounts.Manager) (*st
if
err
!=
nil
{
return
nil
,
err
}
if
acct
.
PrivateKey
!=
""
{
privkey
,
err
:=
hex
.
DecodeString
(
strings
.
TrimPrefix
(
acct
.
PrivateKey
,
"0x"
))
err
=
crypto
.
ImportBlockTestKey
(
privkey
)
err
=
am
.
TimedUnlock
(
common
.
BytesToAddress
(
addr
),
""
,
999999
*
time
.
Second
)
if
err
!=
nil
{
return
nil
,
err
}
}
obj
:=
statedb
.
CreateAccount
(
common
.
HexToAddress
(
addrString
))
obj
.
SetCode
(
code
)
obj
.
SetBalance
(
balance
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录