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
3308491c
Commit
3308491c
authored
Dec 09, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed tests because they've become obsolete
parent
9ff7be68
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
115 deletions
+0
-115
chain_manager_test.go
core/chain_manager_test.go
+0
-115
No files found.
core/chain_manager_test.go
View file @
3308491c
package
core
package
core
import
(
"fmt"
"math/big"
"testing"
"time"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
)
var
TD
*
big
.
Int
func
init
()
{
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
Config
.
Db
,
_
=
ethdb
.
NewMemDatabase
()
}
type
fakeproc
struct
{
}
func
(
self
fakeproc
)
ProcessWithParent
(
a
,
b
*
types
.
Block
)
(
*
big
.
Int
,
state
.
Messages
,
error
)
{
TD
=
new
(
big
.
Int
)
.
Add
(
TD
,
big
.
NewInt
(
1
))
return
TD
,
nil
,
nil
}
func
makechain
(
cman
*
ChainManager
,
max
int
)
*
BlockChain
{
blocks
:=
make
(
types
.
Blocks
,
max
)
for
i
:=
0
;
i
<
max
;
i
++
{
addr
:=
ethutil
.
LeftPadBytes
([]
byte
{
byte
(
i
)},
20
)
block
:=
cman
.
NewBlock
(
addr
)
if
i
!=
0
{
cman
.
CurrentBlock
=
blocks
[
i
-
1
]
}
blocks
[
i
]
=
block
}
return
NewChain
(
blocks
)
}
func
TestLongerFork
(
t
*
testing
.
T
)
{
cman
:=
NewChainManager
()
cman
.
SetProcessor
(
fakeproc
{})
TD
=
big
.
NewInt
(
1
)
chainA
:=
makechain
(
cman
,
5
)
TD
=
big
.
NewInt
(
1
)
chainB
:=
makechain
(
cman
,
10
)
td
,
err
:=
cman
.
TestChain
(
chainA
)
if
err
!=
nil
{
t
.
Error
(
"unable to create new TD from chainA:"
,
err
)
}
cman
.
TD
=
td
_
,
err
=
cman
.
TestChain
(
chainB
)
if
err
!=
nil
{
t
.
Error
(
"expected chainB not to give errors:"
,
err
)
}
}
func
TestEqualFork
(
t
*
testing
.
T
)
{
cman
:=
NewChainManager
()
cman
.
SetProcessor
(
fakeproc
{})
TD
=
big
.
NewInt
(
1
)
chainA
:=
makechain
(
cman
,
5
)
TD
=
big
.
NewInt
(
2
)
chainB
:=
makechain
(
cman
,
5
)
td
,
err
:=
cman
.
TestChain
(
chainA
)
if
err
!=
nil
{
t
.
Error
(
"unable to create new TD from chainA:"
,
err
)
}
cman
.
TD
=
td
_
,
err
=
cman
.
TestChain
(
chainB
)
if
err
!=
nil
{
t
.
Error
(
"expected chainB not to give errors:"
,
err
)
}
}
func
TestBrokenChain
(
t
*
testing
.
T
)
{
cman
:=
NewChainManager
()
cman
.
SetProcessor
(
fakeproc
{})
TD
=
big
.
NewInt
(
1
)
chain
:=
makechain
(
cman
,
5
)
chain
.
Remove
(
chain
.
Front
())
_
,
err
:=
cman
.
TestChain
(
chain
)
if
err
==
nil
{
t
.
Error
(
"expected broken chain to return error"
)
}
}
func
BenchmarkChainTesting
(
b
*
testing
.
B
)
{
const
chainlen
=
1000
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
Config
.
Db
,
_
=
ethdb
.
NewMemDatabase
()
cman
:=
NewChainManager
()
cman
.
SetProcessor
(
fakeproc
{})
TD
=
big
.
NewInt
(
1
)
chain
:=
makechain
(
cman
,
chainlen
)
stime
:=
time
.
Now
()
cman
.
TestChain
(
chain
)
fmt
.
Println
(
chainlen
,
"took"
,
time
.
Since
(
stime
))
}
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