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
d7ab716e
Commit
d7ab716e
authored
Mar 19, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed mkdnode & added some tests
parent
e67d32b4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
55 additions
and
16 deletions
+55
-16
main.go
cmd/ethtest/main.go
+12
-7
dump.go
state/dump.go
+1
-0
state_object.go
state/state_object.go
+1
-1
state_test.go
state/state_test.go
+19
-1
statedb.go
state/statedb.go
+4
-0
trie.go
trie/trie.go
+7
-5
trie_test.go
trie/trie_test.go
+10
-1
vm.go
vm/vm.go
+1
-1
No files found.
cmd/ethtest/main.go
View file @
d7ab716e
...
...
@@ -24,7 +24,6 @@ package main
import
(
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
...
...
@@ -33,8 +32,8 @@ import (
"strconv"
"strings"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/tests/helper"
...
...
@@ -136,7 +135,7 @@ func RunVmTest(r io.Reader) (failed int) {
rexp
:=
helper
.
FromHex
(
test
.
Out
)
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
fmt
.
Print
f
(
"FAIL: %s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
helper
.
Log
.
Info
f
(
"FAIL: %s's return failed. Expected %x, got %x
\n
"
,
name
,
rexp
,
ret
)
failed
=
1
}
...
...
@@ -148,7 +147,13 @@ func RunVmTest(r io.Reader) (failed int) {
if
len
(
test
.
Exec
)
==
0
{
if
obj
.
Balance
()
.
Cmp
(
common
.
Big
(
account
.
Balance
))
!=
0
{
fmt
.
Printf
(
"FAIL: %s's : (%x) balance failed. Expected %v, got %v => %v
\n
"
,
name
,
obj
.
Address
()[
:
4
],
account
.
Balance
,
obj
.
Balance
(),
new
(
big
.
Int
)
.
Sub
(
common
.
Big
(
account
.
Balance
),
obj
.
Balance
()))
helper
.
Log
.
Infof
(
"FAIL: %s's : (%x) balance failed. Expected %v, got %v => %v
\n
"
,
name
,
obj
.
Address
()[
:
4
],
account
.
Balance
,
obj
.
Balance
(),
new
(
big
.
Int
)
.
Sub
(
common
.
Big
(
account
.
Balance
),
obj
.
Balance
()),
)
failed
=
1
}
}
...
...
@@ -158,20 +163,20 @@ func RunVmTest(r io.Reader) (failed int) {
vexp
:=
helper
.
FromHex
(
value
)
if
bytes
.
Compare
(
v
,
vexp
)
!=
0
{
fmt
.
Print
f
(
"FAIL: %s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)
\n
"
,
name
,
obj
.
Address
()[
0
:
4
],
addr
,
vexp
,
v
,
common
.
BigD
(
vexp
),
common
.
BigD
(
v
))
helper
.
Log
.
Info
f
(
"FAIL: %s's : (%x: %s) storage failed. Expected %x, got %x (%v %v)
\n
"
,
name
,
obj
.
Address
()[
0
:
4
],
addr
,
vexp
,
v
,
common
.
BigD
(
vexp
),
common
.
BigD
(
v
))
failed
=
1
}
}
}
if
!
bytes
.
Equal
(
common
.
Hex2Bytes
(
test
.
PostStateRoot
),
statedb
.
Root
())
{
fmt
.
Print
f
(
"FAIL: %s's : Post state root error. Expected %s, got %x
\n
"
,
name
,
test
.
PostStateRoot
,
statedb
.
Root
())
helper
.
Log
.
Info
f
(
"FAIL: %s's : Post state root error. Expected %s, got %x
\n
"
,
name
,
test
.
PostStateRoot
,
statedb
.
Root
())
failed
=
1
}
if
len
(
test
.
Logs
)
>
0
{
if
len
(
test
.
Logs
)
!=
len
(
logs
)
{
fmt
.
Print
f
(
"FAIL: log length mismatch. Expected %d, got %d"
,
len
(
test
.
Logs
),
len
(
logs
))
helper
.
Log
.
Info
f
(
"FAIL: log length mismatch. Expected %d, got %d"
,
len
(
test
.
Logs
),
len
(
logs
))
failed
=
1
}
else
{
/*
...
...
state/dump.go
View file @
d7ab716e
...
...
@@ -35,6 +35,7 @@ func (self *StateDB) RawDump() World {
storageIt
:=
stateObject
.
State
.
trie
.
Iterator
()
for
storageIt
.
Next
()
{
fmt
.
Println
(
"value"
,
storageIt
.
Value
)
account
.
Storage
[
common
.
Bytes2Hex
(
storageIt
.
Key
)]
=
common
.
Bytes2Hex
(
storageIt
.
Value
)
}
world
.
Accounts
[
common
.
Bytes2Hex
(
it
.
Key
)]
=
account
...
...
state/state_object.go
View file @
d7ab716e
...
...
@@ -5,8 +5,8 @@ import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
)
...
...
state/state_test.go
View file @
d7ab716e
package
state
import
(
"fmt"
"math/big"
"testing"
checker
"gopkg.in/check.v1"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
)
type
StateSuite
struct
{
...
...
@@ -61,6 +63,22 @@ func (s *StateSuite) SetUpTest(c *checker.C) {
s
.
state
=
New
(
nil
,
db
)
}
func
TestNull
(
t
*
testing
.
T
)
{
db
,
_
:=
ethdb
.
NewMemDatabase
()
state
:=
New
(
nil
,
db
)
address
:=
common
.
FromHex
(
"0x823140710bf13990e4500136726d8b55"
)
state
.
NewStateObject
(
address
)
//value := common.FromHex("0x823140710bf13990e4500136726d8b55")
value
:=
make
([]
byte
,
16
)
fmt
.
Println
(
"test it here"
,
common
.
NewValue
(
value
))
state
.
SetState
(
address
,
[]
byte
{
0
},
value
)
state
.
Update
(
nil
)
state
.
Sync
()
value
=
state
.
GetState
(
address
,
[]
byte
{
0
})
fmt
.
Printf
(
"res: %x
\n
"
,
value
)
}
func
(
s
*
StateSuite
)
TestSnapshot
(
c
*
checker
.
C
)
{
stateobjaddr
:=
[]
byte
(
"aa"
)
storageaddr
:=
common
.
Big
(
"0"
)
...
...
state/statedb.go
View file @
d7ab716e
...
...
@@ -33,6 +33,10 @@ func New(root []byte, db common.Database) *StateDB {
return
&
StateDB
{
db
:
db
,
trie
:
trie
,
stateObjects
:
make
(
map
[
string
]
*
StateObject
),
refund
:
make
(
map
[
string
]
*
big
.
Int
)}
}
func
(
self
*
StateDB
)
PrintRoot
()
{
self
.
trie
.
Trie
.
PrintRoot
()
}
func
(
self
*
StateDB
)
EmptyLogs
()
{
self
.
logs
=
nil
}
...
...
trie/trie.go
View file @
d7ab716e
...
...
@@ -6,8 +6,8 @@ import (
"fmt"
"sync"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func
ParanoiaCheck
(
t1
*
Trie
,
backend
Backend
)
(
bool
,
*
Trie
)
{
...
...
@@ -305,11 +305,13 @@ func (self *Trie) mknode(value *common.Value) Node {
return
NewShortNode
(
self
,
CompactDecode
(
string
(
value
.
Get
(
0
)
.
Bytes
())),
self
.
mknode
(
value
.
Get
(
1
)))
}
case
17
:
fnode
:=
NewFullNode
(
self
)
for
i
:=
0
;
i
<
l
;
i
++
{
fnode
.
set
(
byte
(
i
),
self
.
mknode
(
value
.
Get
(
i
)))
if
len
(
value
.
Bytes
())
!=
17
{
fnode
:=
NewFullNode
(
self
)
for
i
:=
0
;
i
<
l
;
i
++
{
fnode
.
set
(
byte
(
i
),
self
.
mknode
(
value
.
Get
(
i
)))
}
return
fnode
}
return
fnode
case
32
:
return
&
HashNode
{
value
.
Bytes
(),
self
}
}
...
...
trie/trie_test.go
View file @
d7ab716e
...
...
@@ -5,8 +5,8 @@ import (
"fmt"
"testing"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
type
Db
map
[
string
][]
byte
...
...
@@ -32,6 +32,15 @@ func TestEmptyTrie(t *testing.T) {
}
}
func
TestNull
(
t
*
testing
.
T
)
{
trie
:=
NewEmpty
()
key
:=
make
([]
byte
,
32
)
value
:=
common
.
FromHex
(
"0x823140710bf13990e4500136726d8b55"
)
trie
.
Update
(
key
,
value
)
value
=
trie
.
Get
(
key
)
}
func
TestInsert
(
t
*
testing
.
T
)
{
trie
:=
NewEmpty
()
...
...
vm/vm.go
View file @
d7ab716e
...
...
@@ -4,8 +4,8 @@ import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/state"
)
...
...
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