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
67f8f83a
Commit
67f8f83a
authored
Mar 13, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/ethereum: add blocktest command
parent
e463479b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
blocktest.go
cmd/ethereum/blocktest.go
+66
-0
main.go
cmd/ethereum/main.go
+1
-0
No files found.
cmd/ethereum/blocktest.go
0 → 100644
View file @
67f8f83a
package
main
import
(
"fmt"
"github.com/codegangsta/cli"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/tests"
)
var
blocktestCmd
=
cli
.
Command
{
Action
:
runblocktest
,
Name
:
"blocktest"
,
Usage
:
`loads a block test file`
,
Description
:
`
The first argument should be a block test file.
The second argument is the name of a block test from the file.
The block test will be loaded into an in-memory database.
If loading succeeds, the RPC server is started. Clients will
be able to interact with the chain defined by the test.
`
,
}
func
runblocktest
(
ctx
*
cli
.
Context
)
{
if
len
(
ctx
.
Args
())
!=
2
{
utils
.
Fatalf
(
"This command requires two arguments."
)
}
file
,
testname
:=
ctx
.
Args
()[
0
],
ctx
.
Args
()[
1
]
bt
,
err
:=
tests
.
LoadBlockTests
(
file
)
if
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
test
,
ok
:=
bt
[
testname
]
if
!
ok
{
utils
.
Fatalf
(
"Test file does not contain test named %q"
,
testname
)
}
cfg
:=
utils
.
MakeEthConfig
(
ClientIdentifier
,
Version
,
ctx
)
cfg
.
NewDB
=
func
(
path
string
)
(
ethutil
.
Database
,
error
)
{
return
ethdb
.
NewMemDatabase
()
}
ethereum
,
err
:=
eth
.
New
(
cfg
)
if
err
!=
nil
{
utils
.
Fatalf
(
"%v"
,
err
)
}
// import the genesis block
ethereum
.
ResetWithGenesisBlock
(
test
.
Genesis
)
// import pre accounts
if
err
:=
test
.
InsertPreState
(
ethereum
.
StateDb
());
err
!=
nil
{
utils
.
Fatalf
(
"could not insert genesis accounts: %v"
,
err
)
}
// insert the test blocks, which will execute all transactions
chain
:=
ethereum
.
ChainManager
()
if
err
:=
chain
.
InsertChain
(
test
.
Blocks
);
err
!=
nil
{
utils
.
Fatalf
(
"Block Test load error: %v"
,
err
)
}
else
{
fmt
.
Println
(
"Block Test chain loaded, starting ethereum."
)
}
startEth
(
ctx
,
ethereum
)
}
cmd/ethereum/main.go
View file @
67f8f83a
...
@@ -53,6 +53,7 @@ func init() {
...
@@ -53,6 +53,7 @@ func init() {
app
.
Action
=
run
app
.
Action
=
run
app
.
HideVersion
=
true
// we have a command to print the version
app
.
HideVersion
=
true
// we have a command to print the version
app
.
Commands
=
[]
cli
.
Command
{
app
.
Commands
=
[]
cli
.
Command
{
blocktestCmd
,
{
{
Action
:
version
,
Action
:
version
,
Name
:
"version"
,
Name
:
"version"
,
...
...
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