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
f2da6581
Commit
f2da6581
authored
Jan 06, 2017
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: fix issues reported by honnef.co/go/simple/cmd/gosimple
parent
35a7dcb1
Changes
46
Hide whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
99 additions
and
194 deletions
+99
-194
bind.go
accounts/abi/bind/bind.go
+10
-10
type.go
accounts/abi/type.go
+1
-1
main.go
cmd/ethtest/main.go
+1
-6
accountcmd_test.go
cmd/geth/accountcmd_test.go
+4
-4
cmd.go
cmd/utils/cmd.go
+1
-1
big_test.go
common/big_test.go
+3
-3
bytes_test.go
common/bytes_test.go
+2
-2
solidity.go
common/compiler/solidity.go
+1
-1
format.go
common/format.go
+1
-1
read_write.go
compression/rle/read_write.go
+2
-2
console.go
console/console.go
+4
-7
blockchain.go
core/blockchain.go
+1
-4
dao.go
core/dao.go
+2
-2
database_util_test.go
core/database_util_test.go
+2
-2
iterator.go
core/state/iterator.go
+1
-1
sync_test.go
core/state/sync_test.go
+2
-2
bloom9.go
core/types/bloom9.go
+1
-7
crypto_test.go
crypto/crypto_test.go
+1
-1
ecies.go
crypto/ecies/ecies.go
+2
-3
handler.go
eth/handler.go
+4
-26
ethstats.go
ethstats/ethstats.go
+6
-23
worker.go
miner/worker.go
+1
-1
bind.go
mobile/bind.go
+5
-24
config_test.go
node/config_test.go
+1
-1
node_test.go
node/node_test.go
+2
-2
database.go
p2p/discover/database.go
+1
-1
node.go
p2p/discover/node.go
+1
-4
database.go
p2p/discv5/database.go
+1
-1
node.go
p2p/discv5/node.go
+1
-4
dbstore.go
swarm/storage/dbstore.go
+1
-1
types.go
swarm/storage/types.go
+1
-1
block_test_util.go
tests/block_test_util.go
+1
-3
init.go
tests/init.go
+1
-5
state_test_util.go
tests/state_test_util.go
+1
-1
vm_test_util.go
tests/vm_test_util.go
+1
-1
sync_test.go
trie/sync_test.go
+1
-1
api.go
whisper/shhapi/api.go
+1
-5
api_test.go
whisper/shhapi/api_test.go
+1
-1
envelope_test.go
whisper/whisperv2/envelope_test.go
+6
-6
filter.go
whisper/whisperv2/filter.go
+1
-4
filter_test.go
whisper/whisperv2/filter_test.go
+4
-4
message_test.go
whisper/whisperv2/message_test.go
+2
-2
topic_test.go
whisper/whisperv2/topic_test.go
+4
-4
message_test.go
whisper/whisperv5/message_test.go
+4
-4
peer_test.go
whisper/whisperv5/peer_test.go
+1
-1
whisper_test.go
whisper/whisperv5/whisper_test.go
+3
-3
No files found.
accounts/abi/bind/bind.go
View file @
f2da6581
...
...
@@ -147,21 +147,21 @@ func bindTypeGo(kind abi.Type) string {
switch
{
case
strings
.
HasPrefix
(
stringKind
,
"address"
)
:
parts
:=
regexp
.
MustCompile
(
"address(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`address(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
2
{
return
stringKind
}
return
fmt
.
Sprintf
(
"%scommon.Address"
,
parts
[
1
])
case
strings
.
HasPrefix
(
stringKind
,
"bytes"
)
:
parts
:=
regexp
.
MustCompile
(
"bytes([0-9]*)(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`bytes([0-9]*)(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
3
{
return
stringKind
}
return
fmt
.
Sprintf
(
"%s[%s]byte"
,
parts
[
2
],
parts
[
1
])
case
strings
.
HasPrefix
(
stringKind
,
"int"
)
||
strings
.
HasPrefix
(
stringKind
,
"uint"
)
:
parts
:=
regexp
.
MustCompile
(
"(u)?int([0-9]*)(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`(u)?int([0-9]*)(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
4
{
return
stringKind
}
...
...
@@ -172,7 +172,7 @@ func bindTypeGo(kind abi.Type) string {
return
fmt
.
Sprintf
(
"%s*big.Int"
,
parts
[
3
])
case
strings
.
HasPrefix
(
stringKind
,
"bool"
)
||
strings
.
HasPrefix
(
stringKind
,
"string"
)
:
parts
:=
regexp
.
MustCompile
(
"([a-z]+)(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`([a-z]+)(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
3
{
return
stringKind
}
...
...
@@ -191,7 +191,7 @@ func bindTypeJava(kind abi.Type) string {
switch
{
case
strings
.
HasPrefix
(
stringKind
,
"address"
)
:
parts
:=
regexp
.
MustCompile
(
"address(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`address(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
2
{
return
stringKind
}
...
...
@@ -201,7 +201,7 @@ func bindTypeJava(kind abi.Type) string {
return
fmt
.
Sprintf
(
"Addresses"
)
case
strings
.
HasPrefix
(
stringKind
,
"bytes"
)
:
parts
:=
regexp
.
MustCompile
(
"bytes([0-9]*)(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`bytes([0-9]*)(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
3
{
return
stringKind
}
...
...
@@ -211,7 +211,7 @@ func bindTypeJava(kind abi.Type) string {
return
"byte[]"
case
strings
.
HasPrefix
(
stringKind
,
"int"
)
||
strings
.
HasPrefix
(
stringKind
,
"uint"
)
:
parts
:=
regexp
.
MustCompile
(
"(u)?int([0-9]*)(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`(u)?int([0-9]*)(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
4
{
return
stringKind
}
...
...
@@ -230,7 +230,7 @@ func bindTypeJava(kind abi.Type) string {
return
fmt
.
Sprintf
(
"BigInts"
)
case
strings
.
HasPrefix
(
stringKind
,
"bool"
)
:
parts
:=
regexp
.
MustCompile
(
"bool(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`bool(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
2
{
return
stringKind
}
...
...
@@ -240,7 +240,7 @@ func bindTypeJava(kind abi.Type) string {
return
fmt
.
Sprintf
(
"bool[]"
)
case
strings
.
HasPrefix
(
stringKind
,
"string"
)
:
parts
:=
regexp
.
MustCompile
(
"string(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
stringKind
)
parts
:=
regexp
.
MustCompile
(
`string(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
stringKind
)
if
len
(
parts
)
!=
2
{
return
stringKind
}
...
...
@@ -278,7 +278,7 @@ func namedTypeJava(javaKind string, solKind abi.Type) string {
case
"bool[]"
:
return
"Bools"
case
"BigInt"
:
parts
:=
regexp
.
MustCompile
(
"(u)?int([0-9]*)(
\\
[[0-9]*
\\
])?"
)
.
FindStringSubmatch
(
solKind
.
String
())
parts
:=
regexp
.
MustCompile
(
`(u)?int([0-9]*)(\[[0-9]*\])?`
)
.
FindStringSubmatch
(
solKind
.
String
())
if
len
(
parts
)
!=
4
{
return
javaKind
}
...
...
accounts/abi/type.go
View file @
f2da6581
...
...
@@ -65,7 +65,7 @@ var (
// string int uint fixed
// string32 int8 uint8 uint[]
// address int256 uint256 fixed128x128[2]
fullTypeRegex
=
regexp
.
MustCompile
(
"([a-zA-Z0-9]+)(
\\
[([0-9]*)
\\
])?"
)
fullTypeRegex
=
regexp
.
MustCompile
(
`([a-zA-Z0-9]+)(\[([0-9]*)\])?`
)
// typeRegex parses the abi sub types
typeRegex
=
regexp
.
MustCompile
(
"([a-zA-Z]+)(([0-9]+)(x([0-9]+))?)?"
)
)
...
...
cmd/ethtest/main.go
View file @
f2da6581
...
...
@@ -88,12 +88,7 @@ func runTestWithReader(test string, r io.Reader) error {
default
:
err
=
fmt
.
Errorf
(
"Invalid test type specified: %v"
,
test
)
}
if
err
!=
nil
{
return
err
}
return
nil
return
err
}
func
getFiles
(
path
string
)
([]
string
,
error
)
{
...
...
cmd/geth/accountcmd_test.go
View file @
f2da6581
...
...
@@ -148,7 +148,7 @@ Passphrase: {{.InputLine "foobar"}}
"Unlocked account f466859ead1932d743d622cb74fc058882e8648a"
,
}
for
_
,
m
:=
range
wantMessages
{
if
strings
.
Index
(
geth
.
stderrText
(),
m
)
==
-
1
{
if
!
strings
.
Contains
(
geth
.
stderrText
(),
m
)
{
t
.
Errorf
(
"stderr text does not contain %q"
,
m
)
}
}
...
...
@@ -193,7 +193,7 @@ Passphrase: {{.InputLine "foobar"}}
"Unlocked account 289d485d9771714cce91d3393d764e1311907acc"
,
}
for
_
,
m
:=
range
wantMessages
{
if
strings
.
Index
(
geth
.
stderrText
(),
m
)
==
-
1
{
if
!
strings
.
Contains
(
geth
.
stderrText
(),
m
)
{
t
.
Errorf
(
"stderr text does not contain %q"
,
m
)
}
}
...
...
@@ -212,7 +212,7 @@ func TestUnlockFlagPasswordFile(t *testing.T) {
"Unlocked account 289d485d9771714cce91d3393d764e1311907acc"
,
}
for
_
,
m
:=
range
wantMessages
{
if
strings
.
Index
(
geth
.
stderrText
(),
m
)
==
-
1
{
if
!
strings
.
Contains
(
geth
.
stderrText
(),
m
)
{
t
.
Errorf
(
"stderr text does not contain %q"
,
m
)
}
}
...
...
@@ -260,7 +260,7 @@ In order to avoid this warning, you need to remove the following duplicate key f
"Unlocked account f466859ead1932d743d622cb74fc058882e8648a"
,
}
for
_
,
m
:=
range
wantMessages
{
if
strings
.
Index
(
geth
.
stderrText
(),
m
)
==
-
1
{
if
!
strings
.
Contains
(
geth
.
stderrText
(),
m
)
{
t
.
Errorf
(
"stderr text does not contain %q"
,
m
)
}
}
...
...
cmd/utils/cmd.go
View file @
f2da6581
...
...
@@ -95,7 +95,7 @@ func StartNode(stack *node.Node) {
func
FormatTransactionData
(
data
string
)
[]
byte
{
d
:=
common
.
StringToByteFunc
(
data
,
func
(
s
string
)
(
ret
[]
byte
)
{
slice
:=
regexp
.
MustCompile
(
"
\\
n|
\\
s"
)
.
Split
(
s
,
1000000000
)
slice
:=
regexp
.
MustCompile
(
`\n|\s`
)
.
Split
(
s
,
1000000000
)
for
_
,
dataItem
:=
range
slice
{
d
:=
common
.
FormatData
(
dataItem
)
ret
=
append
(
ret
,
d
...
)
...
...
common/big_test.go
View file @
f2da6581
...
...
@@ -27,7 +27,7 @@ func TestMisc(t *testing.T) {
c
:=
[]
byte
{
1
,
2
,
3
,
4
}
z
:=
BitTest
(
a
,
1
)
if
z
!=
true
{
if
!
z
{
t
.
Error
(
"Expected true got"
,
z
)
}
...
...
@@ -79,11 +79,11 @@ func TestBigCopy(t *testing.T) {
z
:=
BigToBytes
(
c
,
16
)
zbytes
:=
[]
byte
{
232
,
212
,
165
,
16
,
0
}
if
bytes
.
Compare
(
y
,
ybytes
)
!=
0
{
if
!
bytes
.
Equal
(
y
,
ybytes
)
{
t
.
Error
(
"Got"
,
ybytes
)
}
if
bytes
.
Compare
(
z
,
zbytes
)
!=
0
{
if
!
bytes
.
Equal
(
z
,
zbytes
)
{
t
.
Error
(
"Got"
,
zbytes
)
}
}
common/bytes_test.go
View file @
f2da6581
...
...
@@ -181,7 +181,7 @@ func TestFromHex(t *testing.T) {
input
:=
"0x01"
expected
:=
[]
byte
{
1
}
result
:=
FromHex
(
input
)
if
bytes
.
Compare
(
expected
,
result
)
!=
0
{
if
!
bytes
.
Equal
(
expected
,
result
)
{
t
.
Errorf
(
"Expected % x got % x"
,
expected
,
result
)
}
}
...
...
@@ -190,7 +190,7 @@ func TestFromHexOddLength(t *testing.T) {
input
:=
"0x1"
expected
:=
[]
byte
{
1
}
result
:=
FromHex
(
input
)
if
bytes
.
Compare
(
expected
,
result
)
!=
0
{
if
!
bytes
.
Equal
(
expected
,
result
)
{
t
.
Errorf
(
"Expected % x got % x"
,
expected
,
result
)
}
}
common/compiler/solidity.go
View file @
f2da6581
...
...
@@ -32,7 +32,7 @@ import (
)
var
(
versionRegexp
=
regexp
.
MustCompile
(
"[0-9]+
\\
.[0-9]+
\\
.[0-9]+"
)
versionRegexp
=
regexp
.
MustCompile
(
`[0-9]+\.[0-9]+\.[0-9]+`
)
solcParams
=
[]
string
{
"--combined-json"
,
"bin,abi,userdoc,devdoc"
,
"--add-std"
,
// include standard lib contracts
...
...
common/format.go
View file @
f2da6581
...
...
@@ -27,7 +27,7 @@ import (
// the unnecessary precision off from the formatted textual representation.
type
PrettyDuration
time
.
Duration
var
prettyDurationRe
=
regexp
.
MustCompile
(
"
\\
.[0-9]+"
)
var
prettyDurationRe
=
regexp
.
MustCompile
(
`\.[0-9]+`
)
// String implements the Stringer interface, allowing pretty printing of duration
// values rounded to three decimals.
...
...
compression/rle/read_write.go
View file @
f2da6581
...
...
@@ -76,9 +76,9 @@ func compressChunk(dat []byte) (ret []byte, n int) {
}
return
[]
byte
{
token
,
byte
(
j
+
2
)},
j
case
len
(
dat
)
>=
32
:
if
dat
[
0
]
==
empty
[
0
]
&&
bytes
.
Compare
(
dat
[
:
32
],
empty
)
==
0
{
if
dat
[
0
]
==
empty
[
0
]
&&
bytes
.
Equal
(
dat
[
:
32
],
empty
)
{
return
[]
byte
{
token
,
emptyShaToken
},
32
}
else
if
dat
[
0
]
==
emptyList
[
0
]
&&
bytes
.
Compare
(
dat
[
:
32
],
emptyList
)
==
0
{
}
else
if
dat
[
0
]
==
emptyList
[
0
]
&&
bytes
.
Equal
(
dat
[
:
32
],
emptyList
)
{
return
[]
byte
{
token
,
emptyListShaToken
},
32
}
fallthrough
...
...
console/console.go
View file @
f2da6581
...
...
@@ -36,9 +36,9 @@ import (
)
var
(
passwordRegexp
=
regexp
.
MustCompile
(
"personal.[nus]"
)
onlyWhitespace
=
regexp
.
MustCompile
(
"^
\\
s*$"
)
exit
=
regexp
.
MustCompile
(
"^
\\
s*exit
\\
s*;*
\\
s*$"
)
passwordRegexp
=
regexp
.
MustCompile
(
`personal.[nus]`
)
onlyWhitespace
=
regexp
.
MustCompile
(
`^\s*$`
)
exit
=
regexp
.
MustCompile
(
`^\s*exit\s*;*\s*$`
)
)
// HistoryFile is the file within the data directory to store input scrollback.
...
...
@@ -275,10 +275,7 @@ func (c *Console) Evaluate(statement string) error {
fmt
.
Fprintf
(
c
.
printer
,
"[native] error: %v
\n
"
,
r
)
}
}()
if
err
:=
c
.
jsre
.
Evaluate
(
statement
,
c
.
printer
);
err
!=
nil
{
return
err
}
return
nil
return
c
.
jsre
.
Evaluate
(
statement
,
c
.
printer
)
}
// Interactive starts an interactive user session, where input is propted from
...
...
core/blockchain.go
View file @
f2da6581
...
...
@@ -402,10 +402,7 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) {
// Export writes the active chain to the given writer.
func
(
self
*
BlockChain
)
Export
(
w
io
.
Writer
)
error
{
if
err
:=
self
.
ExportN
(
w
,
uint64
(
0
),
self
.
currentBlock
.
NumberU64
());
err
!=
nil
{
return
err
}
return
nil
return
self
.
ExportN
(
w
,
uint64
(
0
),
self
.
currentBlock
.
NumberU64
())
}
// ExportN writes a subset of the active chain to the given writer.
...
...
core/dao.go
View file @
f2da6581
...
...
@@ -45,11 +45,11 @@ func ValidateDAOHeaderExtraData(config *params.ChainConfig, header *types.Header
}
// Depending whether we support or oppose the fork, validate the extra-data contents
if
config
.
DAOForkSupport
{
if
bytes
.
Compare
(
header
.
Extra
,
params
.
DAOForkBlockExtra
)
!=
0
{
if
!
bytes
.
Equal
(
header
.
Extra
,
params
.
DAOForkBlockExtra
)
{
return
ValidationError
(
"DAO pro-fork bad block extra-data: 0x%x"
,
header
.
Extra
)
}
}
else
{
if
bytes
.
Compare
(
header
.
Extra
,
params
.
DAOForkBlockExtra
)
==
0
{
if
bytes
.
Equal
(
header
.
Extra
,
params
.
DAOForkBlockExtra
)
{
return
ValidationError
(
"DAO no-fork bad block extra-data: 0x%x"
,
header
.
Extra
)
}
}
...
...
core/database_util_test.go
View file @
f2da6581
...
...
@@ -430,7 +430,7 @@ func TestReceiptStorage(t *testing.T) {
rlpHave
,
_
:=
rlp
.
EncodeToBytes
(
r
)
rlpWant
,
_
:=
rlp
.
EncodeToBytes
(
receipt
)
if
bytes
.
Compare
(
rlpHave
,
rlpWant
)
!=
0
{
if
!
bytes
.
Equal
(
rlpHave
,
rlpWant
)
{
t
.
Fatalf
(
"receipt #%d [%x]: receipt mismatch: have %v, want %v"
,
i
,
receipt
.
TxHash
,
r
,
receipt
)
}
}
...
...
@@ -488,7 +488,7 @@ func TestBlockReceiptStorage(t *testing.T) {
rlpHave
,
_
:=
rlp
.
EncodeToBytes
(
rs
[
i
])
rlpWant
,
_
:=
rlp
.
EncodeToBytes
(
receipts
[
i
])
if
bytes
.
Compare
(
rlpHave
,
rlpWant
)
!=
0
{
if
!
bytes
.
Equal
(
rlpHave
,
rlpWant
)
{
t
.
Fatalf
(
"receipt #%d: receipt mismatch: have %v, want %v"
,
i
,
rs
[
i
],
receipts
[
i
])
}
}
...
...
core/state/iterator.go
View file @
f2da6581
...
...
@@ -123,7 +123,7 @@ func (it *NodeIterator) step() error {
if
!
it
.
dataIt
.
Next
()
{
it
.
dataIt
=
nil
}
if
bytes
.
Compare
(
account
.
CodeHash
,
emptyCodeHash
)
!=
0
{
if
!
bytes
.
Equal
(
account
.
CodeHash
,
emptyCodeHash
)
{
it
.
codeHash
=
common
.
BytesToHash
(
account
.
CodeHash
)
it
.
code
,
err
=
it
.
state
.
db
.
Get
(
account
.
CodeHash
)
if
err
!=
nil
{
...
...
core/state/sync_test.go
View file @
f2da6581
...
...
@@ -84,7 +84,7 @@ func checkStateAccounts(t *testing.T, db ethdb.Database, root common.Hash, accou
if
nonce
:=
state
.
GetNonce
(
acc
.
address
);
nonce
!=
acc
.
nonce
{
t
.
Errorf
(
"account %d: nonce mismatch: have %v, want %v"
,
i
,
nonce
,
acc
.
nonce
)
}
if
code
:=
state
.
GetCode
(
acc
.
address
);
bytes
.
Compare
(
code
,
acc
.
code
)
!=
0
{
if
code
:=
state
.
GetCode
(
acc
.
address
);
!
bytes
.
Equal
(
code
,
acc
.
code
)
{
t
.
Errorf
(
"account %d: code mismatch: have %x, want %x"
,
i
,
code
,
acc
.
code
)
}
}
...
...
@@ -294,7 +294,7 @@ func TestIncompleteStateSync(t *testing.T) {
// Skim through the accounts and make sure the root hash is not a code node
codeHash
:=
false
for
_
,
acc
:=
range
srcAccounts
{
if
bytes
.
Compare
(
root
.
Bytes
(),
crypto
.
Sha3
(
acc
.
code
))
==
0
{
if
root
==
crypto
.
Keccak256Hash
(
acc
.
code
)
{
codeHash
=
true
break
}
...
...
core/types/bloom9.go
View file @
f2da6581
...
...
@@ -97,14 +97,8 @@ func CreateBloom(receipts Receipts) Bloom {
func
LogsBloom
(
logs
[]
*
Log
)
*
big
.
Int
{
bin
:=
new
(
big
.
Int
)
for
_
,
log
:=
range
logs
{
data
:=
make
([]
common
.
Hash
,
len
(
log
.
Topics
))
bin
.
Or
(
bin
,
bloom9
(
log
.
Address
.
Bytes
()))
for
i
,
topic
:=
range
log
.
Topics
{
data
[
i
]
=
topic
}
for
_
,
b
:=
range
data
{
for
_
,
b
:=
range
log
.
Topics
{
bin
.
Or
(
bin
,
bloom9
(
b
[
:
]))
}
}
...
...
crypto/crypto_test.go
View file @
f2da6581
...
...
@@ -217,7 +217,7 @@ func TestValidateSignatureValues(t *testing.T) {
func
checkhash
(
t
*
testing
.
T
,
name
string
,
f
func
([]
byte
)
[]
byte
,
msg
,
exp
[]
byte
)
{
sum
:=
f
(
msg
)
if
bytes
.
Compare
(
exp
,
sum
)
!=
0
{
if
!
bytes
.
Equal
(
exp
,
sum
)
{
t
.
Fatalf
(
"hash %s mismatch: want: %x have: %x"
,
name
,
exp
,
sum
)
}
}
...
...
crypto/ecies/ecies.go
View file @
f2da6581
...
...
@@ -291,9 +291,8 @@ func Encrypt(rand io.Reader, pub *PublicKey, m, s1, s2 []byte) (ct []byte, err e
// Decrypt decrypts an ECIES ciphertext.
func
(
prv
*
PrivateKey
)
Decrypt
(
rand
io
.
Reader
,
c
,
s1
,
s2
[]
byte
)
(
m
[]
byte
,
err
error
)
{
if
c
==
nil
||
len
(
c
)
==
0
{
err
=
ErrInvalidMessage
return
if
len
(
c
)
==
0
{
return
nil
,
ErrInvalidMessage
}
params
:=
prv
.
PublicKey
.
Params
if
params
==
nil
{
...
...
eth/handler.go
View file @
f2da6581
...
...
@@ -607,38 +607,16 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
}
case
msg
.
Code
==
NewBlockHashesMsg
:
// Retrieve and deserialize the remote new block hashes notification
type
announce
struct
{
Hash
common
.
Hash
Number
uint64
}
var
announces
=
[]
announce
{}
if
p
.
version
<
eth62
{
// We're running the old protocol, make block number unknown (0)
var
hashes
[]
common
.
Hash
if
err
:=
msg
.
Decode
(
&
hashes
);
err
!=
nil
{
return
errResp
(
ErrDecode
,
"%v: %v"
,
msg
,
err
)
}
for
_
,
hash
:=
range
hashes
{
announces
=
append
(
announces
,
announce
{
hash
,
0
})
}
}
else
{
// Otherwise extract both block hash and number
var
request
newBlockHashesData
if
err
:=
msg
.
Decode
(
&
request
);
err
!=
nil
{
return
errResp
(
ErrDecode
,
"%v: %v"
,
msg
,
err
)
}
for
_
,
block
:=
range
request
{
announces
=
append
(
announces
,
announce
{
block
.
Hash
,
block
.
Number
})
}
var
announces
newBlockHashesData
if
err
:=
msg
.
Decode
(
&
announces
);
err
!=
nil
{
return
errResp
(
ErrDecode
,
"%v: %v"
,
msg
,
err
)
}
// Mark the hashes as present at the remote node
for
_
,
block
:=
range
announces
{
p
.
MarkBlock
(
block
.
Hash
)
}
// Schedule all the unknown hashes for retrieval
unknown
:=
make
(
[]
announce
,
0
,
len
(
announces
))
unknown
:=
make
(
newBlockHashesData
,
0
,
len
(
announces
))
for
_
,
block
:=
range
announces
{
if
!
pm
.
blockchain
.
HasBlock
(
block
.
Hash
)
{
unknown
=
append
(
unknown
,
block
)
...
...
ethstats/ethstats.go
View file @
f2da6581
...
...
@@ -388,10 +388,7 @@ func (s *Service) reportLatency(out *json.Encoder) error {
"latency"
:
strconv
.
Itoa
(
int
((
time
.
Since
(
start
)
/
time
.
Duration
(
2
))
.
Nanoseconds
()
/
1000000
)),
}},
}
if
err
:=
out
.
Encode
(
latency
);
err
!=
nil
{
return
err
}
return
nil
return
out
.
Encode
(
latency
)
}
// blockStats is the information to report about individual blocks.
...
...
@@ -440,10 +437,7 @@ func (s *Service) reportBlock(out *json.Encoder, block *types.Block) error {
report
:=
map
[
string
][]
interface
{}{
"emit"
:
{
"block"
,
stats
},
}
if
err
:=
out
.
Encode
(
report
);
err
!=
nil
{
return
err
}
return
nil
return
out
.
Encode
(
report
)
}
// assembleBlockStats retrieves any required metadata to report a single block
...
...
@@ -497,9 +491,7 @@ func (s *Service) reportHistory(out *json.Encoder, list []uint64) error {
indexes
:=
make
([]
uint64
,
0
,
historyUpdateRange
)
if
len
(
list
)
>
0
{
// Specific indexes requested, send them back in particular
for
_
,
idx
:=
range
list
{
indexes
=
append
(
indexes
,
idx
)
}
indexes
=
append
(
indexes
,
list
...
)
}
else
{
// No indexes requested, send back the top ones
var
head
*
types
.
Header
...
...
@@ -533,10 +525,7 @@ func (s *Service) reportHistory(out *json.Encoder, list []uint64) error {
report
:=
map
[
string
][]
interface
{}{
"emit"
:
{
"history"
,
stats
},
}
if
err
:=
out
.
Encode
(
report
);
err
!=
nil
{
return
err
}
return
nil
return
out
.
Encode
(
report
)
}
// pendStats is the information to report about pending transactions.
...
...
@@ -564,10 +553,7 @@ func (s *Service) reportPending(out *json.Encoder) error {
report
:=
map
[
string
][]
interface
{}{
"emit"
:
{
"pending"
,
stats
},
}
if
err
:=
out
.
Encode
(
report
);
err
!=
nil
{
return
err
}
return
nil
return
out
.
Encode
(
report
)
}
// blockStats is the information to report about the local node.
...
...
@@ -618,8 +604,5 @@ func (s *Service) reportStats(out *json.Encoder) error {
report
:=
map
[
string
][]
interface
{}{
"emit"
:
{
"stats"
,
stats
},
}
if
err
:=
out
.
Encode
(
report
);
err
!=
nil
{
return
err
}
return
nil
return
out
.
Encode
(
report
)
}
miner/worker.go
View file @
f2da6581
...
...
@@ -449,7 +449,7 @@ func (self *worker) commitNewWork() {
// Depending whether we support or oppose the fork, override differently
if
self
.
config
.
DAOForkSupport
{
header
.
Extra
=
common
.
CopyBytes
(
params
.
DAOForkBlockExtra
)
}
else
if
bytes
.
Compare
(
header
.
Extra
,
params
.
DAOForkBlockExtra
)
==
0
{
}
else
if
bytes
.
Equal
(
header
.
Extra
,
params
.
DAOForkBlockExtra
)
{
header
.
Extra
=
[]
byte
{}
// If miner opposes, don't let it use the reserved extra-data
}
}
...
...
mobile/bind.go
View file @
f2da6581
...
...
@@ -114,17 +114,12 @@ type BoundContract struct {
// DeployContract deploys a contract onto the Ethereum blockchain and binds the
// deployment address with a wrapper.
func
DeployContract
(
opts
*
TransactOpts
,
abiJSON
string
,
bytecode
[]
byte
,
client
*
EthereumClient
,
args
*
Interfaces
)
(
contract
*
BoundContract
,
_
error
)
{
// Convert all the deployment parameters to Go types
params
:=
make
([]
interface
{},
len
(
args
.
objects
))
for
i
,
obj
:=
range
args
.
objects
{
params
[
i
]
=
obj
}
// Deploy the contract to the network
parsed
,
err
:=
abi
.
JSON
(
strings
.
NewReader
(
abiJSON
))
if
err
!=
nil
{
return
nil
,
err
}
addr
,
tx
,
bound
,
err
:=
bind
.
DeployContract
(
&
opts
.
opts
,
parsed
,
bytecode
,
client
.
client
,
param
s
...
)
addr
,
tx
,
bound
,
err
:=
bind
.
DeployContract
(
&
opts
.
opts
,
parsed
,
bytecode
,
client
.
client
,
args
.
object
s
...
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -159,32 +154,18 @@ func (c *BoundContract) GetDeployer() *Transaction {
// Call invokes the (constant) contract method with params as input values and
// sets the output to result.
func
(
c
*
BoundContract
)
Call
(
opts
*
CallOpts
,
out
*
Interfaces
,
method
string
,
args
*
Interfaces
)
error
{
// Convert all the input and output parameters to Go types
params
:=
make
([]
interface
{},
len
(
args
.
objects
))
for
i
,
obj
:=
range
args
.
objects
{
params
[
i
]
=
obj
}
results
:=
make
([]
interface
{},
len
(
out
.
objects
))
for
i
,
obj
:=
range
out
.
objects
{
results
[
i
]
=
obj
}
// Execute the call to the contract and wrap any results
if
err
:=
c
.
contract
.
Call
(
&
opts
.
opts
,
&
results
,
method
,
params
...
);
err
!=
nil
{
copy
(
results
,
out
.
objects
)
if
err
:=
c
.
contract
.
Call
(
&
opts
.
opts
,
&
results
,
method
,
args
.
objects
...
);
err
!=
nil
{
return
err
}
for
i
,
res
:=
range
results
{
out
.
objects
[
i
]
=
res
}
copy
(
out
.
objects
,
results
)
return
nil
}
// Transact invokes the (paid) contract method with params as input values.
func
(
c
*
BoundContract
)
Transact
(
opts
*
TransactOpts
,
method
string
,
args
*
Interfaces
)
(
tx
*
Transaction
,
_
error
)
{
params
:=
make
([]
interface
{},
len
(
args
.
objects
))
for
i
,
obj
:=
range
args
.
objects
{
params
[
i
]
=
obj
}
rawTx
,
err
:=
c
.
contract
.
Transact
(
&
opts
.
opts
,
method
,
params
)
rawTx
,
err
:=
c
.
contract
.
Transact
(
&
opts
.
opts
,
method
,
args
.
objects
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
node/config_test.go
View file @
f2da6581
...
...
@@ -137,7 +137,7 @@ func TestNodeKeyPersistency(t *testing.T) {
if
err
!=
nil
{
t
.
Fatalf
(
"failed to read previously persisted node key: %v"
,
err
)
}
if
bytes
.
Compare
(
blob1
,
blob2
)
!=
0
{
if
!
bytes
.
Equal
(
blob1
,
blob2
)
{
t
.
Fatalf
(
"persisted node key mismatch: have %x, want %x"
,
blob2
,
blob1
)
}
...
...
node/node_test.go
View file @
f2da6581
...
...
@@ -218,7 +218,7 @@ func TestServiceRestarts(t *testing.T) {
}
defer
stack
.
Stop
()
if
running
!=
true
||
started
!=
1
{
if
running
||
started
!=
1
{
t
.
Fatalf
(
"running/started mismatch: have %v/%d, want true/1"
,
running
,
started
)
}
// Restart the stack a few times and check successful service restarts
...
...
@@ -227,7 +227,7 @@ func TestServiceRestarts(t *testing.T) {
t
.
Fatalf
(
"iter %d: failed to restart stack: %v"
,
i
,
err
)
}
}
if
running
!=
true
||
started
!=
4
{
if
!
running
||
started
!=
4
{
t
.
Fatalf
(
"running/started mismatch: have %v/%d, want true/4"
,
running
,
started
)
}
}
...
...
p2p/discover/database.go
View file @
f2da6581
...
...
@@ -258,7 +258,7 @@ func (db *nodeDB) expireNodes() error {
continue
}
// Skip the node if not expired yet (and not self)
if
bytes
.
Compare
(
id
[
:
],
db
.
self
[
:
])
!=
0
{
if
!
bytes
.
Equal
(
id
[
:
],
db
.
self
[
:
])
{
if
seen
:=
db
.
lastPong
(
id
);
seen
.
After
(
threshold
)
{
continue
}
...
...
p2p/discover/node.go
View file @
f2da6581
...
...
@@ -224,11 +224,8 @@ func (n NodeID) GoString() string {
// HexID converts a hex string to a NodeID.
// The string may be prefixed with 0x.
func
HexID
(
in
string
)
(
NodeID
,
error
)
{
if
strings
.
HasPrefix
(
in
,
"0x"
)
{
in
=
in
[
2
:
]
}
var
id
NodeID
b
,
err
:=
hex
.
DecodeString
(
in
)
b
,
err
:=
hex
.
DecodeString
(
strings
.
TrimPrefix
(
in
,
"0x"
)
)
if
err
!=
nil
{
return
id
,
err
}
else
if
len
(
b
)
!=
len
(
id
)
{
...
...
p2p/discv5/database.go
View file @
f2da6581
...
...
@@ -269,7 +269,7 @@ func (db *nodeDB) expireNodes() error {
continue
}
// Skip the node if not expired yet (and not self)
if
bytes
.
Compare
(
id
[
:
],
db
.
self
[
:
])
!=
0
{
if
!
bytes
.
Equal
(
id
[
:
],
db
.
self
[
:
])
{
if
seen
:=
db
.
lastPong
(
id
);
seen
.
After
(
threshold
)
{
continue
}
...
...
p2p/discv5/node.go
View file @
f2da6581
...
...
@@ -262,11 +262,8 @@ func (n NodeID) GoString() string {
// HexID converts a hex string to a NodeID.
// The string may be prefixed with 0x.
func
HexID
(
in
string
)
(
NodeID
,
error
)
{
if
strings
.
HasPrefix
(
in
,
"0x"
)
{
in
=
in
[
2
:
]
}
var
id
NodeID
b
,
err
:=
hex
.
DecodeString
(
in
)
b
,
err
:=
hex
.
DecodeString
(
strings
.
TrimPrefix
(
in
,
"0x"
)
)
if
err
!=
nil
{
return
id
,
err
}
else
if
len
(
b
)
!=
len
(
id
)
{
...
...
swarm/storage/dbstore.go
View file @
f2da6581
...
...
@@ -354,7 +354,7 @@ func (s *DbStore) Get(key Key) (chunk *Chunk, err error) {
hasher
:=
s
.
hashfunc
()
hasher
.
Write
(
data
)
hash
:=
hasher
.
Sum
(
nil
)
if
bytes
.
Compare
(
hash
,
key
)
!=
0
{
if
!
bytes
.
Equal
(
hash
,
key
)
{
s
.
db
.
Delete
(
getDataKey
(
index
.
Idx
))
err
=
fmt
.
Errorf
(
"invalid chunk. hash=%x, key=%v"
,
hash
,
key
[
:
])
return
...
...
swarm/storage/types.go
View file @
f2da6581
...
...
@@ -41,7 +41,7 @@ func (x Key) Size() uint {
}
func
(
x
Key
)
isEqual
(
y
Key
)
bool
{
return
bytes
.
Compare
(
x
,
y
)
==
0
return
bytes
.
Equal
(
x
,
y
)
}
func
(
h
Key
)
bits
(
i
,
j
uint
)
uint
{
...
...
tests/block_test_util.go
View file @
f2da6581
...
...
@@ -552,9 +552,7 @@ func LoadBlockTests(file string) (map[string]*BlockTest, error) {
// Nothing to see here, please move along...
func
prepInt
(
base
int
,
s
string
)
string
{
if
base
==
16
{
if
strings
.
HasPrefix
(
s
,
"0x"
)
{
s
=
s
[
2
:
]
}
s
=
strings
.
TrimPrefix
(
s
,
"0x"
)
if
len
(
s
)
==
0
{
s
=
"00"
}
...
...
tests/init.go
View file @
f2da6581
...
...
@@ -87,11 +87,7 @@ func readJsonHttp(uri string, value interface{}) error {
}
defer
resp
.
Body
.
Close
()
err
=
readJson
(
resp
.
Body
,
value
)
if
err
!=
nil
{
return
err
}
return
nil
return
readJson
(
resp
.
Body
,
value
)
}
func
readJsonFile
(
fn
string
,
value
interface
{})
error
{
...
...
tests/state_test_util.go
View file @
f2da6581
...
...
@@ -159,7 +159,7 @@ func runStateTest(chainConfig *params.ChainConfig, test VmTest) error {
}
else
{
rexp
=
common
.
FromHex
(
test
.
Out
)
}
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
if
!
bytes
.
Equal
(
rexp
,
ret
)
{
return
fmt
.
Errorf
(
"return failed. Expected %x, got %x
\n
"
,
rexp
,
ret
)
}
...
...
tests/vm_test_util.go
View file @
f2da6581
...
...
@@ -172,7 +172,7 @@ func runVmTest(test VmTest) error {
// Compare expected and actual return
rexp
:=
common
.
FromHex
(
test
.
Out
)
if
bytes
.
Compare
(
rexp
,
ret
)
!=
0
{
if
!
bytes
.
Equal
(
rexp
,
ret
)
{
return
fmt
.
Errorf
(
"return failed. Expected %x, got %x
\n
"
,
rexp
,
ret
)
}
...
...
trie/sync_test.go
View file @
f2da6581
...
...
@@ -67,7 +67,7 @@ func checkTrieContents(t *testing.T, db Database, root []byte, content map[strin
t
.
Fatalf
(
"inconsistent trie at %x: %v"
,
root
,
err
)
}
for
key
,
val
:=
range
content
{
if
have
:=
trie
.
Get
([]
byte
(
key
));
bytes
.
Compare
(
have
,
val
)
!=
0
{
if
have
:=
trie
.
Get
([]
byte
(
key
));
!
bytes
.
Equal
(
have
,
val
)
{
t
.
Errorf
(
"entry %x: content mismatch: have %x, want %x"
,
key
,
have
,
val
)
}
}
...
...
whisper/shhapi/api.go
View file @
f2da6581
...
...
@@ -178,14 +178,10 @@ func (api *PublicWhisperAPI) NewFilter(args WhisperFilterArgs) (uint32, error) {
Messages
:
make
(
map
[
common
.
Hash
]
*
whisperv5
.
ReceivedMessage
),
AcceptP2P
:
args
.
AcceptP2P
,
}
if
len
(
filter
.
KeySym
)
>
0
{
filter
.
SymKeyHash
=
crypto
.
Keccak256Hash
(
filter
.
KeySym
)
}
for
_
,
t
:=
range
args
.
Topics
{
filter
.
Topics
=
append
(
filter
.
Topics
,
t
)
}
filter
.
Topics
=
append
(
filter
.
Topics
,
args
.
Topics
...
)
if
len
(
args
.
Topics
)
==
0
{
info
:=
"NewFilter: at least one topic must be specified"
...
...
whisper/shhapi/api_test.go
View file @
f2da6581
...
...
@@ -253,7 +253,7 @@ func TestUnmarshalPostArgs(t *testing.T) {
if
a
.
FilterID
!=
64
{
t
.
Fatalf
(
"wrong FilterID: %d."
,
a
.
FilterID
)
}
if
bytes
.
Compare
(
a
.
PeerID
[
:
],
a
.
Topic
[
:
])
!=
0
{
if
!
bytes
.
Equal
(
a
.
PeerID
[
:
],
a
.
Topic
[
:
])
{
t
.
Fatalf
(
"wrong PeerID: %x."
,
a
.
PeerID
)
}
}
...
...
whisper/whisperv2/envelope_test.go
View file @
f2da6581
...
...
@@ -40,10 +40,10 @@ func TestEnvelopeOpen(t *testing.T) {
if
opened
.
Flags
!=
message
.
Flags
{
t
.
Fatalf
(
"flags mismatch: have %d, want %d"
,
opened
.
Flags
,
message
.
Flags
)
}
if
bytes
.
Compare
(
opened
.
Signature
,
message
.
Signature
)
!=
0
{
if
!
bytes
.
Equal
(
opened
.
Signature
,
message
.
Signature
)
{
t
.
Fatalf
(
"signature mismatch: have 0x%x, want 0x%x"
,
opened
.
Signature
,
message
.
Signature
)
}
if
bytes
.
Compare
(
opened
.
Payload
,
message
.
Payload
)
!=
0
{
if
!
bytes
.
Equal
(
opened
.
Payload
,
message
.
Payload
)
{
t
.
Fatalf
(
"payload mismatch: have 0x%x, want 0x%x"
,
opened
.
Payload
,
message
.
Payload
)
}
if
opened
.
Sent
.
Unix
()
!=
message
.
Sent
.
Unix
()
{
...
...
@@ -71,7 +71,7 @@ func TestEnvelopeAnonymousOpenUntargeted(t *testing.T) {
if
opened
.
To
!=
nil
{
t
.
Fatalf
(
"recipient mismatch: have 0x%x, want nil"
,
opened
.
To
)
}
if
bytes
.
Compare
(
opened
.
Payload
,
payload
)
!=
0
{
if
!
bytes
.
Equal
(
opened
.
Payload
,
payload
)
{
t
.
Fatalf
(
"payload mismatch: have 0x%x, want 0x%x"
,
opened
.
Payload
,
payload
)
}
}
...
...
@@ -96,7 +96,7 @@ func TestEnvelopeAnonymousOpenTargeted(t *testing.T) {
if
opened
.
To
!=
nil
{
t
.
Fatalf
(
"recipient mismatch: have 0x%x, want nil"
,
opened
.
To
)
}
if
bytes
.
Compare
(
opened
.
Payload
,
payload
)
==
0
{
if
bytes
.
Equal
(
opened
.
Payload
,
payload
)
{
t
.
Fatalf
(
"payload match, should have been encrypted: 0x%x"
,
opened
.
Payload
)
}
}
...
...
@@ -127,7 +127,7 @@ func TestEnvelopeIdentifiedOpenUntargeted(t *testing.T) {
if
opened
.
To
!=
nil
{
t
.
Fatalf
(
"recipient mismatch: have 0x%x, want nil"
,
opened
.
To
)
}
if
bytes
.
Compare
(
opened
.
Payload
,
payload
)
!=
0
{
if
!
bytes
.
Equal
(
opened
.
Payload
,
payload
)
{
t
.
Fatalf
(
"payload mismatch: have 0x%x, want 0x%x"
,
opened
.
Payload
,
payload
)
}
}
...
...
@@ -152,7 +152,7 @@ func TestEnvelopeIdentifiedOpenTargeted(t *testing.T) {
if
opened
.
To
!=
nil
{
t
.
Fatalf
(
"recipient mismatch: have 0x%x, want nil"
,
opened
.
To
)
}
if
bytes
.
Compare
(
opened
.
Payload
,
payload
)
!=
0
{
if
!
bytes
.
Equal
(
opened
.
Payload
,
payload
)
{
t
.
Fatalf
(
"payload mismatch: have 0x%x, want 0x%x"
,
opened
.
Payload
,
payload
)
}
}
whisper/whisperv2/filter.go
View file @
f2da6581
...
...
@@ -120,10 +120,7 @@ func (self filterer) Compare(f filter.Filter) bool {
break
}
}
if
!
self
.
matcher
.
Matches
(
topics
)
{
return
false
}
return
true
return
self
.
matcher
.
Matches
(
topics
)
}
// Trigger is called when a filter successfully matches an inbound message.
...
...
whisper/whisperv2/filter_test.go
View file @
f2da6581
...
...
@@ -91,7 +91,7 @@ func TestFilterTopicsCreation(t *testing.T) {
continue
}
for
k
:=
0
;
k
<
len
(
condition
);
k
++
{
if
bytes
.
Compare
(
condition
[
k
][
:
],
tt
.
filter
[
j
][
k
][
:
])
!=
0
{
if
!
bytes
.
Equal
(
condition
[
k
][
:
],
tt
.
filter
[
j
][
k
][
:
])
{
t
.
Errorf
(
"test %d, condition %d, segment %d: filter mismatch: have 0x%x, want 0x%x"
,
i
,
j
,
k
,
condition
[
k
],
tt
.
filter
[
j
][
k
])
}
}
...
...
@@ -115,7 +115,7 @@ func TestFilterTopicsCreation(t *testing.T) {
continue
}
for
k
:=
0
;
k
<
len
(
condition
);
k
++
{
if
bytes
.
Compare
(
condition
[
k
][
:
],
tt
.
filter
[
j
][
k
][
:
])
!=
0
{
if
!
bytes
.
Equal
(
condition
[
k
][
:
],
tt
.
filter
[
j
][
k
][
:
])
{
t
.
Errorf
(
"test %d, condition %d, segment %d: filter mismatch: have 0x%x, want 0x%x"
,
i
,
j
,
k
,
condition
[
k
],
tt
.
filter
[
j
][
k
])
}
}
...
...
@@ -135,7 +135,7 @@ func TestFilterTopicsCreation(t *testing.T) {
continue
}
for
k
:=
0
;
k
<
len
(
condition
);
k
++
{
if
bytes
.
Compare
(
condition
[
k
][
:
],
tt
.
filter
[
j
][
k
][
:
])
!=
0
{
if
!
bytes
.
Equal
(
condition
[
k
][
:
],
tt
.
filter
[
j
][
k
][
:
])
{
t
.
Errorf
(
"test %d, condition %d, segment %d: filter mismatch: have 0x%x, want 0x%x"
,
i
,
j
,
k
,
condition
[
k
],
tt
.
filter
[
j
][
k
])
}
}
...
...
@@ -156,7 +156,7 @@ func TestFilterTopicsCreation(t *testing.T) {
continue
}
for
k
:=
0
;
k
<
len
(
condition
);
k
++
{
if
bytes
.
Compare
(
condition
[
k
][
:
],
tt
.
filter
[
j
][
k
][
:
])
!=
0
{
if
!
bytes
.
Equal
(
condition
[
k
][
:
],
tt
.
filter
[
j
][
k
][
:
])
{
t
.
Errorf
(
"test %d, condition %d, segment %d: filter mismatch: have 0x%x, want 0x%x"
,
i
,
j
,
k
,
condition
[
k
],
tt
.
filter
[
j
][
k
])
}
}
...
...
whisper/whisperv2/message_test.go
View file @
f2da6581
...
...
@@ -40,7 +40,7 @@ func TestMessageSimpleWrap(t *testing.T) {
if
len
(
msg
.
Signature
)
!=
0
{
t
.
Fatalf
(
"signature found for simple wrapping: 0x%x"
,
msg
.
Signature
)
}
if
bytes
.
Compare
(
msg
.
Payload
,
payload
)
!=
0
{
if
!
bytes
.
Equal
(
msg
.
Payload
,
payload
)
{
t
.
Fatalf
(
"payload mismatch after wrapping: have 0x%x, want 0x%x"
,
msg
.
Payload
,
payload
)
}
if
msg
.
TTL
/
time
.
Second
!=
DefaultTTL
/
time
.
Second
{
...
...
@@ -65,7 +65,7 @@ func TestMessageCleartextSignRecover(t *testing.T) {
if
msg
.
Flags
&
signatureFlag
!=
signatureFlag
{
t
.
Fatalf
(
"signature flag mismatch: have %d, want %d"
,
msg
.
Flags
&
signatureFlag
,
signatureFlag
)
}
if
bytes
.
Compare
(
msg
.
Payload
,
payload
)
!=
0
{
if
!
bytes
.
Equal
(
msg
.
Payload
,
payload
)
{
t
.
Fatalf
(
"payload mismatch after signing: have 0x%x, want 0x%x"
,
msg
.
Payload
,
payload
)
}
...
...
whisper/whisperv2/topic_test.go
View file @
f2da6581
...
...
@@ -33,13 +33,13 @@ func TestTopicCreation(t *testing.T) {
// Create the topics individually
for
i
,
tt
:=
range
topicCreationTests
{
topic
:=
NewTopic
(
tt
.
data
)
if
bytes
.
Compare
(
topic
[
:
],
tt
.
hash
[
:
])
!=
0
{
if
!
bytes
.
Equal
(
topic
[
:
],
tt
.
hash
[
:
])
{
t
.
Errorf
(
"binary test %d: hash mismatch: have %v, want %v."
,
i
,
topic
,
tt
.
hash
)
}
}
for
i
,
tt
:=
range
topicCreationTests
{
topic
:=
NewTopicFromString
(
string
(
tt
.
data
))
if
bytes
.
Compare
(
topic
[
:
],
tt
.
hash
[
:
])
!=
0
{
if
!
bytes
.
Equal
(
topic
[
:
],
tt
.
hash
[
:
])
{
t
.
Errorf
(
"textual test %d: hash mismatch: have %v, want %v."
,
i
,
topic
,
tt
.
hash
)
}
}
...
...
@@ -55,13 +55,13 @@ func TestTopicCreation(t *testing.T) {
topics
:=
NewTopics
(
binaryData
...
)
for
i
,
tt
:=
range
topicCreationTests
{
if
bytes
.
Compare
(
topics
[
i
][
:
],
tt
.
hash
[
:
])
!=
0
{
if
!
bytes
.
Equal
(
topics
[
i
][
:
],
tt
.
hash
[
:
])
{
t
.
Errorf
(
"binary batch test %d: hash mismatch: have %v, want %v."
,
i
,
topics
[
i
],
tt
.
hash
)
}
}
topics
=
NewTopicsFromStrings
(
textualData
...
)
for
i
,
tt
:=
range
topicCreationTests
{
if
bytes
.
Compare
(
topics
[
i
][
:
],
tt
.
hash
[
:
])
!=
0
{
if
!
bytes
.
Equal
(
topics
[
i
][
:
],
tt
.
hash
[
:
])
{
t
.
Errorf
(
"textual batch test %d: hash mismatch: have %v, want %v."
,
i
,
topics
[
i
],
tt
.
hash
)
}
}
...
...
whisper/whisperv5/message_test.go
View file @
f2da6581
...
...
@@ -104,10 +104,10 @@ func singleMessageTest(t *testing.T, symmetric bool) {
}
padsz
:=
len
(
decrypted
.
Padding
)
if
bytes
.
Compare
(
steg
[
:
padsz
],
decrypted
.
Padding
)
!=
0
{
if
!
bytes
.
Equal
(
steg
[
:
padsz
],
decrypted
.
Padding
)
{
t
.
Fatalf
(
"failed with seed %d: compare padding."
,
seed
)
}
if
bytes
.
Compare
(
text
,
decrypted
.
Payload
)
!=
0
{
if
!
bytes
.
Equal
(
text
,
decrypted
.
Payload
)
{
t
.
Fatalf
(
"failed with seed %d: compare payload."
,
seed
)
}
if
!
isMessageSigned
(
decrypted
.
Raw
[
0
])
{
...
...
@@ -256,10 +256,10 @@ func singleEnvelopeOpenTest(t *testing.T, symmetric bool) {
}
padsz
:=
len
(
decrypted
.
Padding
)
if
bytes
.
Compare
(
steg
[
:
padsz
],
decrypted
.
Padding
)
!=
0
{
if
!
bytes
.
Equal
(
steg
[
:
padsz
],
decrypted
.
Padding
)
{
t
.
Fatalf
(
"failed with seed %d: compare padding."
,
seed
)
}
if
bytes
.
Compare
(
text
,
decrypted
.
Payload
)
!=
0
{
if
!
bytes
.
Equal
(
text
,
decrypted
.
Payload
)
{
t
.
Fatalf
(
"failed with seed %d: compare payload."
,
seed
)
}
if
!
isMessageSigned
(
decrypted
.
Raw
[
0
])
{
...
...
whisper/whisperv5/peer_test.go
View file @
f2da6581
...
...
@@ -207,7 +207,7 @@ func checkPropagation(t *testing.T) {
func
validateMail
(
t
*
testing
.
T
,
index
int
,
mail
[]
*
ReceivedMessage
)
bool
{
var
cnt
int
for
_
,
m
:=
range
mail
{
if
bytes
.
Compare
(
m
.
Payload
,
expectedMessage
)
==
0
{
if
bytes
.
Equal
(
m
.
Payload
,
expectedMessage
)
{
cnt
++
}
}
...
...
whisper/whisperv5/whisper_test.go
View file @
f2da6581
...
...
@@ -239,7 +239,7 @@ func TestWhisperSymKeyManagement(t *testing.T) {
if
k1
==
nil
{
t
.
Fatalf
(
"first key does not exist."
)
}
if
bytes
.
Compare
(
k1
,
randomKey
)
==
0
{
if
bytes
.
Equal
(
k1
,
randomKey
)
{
t
.
Fatalf
(
"k1 == randomKey."
)
}
if
k2
!=
nil
{
...
...
@@ -264,10 +264,10 @@ func TestWhisperSymKeyManagement(t *testing.T) {
if
k2
==
nil
{
t
.
Fatalf
(
"k2 does not exist."
)
}
if
bytes
.
Compare
(
k1
,
k2
)
==
0
{
if
bytes
.
Equal
(
k1
,
k2
)
{
t
.
Fatalf
(
"k1 == k2."
)
}
if
bytes
.
Compare
(
k1
,
randomKey
)
==
0
{
if
bytes
.
Equal
(
k1
,
randomKey
)
{
t
.
Fatalf
(
"k1 == randomKey."
)
}
if
len
(
k1
)
!=
aesKeyLength
{
...
...
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