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
2dacb51f
Commit
2dacb51f
authored
Mar 09, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/blocktest: simplify to fix build
block tests only need the chain, not all of ethereum.
parent
6684ef20
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
189 deletions
+34
-189
flags.go
cmd/blocktest/flags.go
+0
-41
main.go
cmd/blocktest/main.go
+34
-148
No files found.
cmd/blocktest/flags.go
deleted
100644 → 0
View file @
6684ef20
/*
This file is part of go-ethereum
go-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
go-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @authors
* Gustav Simonsson <gustav.simonsson@gmail.com>
*/
package
main
import
(
"flag"
"fmt"
"os"
)
var
(
TestFile
string
)
func
Init
()
{
flag
.
Usage
=
func
()
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%s <testfile>
\n
"
,
os
.
Args
[
0
])
flag
.
PrintDefaults
()
}
flag
.
Parse
()
TestFile
=
flag
.
Arg
(
0
)
}
cmd/blocktest/main.go
View file @
2dacb51f
...
...
@@ -25,34 +25,26 @@ package main
import
(
"bytes"
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"math/big"
"
path
"
"
os
"
"runtime"
"strconv"
"strings"
"time"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/core"
types
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/e
thutil
"
"github.com/ethereum/go-ethereum/eth
db
"
"github.com/ethereum/go-ethereum/e
vent
"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/ethereum/go-ethereum/rlp"
)
const
(
ClientIdentifier
=
"Ethereum(G)"
Version
=
"0.8.6"
)
type
Account
struct
{
Balance
string
Code
string
...
...
@@ -78,6 +70,7 @@ type BlockHeader struct {
TransactionsTrie
string
UncleHash
string
}
type
Tx
struct
{
Data
string
GasLimit
string
...
...
@@ -103,103 +96,40 @@ type Test struct {
Pre
map
[
string
]
Account
}
var
(
Identifier
string
KeyRing
string
DiffTool
bool
DiffType
string
KeyStore
string
StartRpc
bool
StartWebSockets
bool
RpcListenAddress
string
RpcPort
int
WsPort
int
OutboundPort
string
ShowGenesis
bool
AddPeer
string
MaxPeer
int
GenAddr
bool
BootNodes
string
NodeKey
*
ecdsa
.
PrivateKey
NAT
nat
.
Interface
SecretFile
string
ExportDir
string
NonInteractive
bool
Datadir
string
LogFile
string
ConfigFile
string
DebugFile
string
LogLevel
int
LogFormat
string
Dump
bool
DumpHash
string
DumpNumber
int
VmType
int
ImportChain
string
SHH
bool
Dial
bool
PrintVersion
bool
MinerThreads
int
)
// flags specific to cli client
var
(
StartMining
bool
StartJsConsole
bool
InputFile
string
)
func
main
()
{
init_vars
()
flag
.
Usage
=
func
()
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%s <testfile>
\n
"
,
os
.
Args
[
0
])
flag
.
PrintDefaults
()
}
flag
.
Parse
()
Init
()
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
logger
.
AddLogSystem
(
logger
.
NewStdLogSystem
(
os
.
Stderr
,
log
.
LstdFlags
,
logger
.
DebugDetailLevel
))
defer
func
()
{
logger
.
Flush
()
}()
if
len
(
TestFile
)
<
1
{
log
.
Fatal
(
"Please specify test file
"
)
if
len
(
os
.
Args
)
<
2
{
utils
.
Fatalf
(
"Please specify a test file as the first argument.
"
)
}
blocks
,
err
:=
loadBlocksFromTestFile
(
TestFile
)
blocks
,
err
:=
loadBlocksFromTestFile
(
os
.
Args
[
1
]
)
if
err
!=
nil
{
panic
(
err
)
utils
.
Fatalf
(
"Could not load blocks: %v"
,
err
)
}
runtime
.
GOMAXPROCS
(
runtime
.
NumCPU
())
chain
:=
memchain
()
chain
.
ResetWithGenesisBlock
(
blocks
[
0
])
if
err
=
chain
.
InsertChain
(
types
.
Blocks
{
blocks
[
1
]});
err
!=
nil
{
utils
.
Fatalf
(
"Error: %v"
,
err
)
}
else
{
fmt
.
Println
(
"PASS"
)
}
}
defer
func
()
{
logger
.
Flush
()
}()
utils
.
HandleInterrupt
()
utils
.
InitConfig
(
VmType
,
ConfigFile
,
Datadir
,
"ethblocktest"
)
ethereum
,
err
:=
eth
.
New
(
&
eth
.
Config
{
Name
:
p2p
.
MakeName
(
ClientIdentifier
,
Version
),
KeyStore
:
KeyStore
,
DataDir
:
Datadir
,
LogFile
:
LogFile
,
LogLevel
:
LogLevel
,
LogFormat
:
LogFormat
,
MaxPeers
:
MaxPeer
,
Port
:
OutboundPort
,
NAT
:
NAT
,
KeyRing
:
KeyRing
,
Shh
:
true
,
Dial
:
Dial
,
BootNodes
:
BootNodes
,
NodeKey
:
NodeKey
,
MinerThreads
:
MinerThreads
,
})
utils
.
StartRpc
(
ethereum
,
RpcListenAddress
,
RpcPort
)
utils
.
StartEthereum
(
ethereum
)
ethereum
.
ChainManager
()
.
ResetWithGenesisBlock
(
blocks
[
0
])
// fmt.Println("HURR: ", hex.EncodeToString(ethutil.Encode(blocks[0].RlpData())))
go
ethereum
.
ChainManager
()
.
InsertChain
(
types
.
Blocks
{
blocks
[
1
]})
fmt
.
Println
(
"OK! "
)
ethereum
.
WaitForShutdown
()
func
memchain
()
*
core
.
ChainManager
{
db
,
err
:=
ethdb
.
NewMemDatabase
()
if
err
!=
nil
{
utils
.
Fatalf
(
"Could not create in-memory database: %v"
,
err
)
}
return
core
.
NewChainManager
(
db
,
new
(
event
.
TypeMux
))
}
func
loadBlocksFromTestFile
(
filePath
string
)
(
blocks
types
.
Blocks
,
err
error
)
{
...
...
@@ -207,9 +137,8 @@ func loadBlocksFromTestFile(filePath string) (blocks types.Blocks, err error) {
if
err
!=
nil
{
return
}
bt
:=
*
new
(
map
[
string
]
Test
)
err
=
json
.
Unmarshal
(
fileContent
,
&
bt
)
if
err
!=
nil
{
bt
:=
make
(
map
[
string
]
Test
)
if
err
=
json
.
Unmarshal
(
fileContent
,
&
bt
);
err
!=
nil
{
return
}
...
...
@@ -272,49 +201,6 @@ func loadBlocksFromTestFile(filePath string) (blocks types.Blocks, err error) {
return
}
func
init_vars
()
{
VmType
=
0
Identifier
=
""
KeyRing
=
""
KeyStore
=
"db"
RpcListenAddress
=
"127.0.0.1"
RpcPort
=
8545
WsPort
=
40404
StartRpc
=
true
StartWebSockets
=
false
NonInteractive
=
false
GenAddr
=
false
SecretFile
=
""
ExportDir
=
""
LogFile
=
""
timeStr
:=
strconv
.
FormatInt
(
time
.
Now
()
.
UnixNano
(),
10
)
Datadir
=
path
.
Join
(
ethutil
.
DefaultDataDir
(),
timeStr
)
ConfigFile
=
path
.
Join
(
ethutil
.
DefaultDataDir
(),
timeStr
,
"conf.ini"
)
DebugFile
=
""
LogLevel
=
5
LogFormat
=
"std"
DiffTool
=
false
DiffType
=
"all"
ShowGenesis
=
false
ImportChain
=
""
Dump
=
false
DumpHash
=
""
DumpNumber
=
-
1
StartMining
=
false
StartJsConsole
=
false
PrintVersion
=
false
MinerThreads
=
runtime
.
NumCPU
()
Dial
=
false
OutboundPort
=
"30303"
BootNodes
=
""
MaxPeer
=
1
}
func
hex_decode
(
s
string
)
(
res
[]
byte
,
err
error
)
{
return
hex
.
DecodeString
(
strings
.
TrimPrefix
(
s
,
"0x"
))
}
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