Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
whqwjb
go-ethereum
提交
a59dd393
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 搜索 >>
提交
a59dd393
编写于
3月 18, 2015
作者:
F
Felix Lange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: fix tests
上级
b5b83db4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
13 addition
and
19 deletion
+13
-19
core/block_processor_test.go
core/block_processor_test.go
+3
-2
core/chain_manager_test.go
core/chain_manager_test.go
+4
-5
core/genesis.go
core/genesis.go
+0
-4
core/transaction_pool.go
core/transaction_pool.go
+1
-1
core/transaction_pool_test.go
core/transaction_pool_test.go
+5
-7
未找到文件。
core/block_processor_test.go
浏览文件 @
a59dd393
...
...
@@ -4,6 +4,7 @@ import (
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/pow/ezp"
...
...
@@ -19,7 +20,7 @@ func proc() (*BlockProcessor, *ChainManager) {
func
TestNumber
(
t
*
testing
.
T
)
{
bp
,
chain
:=
proc
()
block1
:=
chain
.
NewBlock
(
nil
)
block1
:=
chain
.
NewBlock
(
common
.
Address
{}
)
block1
.
Header
()
.
Number
=
big
.
NewInt
(
3
)
err
:=
bp
.
ValidateHeader
(
block1
.
Header
(),
chain
.
Genesis
()
.
Header
())
...
...
@@ -27,7 +28,7 @@ func TestNumber(t *testing.T) {
t
.
Errorf
(
"expected block number error"
)
}
block1
=
chain
.
NewBlock
(
nil
)
block1
=
chain
.
NewBlock
(
common
.
Address
{}
)
err
=
bp
.
ValidateHeader
(
block1
.
Header
(),
chain
.
Genesis
()
.
Header
())
if
err
==
BlockNumberErr
{
t
.
Errorf
(
"didn't expect block number error"
)
...
...
core/chain_manager_test.go
浏览文件 @
a59dd393
package
core
import
(
"bytes"
"fmt"
"math/big"
"os"
...
...
@@ -35,7 +34,7 @@ func testFork(t *testing.T, bman *BlockProcessor, i, N int, f func(td1, td2 *big
// asert the bmans have the same block at i
bi1
:=
bman
.
bc
.
GetBlockByNumber
(
uint64
(
i
))
.
Hash
()
bi2
:=
bman2
.
bc
.
GetBlockByNumber
(
uint64
(
i
))
.
Hash
()
if
b
ytes
.
Compare
(
bi1
,
bi2
)
!=
0
{
if
b
i1
!=
bi2
{
t
.
Fatal
(
"chains do not have the same hash at height"
,
i
)
}
...
...
@@ -270,11 +269,11 @@ func TestChainInsertions(t *testing.T) {
<-
done
}
if
bytes
.
Equal
(
chain2
[
len
(
chain2
)
-
1
]
.
Hash
(),
chainMan
.
CurrentBlock
()
.
Hash
()
)
{
if
chain2
[
len
(
chain2
)
-
1
]
.
Hash
()
!=
chainMan
.
CurrentBlock
()
.
Hash
(
)
{
t
.
Error
(
"chain2 is canonical and shouldn't be"
)
}
if
!
bytes
.
Equal
(
chain1
[
len
(
chain1
)
-
1
]
.
Hash
(),
chainMan
.
CurrentBlock
()
.
Hash
()
)
{
if
chain1
[
len
(
chain1
)
-
1
]
.
Hash
()
!=
chainMan
.
CurrentBlock
()
.
Hash
(
)
{
t
.
Error
(
"chain1 isn't canonical and should be"
)
}
}
...
...
@@ -320,7 +319,7 @@ func TestChainMultipleInsertions(t *testing.T) {
<-
done
}
if
!
bytes
.
Equal
(
chains
[
longest
][
len
(
chains
[
longest
])
-
1
]
.
Hash
(),
chainMan
.
CurrentBlock
()
.
Hash
()
)
{
if
chains
[
longest
][
len
(
chains
[
longest
])
-
1
]
.
Hash
()
!=
chainMan
.
CurrentBlock
()
.
Hash
(
)
{
t
.
Error
(
"Invalid canonical chain"
)
}
}
...
...
core/genesis.go
浏览文件 @
a59dd393
...
...
@@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/state"
)
...
...
@@ -19,9 +18,6 @@ import (
var
ZeroHash256
=
make
([]
byte
,
32
)
var
ZeroHash160
=
make
([]
byte
,
20
)
var
ZeroHash512
=
make
([]
byte
,
64
)
var
EmptyShaList
=
crypto
.
Sha3
(
common
.
Encode
([]
interface
{}{}))
var
EmptyListRoot
=
crypto
.
Sha3
(
common
.
Encode
(
""
))
var
GenesisDiff
=
big
.
NewInt
(
131072
)
var
GenesisGasLimit
=
big
.
NewInt
(
3141592
)
...
...
core/transaction_pool.go
浏览文件 @
a59dd393
...
...
@@ -63,7 +63,7 @@ func NewTxPool(eventMux *event.TypeMux) *TxPool {
func
(
pool
*
TxPool
)
ValidateTransaction
(
tx
*
types
.
Transaction
)
error
{
// Validate sender
if
_
,
err
:=
tx
.
From
();
err
!=
nil
{
return
er
r
return
ErrInvalidSende
r
}
// Validate curve param
v
,
_
,
_
:=
tx
.
Curve
()
...
...
core/transaction_pool_test.go
浏览文件 @
a59dd393
...
...
@@ -4,10 +4,10 @@ import (
"crypto/ecdsa"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/state"
)
...
...
@@ -21,11 +21,11 @@ func SQ() stateQuery {
}
func
(
self
stateQuery
)
GetAccount
(
addr
[]
byte
)
*
state
.
StateObject
{
return
state
.
NewStateObject
(
addr
,
self
.
db
)
return
state
.
NewStateObject
(
common
.
BytesToAddress
(
addr
)
,
self
.
db
)
}
func
transaction
()
*
types
.
Transaction
{
return
types
.
NewTransactionMessage
(
make
([]
byte
,
20
)
,
common
.
Big0
,
common
.
Big0
,
common
.
Big0
,
nil
)
return
types
.
NewTransactionMessage
(
common
.
Address
{}
,
common
.
Big0
,
common
.
Big0
,
common
.
Big0
,
nil
)
}
func
setup
()
(
*
TxPool
,
*
ecdsa
.
PrivateKey
)
{
...
...
@@ -88,10 +88,8 @@ func TestRemoveInvalid(t *testing.T) {
func
TestInvalidSender
(
t
*
testing
.
T
)
{
pool
,
_
:=
setup
()
tx
:=
new
(
types
.
Transaction
)
tx
.
V
=
28
err
:=
pool
.
ValidateTransaction
(
tx
)
err
:=
pool
.
ValidateTransaction
(
new
(
types
.
Transaction
))
if
err
!=
ErrInvalidSender
{
t
.
Error
(
"expected %v, got %v"
,
ErrInvalidSender
,
err
)
t
.
Error
f
(
"expected %v, got %v"
,
ErrInvalidSender
,
err
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录