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
1b26d4f2
Commit
1b26d4f2
authored
Jun 10, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flatten helper directory
parent
e8210036
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
70 deletions
+22
-70
common.go
tests/helper/common.go
+0
-11
init.go
tests/helper/init.go
+0
-16
trie.go
tests/helper/trie.go
+0
-31
init.go
tests/init.go
+12
-1
vm.go
tests/vm.go
+3
-3
vm_test_util.go
tests/vm_test_util.go
+7
-8
No files found.
tests/helper/common.go
deleted
100644 → 0
View file @
e8210036
package
helper
import
"github.com/ethereum/go-ethereum/common"
func
FromHex
(
h
string
)
[]
byte
{
if
common
.
IsHex
(
h
)
{
h
=
h
[
2
:
]
}
return
common
.
Hex2Bytes
(
h
)
}
tests/helper/init.go
deleted
100644 → 0
View file @
e8210036
package
helper
import
(
"log"
"os"
logpkg
"github.com/ethereum/go-ethereum/logger"
)
var
Logger
*
logpkg
.
StdLogSystem
var
Log
=
logpkg
.
NewLogger
(
"TEST"
)
func
init
()
{
Logger
=
logpkg
.
NewStdLogSystem
(
os
.
Stdout
,
log
.
LstdFlags
,
logpkg
.
InfoLevel
)
logpkg
.
AddLogSystem
(
Logger
)
}
tests/helper/trie.go
deleted
100644 → 0
View file @
e8210036
package
helper
import
"github.com/ethereum/go-ethereum/trie"
type
MemDatabase
struct
{
db
map
[
string
][]
byte
}
func
NewMemDatabase
()
(
*
MemDatabase
,
error
)
{
db
:=
&
MemDatabase
{
db
:
make
(
map
[
string
][]
byte
)}
return
db
,
nil
}
func
(
db
*
MemDatabase
)
Put
(
key
[]
byte
,
value
[]
byte
)
{
db
.
db
[
string
(
key
)]
=
value
}
func
(
db
*
MemDatabase
)
Get
(
key
[]
byte
)
([]
byte
,
error
)
{
return
db
.
db
[
string
(
key
)],
nil
}
func
(
db
*
MemDatabase
)
Delete
(
key
[]
byte
)
error
{
delete
(
db
.
db
,
string
(
key
))
return
nil
}
func
(
db
*
MemDatabase
)
Print
()
{}
func
(
db
*
MemDatabase
)
Close
()
{}
func
(
db
*
MemDatabase
)
LastKnownTD
()
[]
byte
{
return
nil
}
func
NewTrie
()
*
trie
.
Trie
{
db
,
_
:=
NewMemDatabase
()
return
trie
.
New
(
nil
,
db
)
}
tests/
helper/readers
.go
→
tests/
init
.go
View file @
1b26d4f2
package
helper
package
tests
import
(
import
(
"encoding/json"
"encoding/json"
"io"
"io"
"io/ioutil"
"io/ioutil"
// "log"
"net/http"
"net/http"
"os"
"os"
"testing"
"testing"
// logpkg "github.com/ethereum/go-ethereum/logger"
)
)
// var Logger *logpkg.StdLogSystem
// var Log = logpkg.NewLogger("TEST")
// func init() {
// Logger = logpkg.NewStdLogSystem(os.Stdout, log.LstdFlags, logpkg.InfoLevel)
// logpkg.AddLogSystem(Logger)
// }
func
readJSON
(
t
*
testing
.
T
,
reader
io
.
Reader
,
value
interface
{})
{
func
readJSON
(
t
*
testing
.
T
,
reader
io
.
Reader
,
value
interface
{})
{
data
,
err
:=
ioutil
.
ReadAll
(
reader
)
data
,
err
:=
ioutil
.
ReadAll
(
reader
)
err
=
json
.
Unmarshal
(
data
,
&
value
)
err
=
json
.
Unmarshal
(
data
,
&
value
)
...
...
tests/
helper/
vm.go
→
tests/vm.go
View file @
1b26d4f2
package
helper
package
tests
import
(
import
(
"errors"
"errors"
...
@@ -144,7 +144,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
...
@@ -144,7 +144,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
var
(
var
(
to
=
common
.
HexToAddress
(
exec
[
"address"
])
to
=
common
.
HexToAddress
(
exec
[
"address"
])
from
=
common
.
HexToAddress
(
exec
[
"caller"
])
from
=
common
.
HexToAddress
(
exec
[
"caller"
])
data
=
FromHex
(
exec
[
"data"
])
data
=
common
.
FromHex
(
exec
[
"data"
])
gas
=
common
.
Big
(
exec
[
"gas"
])
gas
=
common
.
Big
(
exec
[
"gas"
])
price
=
common
.
Big
(
exec
[
"gasPrice"
])
price
=
common
.
Big
(
exec
[
"gasPrice"
])
value
=
common
.
Big
(
exec
[
"value"
])
value
=
common
.
Big
(
exec
[
"value"
])
...
@@ -166,7 +166,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
...
@@ -166,7 +166,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
func
RunState
(
statedb
*
state
.
StateDB
,
env
,
tx
map
[
string
]
string
)
([]
byte
,
state
.
Logs
,
*
big
.
Int
,
error
)
{
func
RunState
(
statedb
*
state
.
StateDB
,
env
,
tx
map
[
string
]
string
)
([]
byte
,
state
.
Logs
,
*
big
.
Int
,
error
)
{
var
(
var
(
keyPair
,
_
=
crypto
.
NewKeyPairFromSec
([]
byte
(
common
.
Hex2Bytes
(
tx
[
"secretKey"
])))
keyPair
,
_
=
crypto
.
NewKeyPairFromSec
([]
byte
(
common
.
Hex2Bytes
(
tx
[
"secretKey"
])))
data
=
FromHex
(
tx
[
"data"
])
data
=
common
.
FromHex
(
tx
[
"data"
])
gas
=
common
.
Big
(
tx
[
"gasLimit"
])
gas
=
common
.
Big
(
tx
[
"gasLimit"
])
price
=
common
.
Big
(
tx
[
"gasPrice"
])
price
=
common
.
Big
(
tx
[
"gasPrice"
])
value
=
common
.
Big
(
tx
[
"value"
])
value
=
common
.
Big
(
tx
[
"value"
])
...
...
tests/vm_test_util.go
View file @
1b26d4f2
...
@@ -11,7 +11,6 @@ import (
...
@@ -11,7 +11,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/tests/helper"
)
)
type
Account
struct
{
type
Account
struct
{
...
@@ -52,7 +51,7 @@ func StateObjectFromAccount(db common.Database, addr string, account Account) *s
...
@@ -52,7 +51,7 @@ func StateObjectFromAccount(db common.Database, addr string, account Account) *s
return
obj
return
obj
}
}
type
Env
struct
{
type
Vm
Env
struct
{
CurrentCoinbase
string
CurrentCoinbase
string
CurrentDifficulty
string
CurrentDifficulty
string
CurrentGasLimit
string
CurrentGasLimit
string
...
@@ -64,7 +63,7 @@ type Env struct {
...
@@ -64,7 +63,7 @@ type Env struct {
type
VmTest
struct
{
type
VmTest
struct
{
Callcreates
interface
{}
Callcreates
interface
{}
//Env map[string]string
//Env map[string]string
Env
Env
Env
Vm
Env
Exec
map
[
string
]
string
Exec
map
[
string
]
string
Transaction
map
[
string
]
string
Transaction
map
[
string
]
string
Logs
[]
Log
Logs
[]
Log
...
@@ -78,7 +77,7 @@ type VmTest struct {
...
@@ -78,7 +77,7 @@ type VmTest struct {
func
RunVmTest
(
p
string
,
t
*
testing
.
T
)
{
func
RunVmTest
(
p
string
,
t
*
testing
.
T
)
{
tests
:=
make
(
map
[
string
]
VmTest
)
tests
:=
make
(
map
[
string
]
VmTest
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
/*
/*
...
@@ -121,9 +120,9 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -121,9 +120,9 @@ func RunVmTest(p string, t *testing.T) {
isVmTest
:=
len
(
test
.
Exec
)
>
0
isVmTest
:=
len
(
test
.
Exec
)
>
0
if
isVmTest
{
if
isVmTest
{
ret
,
logs
,
gas
,
err
=
helper
.
RunVm
(
statedb
,
env
,
test
.
Exec
)
ret
,
logs
,
gas
,
err
=
RunVm
(
statedb
,
env
,
test
.
Exec
)
}
else
{
}
else
{
ret
,
logs
,
gas
,
err
=
helper
.
RunState
(
statedb
,
env
,
test
.
Transaction
)
ret
,
logs
,
gas
,
err
=
RunState
(
statedb
,
env
,
test
.
Transaction
)
}
}
switch
name
{
switch
name
{
...
@@ -131,7 +130,7 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -131,7 +130,7 @@ func RunVmTest(p string, t *testing.T) {
// on 19 May 2015 decided to skip these tests their output.
// on 19 May 2015 decided to skip these tests their output.
case
"mload32bitBound_return"
,
"mload32bitBound_return2"
:
case
"mload32bitBound_return"
,
"mload32bitBound_return2"
:
default
:
default
:
rexp
:=
helper
.
FromHex
(
test
.
Out
)
rexp
:=
common
.
FromHex
(
test
.
Out
)
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
t
.
Errorf
(
"%s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
t
.
Errorf
(
"%s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
}
}
...
@@ -192,7 +191,7 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -192,7 +191,7 @@ func RunVmTest(p string, t *testing.T) {
t
.
Errorf
(
"'%s' log address expected %v got %x"
,
name
,
log
.
AddressF
,
logs
[
i
]
.
Address
)
t
.
Errorf
(
"'%s' log address expected %v got %x"
,
name
,
log
.
AddressF
,
logs
[
i
]
.
Address
)
}
}
if
!
bytes
.
Equal
(
logs
[
i
]
.
Data
,
helper
.
FromHex
(
log
.
DataF
))
{
if
!
bytes
.
Equal
(
logs
[
i
]
.
Data
,
common
.
FromHex
(
log
.
DataF
))
{
t
.
Errorf
(
"'%s' log data expected %v got %x"
,
name
,
log
.
DataF
,
logs
[
i
]
.
Data
)
t
.
Errorf
(
"'%s' log data expected %v got %x"
,
name
,
log
.
DataF
,
logs
[
i
]
.
Data
)
}
}
...
...
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