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
c8438979
Commit
c8438979
authored
Nov 01, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
parents
141d3caa
394e0f60
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
74 additions
and
72 deletions
+74
-72
.gitignore
.gitignore
+1
-0
bloom9_test.go
chain/bloom9_test.go
+4
-2
helper_test.go
chain/helper_test.go
+5
-5
main.go
cmd/ethereum/main.go
+1
-2
server.go
p2p/server.go
+2
-2
block.go
pow/ar/block.go
+2
-2
pow_test.go
pow/ar/pow_test.go
+4
-4
rnd.go
pow/ar/rnd.go
+4
-4
state_test.go
state/state_test.go
+2
-2
main.go
tests/ethtest/main.go
+4
-4
init.go
tests/helper/init.go
+5
-5
trie.go
tests/helper/trie.go
+3
-3
vm.go
tests/helper/vm.go
+15
-15
gh_test.go
tests/vm/gh_test.go
+4
-4
vm_test.go
vm/vm_test.go
+18
-18
No files found.
.gitignore
View file @
c8438979
...
@@ -9,3 +9,4 @@
...
@@ -9,3 +9,4 @@
*un~
*un~
.DS_Store
.DS_Store
*/**/.DS_Store
*/**/.DS_Store
.ethtest
chain/bloom9_test.go
View file @
c8438979
...
@@ -3,12 +3,14 @@ package chain
...
@@ -3,12 +3,14 @@ package chain
import
(
import
(
"testing"
"testing"
"github.com/ethereum/go-ethereum/
vm
"
"github.com/ethereum/go-ethereum/
state
"
)
)
func
TestBloom9
(
t
*
testing
.
T
)
{
func
TestBloom9
(
t
*
testing
.
T
)
{
testCase
:=
[]
byte
(
"testtest"
)
testCase
:=
[]
byte
(
"testtest"
)
bin
:=
LogsBloom
([]
vm
.
Log
{
vm
.
Log
{
testCase
,
[][]
byte
{[]
byte
(
"hellohello"
)},
nil
}})
.
Bytes
()
bin
:=
LogsBloom
([]
state
.
Log
{
{
testCase
,
[][]
byte
{[]
byte
(
"hellohello"
)},
nil
},
})
.
Bytes
()
res
:=
BloomLookup
(
bin
,
testCase
)
res
:=
BloomLookup
(
bin
,
testCase
)
if
!
res
{
if
!
res
{
...
...
chain/helper_test.go
View file @
c8438979
...
@@ -4,11 +4,11 @@ import (
...
@@ -4,11 +4,11 @@ import (
"container/list"
"container/list"
"fmt"
"fmt"
"github.com/ethereum/go-ethereum/
eth
crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethwire"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/wire"
)
)
// Implement our EthTest Manager
// Implement our EthTest Manager
...
@@ -53,14 +53,14 @@ func (tm *TestManager) StateManager() *StateManager {
...
@@ -53,14 +53,14 @@ func (tm *TestManager) StateManager() *StateManager {
func
(
tm
*
TestManager
)
EventMux
()
*
event
.
TypeMux
{
func
(
tm
*
TestManager
)
EventMux
()
*
event
.
TypeMux
{
return
tm
.
eventMux
return
tm
.
eventMux
}
}
func
(
tm
*
TestManager
)
Broadcast
(
msgType
eth
wire
.
MsgType
,
data
[]
interface
{})
{
func
(
tm
*
TestManager
)
Broadcast
(
msgType
wire
.
MsgType
,
data
[]
interface
{})
{
fmt
.
Println
(
"Broadcast not implemented"
)
fmt
.
Println
(
"Broadcast not implemented"
)
}
}
func
(
tm
*
TestManager
)
ClientIdentity
()
eth
wire
.
ClientIdentity
{
func
(
tm
*
TestManager
)
ClientIdentity
()
wire
.
ClientIdentity
{
return
nil
return
nil
}
}
func
(
tm
*
TestManager
)
KeyManager
()
*
eth
crypto
.
KeyManager
{
func
(
tm
*
TestManager
)
KeyManager
()
*
crypto
.
KeyManager
{
return
nil
return
nil
}
}
...
...
cmd/ethereum/main.go
View file @
c8438979
...
@@ -26,7 +26,6 @@ import (
...
@@ -26,7 +26,6 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethgo.old/ethlog"
)
)
const
(
const
(
...
@@ -131,5 +130,5 @@ func main() {
...
@@ -131,5 +130,5 @@ func main() {
// this blocks the thread
// this blocks the thread
ethereum
.
WaitForShutdown
()
ethereum
.
WaitForShutdown
()
ethlog
.
Flush
()
logger
.
Flush
()
}
}
p2p/server.go
View file @
c8438979
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
"sync"
"sync"
"time"
"time"
"github.com/ethereum/eth-go/ethlog
"
logpkg
"github.com/ethereum/go-ethereum/logger
"
)
)
const
(
const
(
...
@@ -93,7 +93,7 @@ type Server struct {
...
@@ -93,7 +93,7 @@ type Server struct {
handlers
Handlers
handlers
Handlers
}
}
var
logger
=
ethlo
g
.
NewLogger
(
"P2P"
)
var
logger
=
logpk
g
.
NewLogger
(
"P2P"
)
func
New
(
network
Network
,
addr
net
.
Addr
,
identity
ClientIdentity
,
handlers
Handlers
,
maxPeers
int
,
blacklist
Blacklist
)
*
Server
{
func
New
(
network
Network
,
addr
net
.
Addr
,
identity
ClientIdentity
,
handlers
Handlers
,
maxPeers
int
,
blacklist
Blacklist
)
*
Server
{
// get alphabetical list of protocol names from handlers map
// get alphabetical list of protocol names from handlers map
...
...
pow/ar/block.go
View file @
c8438979
...
@@ -3,10 +3,10 @@ package ar
...
@@ -3,10 +3,10 @@ package ar
import
(
import
(
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/
eth
trie"
"github.com/ethereum/go-ethereum/trie"
)
)
type
Block
interface
{
type
Block
interface
{
Trie
()
*
eth
trie
.
Trie
Trie
()
*
trie
.
Trie
Diff
()
*
big
.
Int
Diff
()
*
big
.
Int
}
}
pow/ar/pow_test.go
View file @
c8438979
...
@@ -6,17 +6,17 @@ import (
...
@@ -6,17 +6,17 @@ import (
"testing"
"testing"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/
eth
trie"
"github.com/ethereum/go-ethereum/trie"
)
)
type
TestBlock
struct
{
type
TestBlock
struct
{
trie
*
eth
trie
.
Trie
trie
*
trie
.
Trie
}
}
func
NewTestBlock
()
*
TestBlock
{
func
NewTestBlock
()
*
TestBlock
{
db
,
_
:=
ethdb
.
NewMemDatabase
()
db
,
_
:=
ethdb
.
NewMemDatabase
()
return
&
TestBlock
{
return
&
TestBlock
{
trie
:
eth
trie
.
New
(
db
,
""
),
trie
:
trie
.
New
(
db
,
""
),
}
}
}
}
...
@@ -24,7 +24,7 @@ func (self *TestBlock) Diff() *big.Int {
...
@@ -24,7 +24,7 @@ func (self *TestBlock) Diff() *big.Int {
return
b
(
10
)
return
b
(
10
)
}
}
func
(
self
*
TestBlock
)
Trie
()
*
eth
trie
.
Trie
{
func
(
self
*
TestBlock
)
Trie
()
*
trie
.
Trie
{
return
self
.
trie
return
self
.
trie
}
}
...
...
pow/ar/rnd.go
View file @
c8438979
...
@@ -3,7 +3,7 @@ package ar
...
@@ -3,7 +3,7 @@ package ar
import
(
import
(
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/
eth
crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
)
)
...
@@ -21,16 +21,16 @@ func (self ByteNode) Big() *big.Int {
...
@@ -21,16 +21,16 @@ func (self ByteNode) Big() *big.Int {
func
Sha3
(
v
interface
{})
*
big
.
Int
{
func
Sha3
(
v
interface
{})
*
big
.
Int
{
if
b
,
ok
:=
v
.
(
*
big
.
Int
);
ok
{
if
b
,
ok
:=
v
.
(
*
big
.
Int
);
ok
{
return
ethutil
.
BigD
(
eth
crypto
.
Sha3
(
b
.
Bytes
()))
return
ethutil
.
BigD
(
crypto
.
Sha3
(
b
.
Bytes
()))
}
else
if
b
,
ok
:=
v
.
([]
interface
{});
ok
{
}
else
if
b
,
ok
:=
v
.
([]
interface
{});
ok
{
return
ethutil
.
BigD
(
eth
crypto
.
Sha3
(
ethutil
.
Encode
(
b
)))
return
ethutil
.
BigD
(
crypto
.
Sha3
(
ethutil
.
Encode
(
b
)))
}
else
if
s
,
ok
:=
v
.
([]
*
big
.
Int
);
ok
{
}
else
if
s
,
ok
:=
v
.
([]
*
big
.
Int
);
ok
{
v
:=
make
([]
interface
{},
len
(
s
))
v
:=
make
([]
interface
{},
len
(
s
))
for
i
,
b
:=
range
s
{
for
i
,
b
:=
range
s
{
v
[
i
]
=
b
v
[
i
]
=
b
}
}
return
ethutil
.
BigD
(
eth
crypto
.
Sha3
(
ethutil
.
Encode
(
v
)))
return
ethutil
.
BigD
(
crypto
.
Sha3
(
ethutil
.
Encode
(
v
)))
}
}
return
nil
return
nil
...
...
state/state_test.go
View file @
c8438979
...
@@ -4,8 +4,8 @@ import (
...
@@ -4,8 +4,8 @@ import (
"testing"
"testing"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethtrie"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/trie"
)
)
var
ZeroHash256
=
make
([]
byte
,
32
)
var
ZeroHash256
=
make
([]
byte
,
32
)
...
@@ -15,7 +15,7 @@ func TestSnapshot(t *testing.T) {
...
@@ -15,7 +15,7 @@ func TestSnapshot(t *testing.T) {
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
Config
.
Db
=
db
ethutil
.
Config
.
Db
=
db
state
:=
New
(
eth
trie
.
New
(
db
,
""
))
state
:=
New
(
trie
.
New
(
db
,
""
))
stateObject
:=
state
.
GetOrNewStateObject
([]
byte
(
"aa"
))
stateObject
:=
state
.
GetOrNewStateObject
([]
byte
(
"aa"
))
...
...
tests/ethtest/main.go
View file @
c8438979
...
@@ -8,8 +8,8 @@ import (
...
@@ -8,8 +8,8 @@ import (
"os"
"os"
"strings"
"strings"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
"github.com/ethereum/go-ethereum/tests/helper"
)
)
...
@@ -20,8 +20,8 @@ type Account struct {
...
@@ -20,8 +20,8 @@ type Account struct {
Storage
map
[
string
]
string
Storage
map
[
string
]
string
}
}
func
StateObjectFromAccount
(
addr
string
,
account
Account
)
*
eth
state
.
StateObject
{
func
StateObjectFromAccount
(
addr
string
,
account
Account
)
*
state
.
StateObject
{
obj
:=
eth
state
.
NewStateObject
(
ethutil
.
Hex2Bytes
(
addr
))
obj
:=
state
.
NewStateObject
(
ethutil
.
Hex2Bytes
(
addr
))
obj
.
SetBalance
(
ethutil
.
Big
(
account
.
Balance
))
obj
.
SetBalance
(
ethutil
.
Big
(
account
.
Balance
))
if
ethutil
.
IsHex
(
account
.
Code
)
{
if
ethutil
.
IsHex
(
account
.
Code
)
{
...
@@ -53,7 +53,7 @@ func RunVmTest(js string) (failed int) {
...
@@ -53,7 +53,7 @@ func RunVmTest(js string) (failed int) {
}
}
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
state
:=
eth
state
.
New
(
helper
.
NewTrie
())
state
:=
state
.
New
(
helper
.
NewTrie
())
for
addr
,
account
:=
range
test
.
Pre
{
for
addr
,
account
:=
range
test
.
Pre
{
obj
:=
StateObjectFromAccount
(
addr
,
account
)
obj
:=
StateObjectFromAccount
(
addr
,
account
)
state
.
SetStateObject
(
obj
)
state
.
SetStateObject
(
obj
)
...
...
tests/helper/init.go
View file @
c8438979
...
@@ -4,16 +4,16 @@ import (
...
@@ -4,16 +4,16 @@ import (
"log"
"log"
"os"
"os"
"github.com/ethereum/go-ethereum/ethlog"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
logpkg
"github.com/ethereum/go-ethereum/logger"
)
)
var
Logger
ethlo
g
.
LogSystem
var
Logger
logpk
g
.
LogSystem
var
Log
=
ethlo
g
.
NewLogger
(
"TEST"
)
var
Log
=
logpk
g
.
NewLogger
(
"TEST"
)
func
init
()
{
func
init
()
{
Logger
=
ethlog
.
NewStdLogSystem
(
os
.
Stdout
,
log
.
LstdFlags
,
ethlo
g
.
InfoLevel
)
Logger
=
logpkg
.
NewStdLogSystem
(
os
.
Stdout
,
log
.
LstdFlags
,
logpk
g
.
InfoLevel
)
ethlo
g
.
AddLogSystem
(
Logger
)
logpk
g
.
AddLogSystem
(
Logger
)
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
}
}
tests/helper/trie.go
View file @
c8438979
package
helper
package
helper
import
"github.com/ethereum/go-ethereum/
eth
trie"
import
"github.com/ethereum/go-ethereum/trie"
type
MemDatabase
struct
{
type
MemDatabase
struct
{
db
map
[
string
][]
byte
db
map
[
string
][]
byte
...
@@ -24,8 +24,8 @@ func (db *MemDatabase) Print() {}
...
@@ -24,8 +24,8 @@ func (db *MemDatabase) Print() {}
func
(
db
*
MemDatabase
)
Close
()
{}
func
(
db
*
MemDatabase
)
Close
()
{}
func
(
db
*
MemDatabase
)
LastKnownTD
()
[]
byte
{
return
nil
}
func
(
db
*
MemDatabase
)
LastKnownTD
()
[]
byte
{
return
nil
}
func
NewTrie
()
*
eth
trie
.
Trie
{
func
NewTrie
()
*
trie
.
Trie
{
db
,
_
:=
NewMemDatabase
()
db
,
_
:=
NewMemDatabase
()
return
eth
trie
.
New
(
db
,
""
)
return
trie
.
New
(
db
,
""
)
}
}
tests/helper/vm.go
View file @
c8438979
...
@@ -3,13 +3,13 @@ package helper
...
@@ -3,13 +3,13 @@ package helper
import
(
import
(
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
"github.com/ethereum/go-ethereum/vm"
)
)
type
Env
struct
{
type
Env
struct
{
state
*
eth
state
.
State
state
*
state
.
State
origin
[]
byte
origin
[]
byte
parent
[]
byte
parent
[]
byte
...
@@ -21,13 +21,13 @@ type Env struct {
...
@@ -21,13 +21,13 @@ type Env struct {
gasLimit
*
big
.
Int
gasLimit
*
big
.
Int
}
}
func
NewEnv
(
state
*
eth
state
.
State
)
*
Env
{
func
NewEnv
(
state
*
state
.
State
)
*
Env
{
return
&
Env
{
return
&
Env
{
state
:
state
,
state
:
state
,
}
}
}
}
func
NewEnvFromMap
(
state
*
eth
state
.
State
,
envValues
map
[
string
]
string
,
exeValues
map
[
string
]
string
)
*
Env
{
func
NewEnvFromMap
(
state
*
state
.
State
,
envValues
map
[
string
]
string
,
exeValues
map
[
string
]
string
)
*
Env
{
env
:=
NewEnv
(
state
)
env
:=
NewEnv
(
state
)
env
.
origin
=
ethutil
.
Hex2Bytes
(
exeValues
[
"caller"
])
env
.
origin
=
ethutil
.
Hex2Bytes
(
exeValues
[
"caller"
])
...
@@ -41,21 +41,21 @@ func NewEnvFromMap(state *ethstate.State, envValues map[string]string, exeValues
...
@@ -41,21 +41,21 @@ func NewEnvFromMap(state *ethstate.State, envValues map[string]string, exeValues
return
env
return
env
}
}
func
(
self
*
Env
)
Origin
()
[]
byte
{
return
self
.
origin
}
func
(
self
*
Env
)
Origin
()
[]
byte
{
return
self
.
origin
}
func
(
self
*
Env
)
BlockNumber
()
*
big
.
Int
{
return
self
.
number
}
func
(
self
*
Env
)
BlockNumber
()
*
big
.
Int
{
return
self
.
number
}
func
(
self
*
Env
)
PrevHash
()
[]
byte
{
return
self
.
parent
}
func
(
self
*
Env
)
PrevHash
()
[]
byte
{
return
self
.
parent
}
func
(
self
*
Env
)
Coinbase
()
[]
byte
{
return
self
.
coinbase
}
func
(
self
*
Env
)
Coinbase
()
[]
byte
{
return
self
.
coinbase
}
func
(
self
*
Env
)
Time
()
int64
{
return
self
.
time
}
func
(
self
*
Env
)
Time
()
int64
{
return
self
.
time
}
func
(
self
*
Env
)
Difficulty
()
*
big
.
Int
{
return
self
.
difficulty
}
func
(
self
*
Env
)
Difficulty
()
*
big
.
Int
{
return
self
.
difficulty
}
func
(
self
*
Env
)
BlockHash
()
[]
byte
{
return
nil
}
func
(
self
*
Env
)
BlockHash
()
[]
byte
{
return
nil
}
func
(
self
*
Env
)
State
()
*
ethstate
.
State
{
return
self
.
state
}
func
(
self
*
Env
)
State
()
*
state
.
State
{
return
self
.
state
}
func
(
self
*
Env
)
GasLimit
()
*
big
.
Int
{
return
self
.
gasLimit
}
func
(
self
*
Env
)
GasLimit
()
*
big
.
Int
{
return
self
.
gasLimit
}
func
(
self
*
Env
)
AddLog
(
vm
.
Log
)
{}
func
(
self
*
Env
)
AddLog
(
state
.
Log
)
{}
func
(
self
*
Env
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
func
(
self
*
Env
)
Transfer
(
from
,
to
vm
.
Account
,
amount
*
big
.
Int
)
error
{
return
vm
.
Transfer
(
from
,
to
,
amount
)
return
vm
.
Transfer
(
from
,
to
,
amount
)
}
}
func
RunVm
(
state
*
eth
state
.
State
,
env
,
exec
map
[
string
]
string
)
([]
byte
,
*
big
.
Int
,
error
)
{
func
RunVm
(
state
*
state
.
State
,
env
,
exec
map
[
string
]
string
)
([]
byte
,
*
big
.
Int
,
error
)
{
address
:=
FromHex
(
exec
[
"address"
])
address
:=
FromHex
(
exec
[
"address"
])
caller
:=
state
.
GetOrNewStateObject
(
FromHex
(
exec
[
"caller"
]))
caller
:=
state
.
GetOrNewStateObject
(
FromHex
(
exec
[
"caller"
]))
...
...
tests/vm/gh_test.go
View file @
c8438979
...
@@ -4,8 +4,8 @@ import (
...
@@ -4,8 +4,8 @@ import (
"bytes"
"bytes"
"testing"
"testing"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
"github.com/ethereum/go-ethereum/tests/helper"
)
)
...
@@ -16,8 +16,8 @@ type Account struct {
...
@@ -16,8 +16,8 @@ type Account struct {
Storage
map
[
string
]
string
Storage
map
[
string
]
string
}
}
func
StateObjectFromAccount
(
addr
string
,
account
Account
)
*
eth
state
.
StateObject
{
func
StateObjectFromAccount
(
addr
string
,
account
Account
)
*
state
.
StateObject
{
obj
:=
eth
state
.
NewStateObject
(
ethutil
.
Hex2Bytes
(
addr
))
obj
:=
state
.
NewStateObject
(
ethutil
.
Hex2Bytes
(
addr
))
obj
.
SetBalance
(
ethutil
.
Big
(
account
.
Balance
))
obj
.
SetBalance
(
ethutil
.
Big
(
account
.
Balance
))
if
ethutil
.
IsHex
(
account
.
Code
)
{
if
ethutil
.
IsHex
(
account
.
Code
)
{
...
@@ -44,7 +44,7 @@ func RunVmTest(p string, t *testing.T) {
...
@@ -44,7 +44,7 @@ func RunVmTest(p string, t *testing.T) {
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
helper
.
CreateFileTests
(
t
,
p
,
&
tests
)
for
name
,
test
:=
range
tests
{
for
name
,
test
:=
range
tests
{
state
:=
eth
state
.
New
(
helper
.
NewTrie
())
state
:=
state
.
New
(
helper
.
NewTrie
())
for
addr
,
account
:=
range
test
.
Pre
{
for
addr
,
account
:=
range
test
.
Pre
{
obj
:=
StateObjectFromAccount
(
addr
,
account
)
obj
:=
StateObjectFromAccount
(
addr
,
account
)
state
.
SetStateObject
(
obj
)
state
.
SetStateObject
(
obj
)
...
...
vm/vm_test.go
View file @
c8438979
...
@@ -9,11 +9,11 @@ import (
...
@@ -9,11 +9,11 @@ import (
"os"
"os"
"testing"
"testing"
"github.com/ethereum/go-ethereum/ethcrypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethlog"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethtrie"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/trie"
"github.com/obscuren/mutan"
"github.com/obscuren/mutan"
)
)
...
@@ -28,15 +28,15 @@ func (TestEnv) Time() int64 { return 0 }
...
@@ -28,15 +28,15 @@ func (TestEnv) Time() int64 { return 0 }
func
(
TestEnv
)
GasLimit
()
*
big
.
Int
{
return
nil
}
func
(
TestEnv
)
GasLimit
()
*
big
.
Int
{
return
nil
}
func
(
TestEnv
)
Difficulty
()
*
big
.
Int
{
return
nil
}
func
(
TestEnv
)
Difficulty
()
*
big
.
Int
{
return
nil
}
func
(
TestEnv
)
Value
()
*
big
.
Int
{
return
nil
}
func
(
TestEnv
)
Value
()
*
big
.
Int
{
return
nil
}
func
(
TestEnv
)
AddLog
(
Log
)
{}
func
(
TestEnv
)
AddLog
(
state
.
Log
)
{}
func
(
TestEnv
)
Transfer
(
from
,
to
Account
,
amount
*
big
.
Int
)
error
{
func
(
TestEnv
)
Transfer
(
from
,
to
Account
,
amount
*
big
.
Int
)
error
{
return
nil
return
nil
}
}
// This is likely to fail if anything ever gets looked up in the state trie :-)
// This is likely to fail if anything ever gets looked up in the state trie :-)
func
(
TestEnv
)
State
()
*
eth
state
.
State
{
func
(
TestEnv
)
State
()
*
state
.
State
{
return
ethstate
.
New
(
eth
trie
.
New
(
nil
,
""
))
return
state
.
New
(
trie
.
New
(
nil
,
""
))
}
}
const
mutcode
=
`
const
mutcode
=
`
...
@@ -47,18 +47,18 @@ for i := 0; i < 10; i++ {
...
@@ -47,18 +47,18 @@ for i := 0; i < 10; i++ {
return x`
return x`
func
setup
(
level
ethlog
.
LogLevel
,
typ
Type
)
(
*
Closure
,
VirtualMachine
)
{
func
setup
(
level
logger
.
LogLevel
,
typ
Type
)
(
*
Closure
,
VirtualMachine
)
{
code
,
err
:=
ethutil
.
Compile
(
mutcode
,
true
)
code
,
err
:=
ethutil
.
Compile
(
mutcode
,
true
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
// Pipe output to /dev/null
// Pipe output to /dev/null
ethlog
.
AddLogSystem
(
ethlog
.
NewStdLogSystem
(
ioutil
.
Discard
,
log
.
LstdFlags
,
level
))
logger
.
AddLogSystem
(
logger
.
NewStdLogSystem
(
ioutil
.
Discard
,
log
.
LstdFlags
,
level
))
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
stateObject
:=
eth
state
.
NewStateObject
([]
byte
{
'j'
,
'e'
,
'f'
,
'f'
})
stateObject
:=
state
.
NewStateObject
([]
byte
{
'j'
,
'e'
,
'f'
,
'f'
})
callerClosure
:=
NewClosure
(
nil
,
stateObject
,
stateObject
,
code
,
big
.
NewInt
(
1000000
),
big
.
NewInt
(
0
))
callerClosure
:=
NewClosure
(
nil
,
stateObject
,
stateObject
,
code
,
big
.
NewInt
(
1000000
),
big
.
NewInt
(
0
))
return
callerClosure
,
New
(
TestEnv
{},
typ
)
return
callerClosure
,
New
(
TestEnv
{},
typ
)
...
@@ -71,7 +71,7 @@ func TestDebugVm(t *testing.T) {
...
@@ -71,7 +71,7 @@ func TestDebugVm(t *testing.T) {
t
.
Skip
(
"skipping for mutan version"
,
mutan
.
Version
,
" < 0.6"
)
t
.
Skip
(
"skipping for mutan version"
,
mutan
.
Version
,
" < 0.6"
)
}
}
closure
,
vm
:=
setup
(
ethlog
.
DebugLevel
,
DebugVmTy
)
closure
,
vm
:=
setup
(
logger
.
DebugLevel
,
DebugVmTy
)
ret
,
_
,
e
:=
closure
.
Call
(
vm
,
nil
)
ret
,
_
,
e
:=
closure
.
Call
(
vm
,
nil
)
if
e
!=
nil
{
if
e
!=
nil
{
t
.
Fatalf
(
"Call returned error: %v"
,
e
)
t
.
Fatalf
(
"Call returned error: %v"
,
e
)
...
@@ -86,7 +86,7 @@ func TestVm(t *testing.T) {
...
@@ -86,7 +86,7 @@ func TestVm(t *testing.T) {
t
.
Skip
(
"skipping for mutan version"
,
mutan
.
Version
,
" < 0.6"
)
t
.
Skip
(
"skipping for mutan version"
,
mutan
.
Version
,
" < 0.6"
)
}
}
closure
,
vm
:=
setup
(
ethlog
.
DebugLevel
,
StandardVmTy
)
closure
,
vm
:=
setup
(
logger
.
DebugLevel
,
StandardVmTy
)
ret
,
_
,
e
:=
closure
.
Call
(
vm
,
nil
)
ret
,
_
,
e
:=
closure
.
Call
(
vm
,
nil
)
if
e
!=
nil
{
if
e
!=
nil
{
t
.
Fatalf
(
"Call returned error: %v"
,
e
)
t
.
Fatalf
(
"Call returned error: %v"
,
e
)
...
@@ -97,7 +97,7 @@ func TestVm(t *testing.T) {
...
@@ -97,7 +97,7 @@ func TestVm(t *testing.T) {
}
}
func
BenchmarkDebugVm
(
b
*
testing
.
B
)
{
func
BenchmarkDebugVm
(
b
*
testing
.
B
)
{
closure
,
vm
:=
setup
(
ethlog
.
InfoLevel
,
DebugVmTy
)
closure
,
vm
:=
setup
(
logger
.
InfoLevel
,
DebugVmTy
)
b
.
ResetTimer
()
b
.
ResetTimer
()
...
@@ -107,7 +107,7 @@ func BenchmarkDebugVm(b *testing.B) {
...
@@ -107,7 +107,7 @@ func BenchmarkDebugVm(b *testing.B) {
}
}
func
BenchmarkVm
(
b
*
testing
.
B
)
{
func
BenchmarkVm
(
b
*
testing
.
B
)
{
closure
,
vm
:=
setup
(
ethlog
.
InfoLevel
,
StandardVmTy
)
closure
,
vm
:=
setup
(
logger
.
InfoLevel
,
StandardVmTy
)
b
.
ResetTimer
()
b
.
ResetTimer
()
...
@@ -122,11 +122,11 @@ func RunCode(mutCode string, typ Type) []byte {
...
@@ -122,11 +122,11 @@ func RunCode(mutCode string, typ Type) []byte {
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
ethlog
.
AddLogSystem
(
ethlog
.
NewStdLogSystem
(
os
.
Stdout
,
log
.
LstdFlags
,
ethlog
.
InfoLevel
))
logger
.
AddLogSystem
(
logger
.
NewStdLogSystem
(
os
.
Stdout
,
log
.
LstdFlags
,
logger
.
InfoLevel
))
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
ethutil
.
ReadConfig
(
".ethtest"
,
"/tmp/ethtest"
,
""
)
stateObject
:=
eth
state
.
NewStateObject
([]
byte
{
'j'
,
'e'
,
'f'
,
'f'
})
stateObject
:=
state
.
NewStateObject
([]
byte
{
'j'
,
'e'
,
'f'
,
'f'
})
closure
:=
NewClosure
(
nil
,
stateObject
,
stateObject
,
code
,
big
.
NewInt
(
1000000
),
big
.
NewInt
(
0
))
closure
:=
NewClosure
(
nil
,
stateObject
,
stateObject
,
code
,
big
.
NewInt
(
1000000
),
big
.
NewInt
(
0
))
vm
:=
New
(
TestEnv
{},
typ
)
vm
:=
New
(
TestEnv
{},
typ
)
...
@@ -148,7 +148,7 @@ func TestBuildInSha256(t *testing.T) {
...
@@ -148,7 +148,7 @@ func TestBuildInSha256(t *testing.T) {
return out
return out
`
,
DebugVmTy
)
`
,
DebugVmTy
)
exp
:=
eth
crypto
.
Sha256
(
ethutil
.
LeftPadBytes
([]
byte
{
42
},
32
))
exp
:=
crypto
.
Sha256
(
ethutil
.
LeftPadBytes
([]
byte
{
42
},
32
))
if
bytes
.
Compare
(
ret
,
exp
)
!=
0
{
if
bytes
.
Compare
(
ret
,
exp
)
!=
0
{
t
.
Errorf
(
"Expected %x, got %x"
,
exp
,
ret
)
t
.
Errorf
(
"Expected %x, got %x"
,
exp
,
ret
)
}
}
...
@@ -164,7 +164,7 @@ func TestBuildInRipemd(t *testing.T) {
...
@@ -164,7 +164,7 @@ func TestBuildInRipemd(t *testing.T) {
return out
return out
`
,
DebugVmTy
)
`
,
DebugVmTy
)
exp
:=
ethutil
.
RightPadBytes
(
eth
crypto
.
Ripemd160
(
ethutil
.
LeftPadBytes
([]
byte
{
42
},
32
)),
32
)
exp
:=
ethutil
.
RightPadBytes
(
crypto
.
Ripemd160
(
ethutil
.
LeftPadBytes
([]
byte
{
42
},
32
)),
32
)
if
bytes
.
Compare
(
ret
,
exp
)
!=
0
{
if
bytes
.
Compare
(
ret
,
exp
)
!=
0
{
t
.
Errorf
(
"Expected %x, got %x"
,
exp
,
ret
)
t
.
Errorf
(
"Expected %x, got %x"
,
exp
,
ret
)
}
}
...
...
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