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
b619b244
Commit
b619b244
authored
Jan 02, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed tests
parent
a4dc12f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
chain_manager_test.go
core/chain_manager_test.go
+11
-4
No files found.
core/chain_manager_test.go
View file @
b619b244
...
@@ -27,6 +27,9 @@ func init() {
...
@@ -27,6 +27,9 @@ func init() {
ethutil
.
ReadConfig
(
"/tmp/ethtest"
,
"/tmp/ethtest"
,
"ETH"
)
ethutil
.
ReadConfig
(
"/tmp/ethtest"
,
"/tmp/ethtest"
,
"ETH"
)
}
func
reset
()
{
db
,
err
:=
ethdb
.
NewMemDatabase
()
db
,
err
:=
ethdb
.
NewMemDatabase
()
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
"Could not create mem-db, failing"
)
panic
(
"Could not create mem-db, failing"
)
...
@@ -51,20 +54,21 @@ func loadChain(fn string, t *testing.T) (types.Blocks, error) {
...
@@ -51,20 +54,21 @@ func loadChain(fn string, t *testing.T) (types.Blocks, error) {
func
insertChain
(
done
chan
bool
,
chainMan
*
ChainManager
,
chain
types
.
Blocks
,
t
*
testing
.
T
)
{
func
insertChain
(
done
chan
bool
,
chainMan
*
ChainManager
,
chain
types
.
Blocks
,
t
*
testing
.
T
)
{
err
:=
chainMan
.
InsertChain
(
chain
)
err
:=
chainMan
.
InsertChain
(
chain
)
done
<-
true
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
t
.
FailNow
()
t
.
FailNow
()
}
}
done
<-
true
}
}
func
TestChainInsertions
(
t
*
testing
.
T
)
{
func
TestChainInsertions
(
t
*
testing
.
T
)
{
reset
()
chain1
,
err
:=
loadChain
(
"valid1"
,
t
)
chain1
,
err
:=
loadChain
(
"valid1"
,
t
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
t
.
FailNow
()
t
.
FailNow
()
}
}
fmt
.
Println
(
len
(
chain1
))
chain2
,
err
:=
loadChain
(
"valid2"
,
t
)
chain2
,
err
:=
loadChain
(
"valid2"
,
t
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -98,6 +102,8 @@ func TestChainInsertions(t *testing.T) {
...
@@ -98,6 +102,8 @@ func TestChainInsertions(t *testing.T) {
}
}
func
TestChainMultipleInsertions
(
t
*
testing
.
T
)
{
func
TestChainMultipleInsertions
(
t
*
testing
.
T
)
{
reset
()
const
max
=
4
const
max
=
4
chains
:=
make
([]
types
.
Blocks
,
max
)
chains
:=
make
([]
types
.
Blocks
,
max
)
var
longest
int
var
longest
int
...
@@ -114,7 +120,6 @@ func TestChainMultipleInsertions(t *testing.T) {
...
@@ -114,7 +120,6 @@ func TestChainMultipleInsertions(t *testing.T) {
t
.
FailNow
()
t
.
FailNow
()
}
}
}
}
var
eventMux
event
.
TypeMux
var
eventMux
event
.
TypeMux
chainMan
:=
NewChainManager
(
&
eventMux
)
chainMan
:=
NewChainManager
(
&
eventMux
)
txPool
:=
NewTxPool
(
chainMan
,
&
eventMux
)
txPool
:=
NewTxPool
(
chainMan
,
&
eventMux
)
...
@@ -122,7 +127,9 @@ func TestChainMultipleInsertions(t *testing.T) {
...
@@ -122,7 +127,9 @@ func TestChainMultipleInsertions(t *testing.T) {
chainMan
.
SetProcessor
(
blockMan
)
chainMan
.
SetProcessor
(
blockMan
)
done
:=
make
(
chan
bool
,
max
)
done
:=
make
(
chan
bool
,
max
)
for
i
,
chain
:=
range
chains
{
for
i
,
chain
:=
range
chains
{
var
i
int
=
i
// XXX the go routine would otherwise reference the same (chain[3]) variable and fail
i
:=
i
chain
:=
chain
go
func
()
{
go
func
()
{
insertChain
(
done
,
chainMan
,
chain
,
t
)
insertChain
(
done
,
chainMan
,
chain
,
t
)
fmt
.
Println
(
i
,
"done"
)
fmt
.
Println
(
i
,
"done"
)
...
...
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