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
216fc267
Commit
216fc267
authored
Jun 26, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: fix local/remote cap/protocol mixup
parent
d84638bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
peer_test.go
p2p/peer_test.go
+23
-23
No files found.
p2p/peer_test.go
View file @
216fc267
...
@@ -199,68 +199,68 @@ func TestNewPeer(t *testing.T) {
...
@@ -199,68 +199,68 @@ func TestNewPeer(t *testing.T) {
func
TestMatchProtocols
(
t
*
testing
.
T
)
{
func
TestMatchProtocols
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
Local
[]
Cap
Remote
[]
Cap
Remote
[]
Protocol
Local
[]
Protocol
Match
map
[
string
]
protoRW
Match
map
[
string
]
protoRW
}{
}{
{
{
// No remote
protocol
s
// No remote
capabilitie
s
Local
:
[]
Cap
{{
Name
:
"a"
}},
Local
:
[]
Protocol
{{
Name
:
"a"
}},
},
},
{
{
// No local
capabilitie
s
// No local
protocol
s
Remote
:
[]
Protocol
{{
Name
:
"a"
}},
Remote
:
[]
Cap
{{
Name
:
"a"
}},
},
},
{
{
// No mutual protocols
// No mutual protocols
Local
:
[]
Cap
{{
Name
:
"a"
}},
Remote
:
[]
Cap
{{
Name
:
"a"
}},
Remote
:
[]
Protocol
{{
Name
:
"b"
}},
Local
:
[]
Protocol
{{
Name
:
"b"
}},
},
},
{
{
// Some matches, some differences
// Some matches, some differences
Local
:
[]
Cap
{{
Name
:
"local"
},
{
Name
:
"match1"
},
{
Name
:
"match2"
}},
Remote
:
[]
Cap
{{
Name
:
"local"
},
{
Name
:
"match1"
},
{
Name
:
"match2"
}},
Remote
:
[]
Protocol
{{
Name
:
"match1"
},
{
Name
:
"match2"
},
{
Name
:
"remote"
}},
Local
:
[]
Protocol
{{
Name
:
"match1"
},
{
Name
:
"match2"
},
{
Name
:
"remote"
}},
Match
:
map
[
string
]
protoRW
{
"match1"
:
{
Protocol
:
Protocol
{
Name
:
"match1"
}},
"match2"
:
{
Protocol
:
Protocol
{
Name
:
"match2"
}}},
Match
:
map
[
string
]
protoRW
{
"match1"
:
{
Protocol
:
Protocol
{
Name
:
"match1"
}},
"match2"
:
{
Protocol
:
Protocol
{
Name
:
"match2"
}}},
},
},
{
{
// Various alphabetical ordering
// Various alphabetical ordering
Local
:
[]
Cap
{{
Name
:
"aa"
},
{
Name
:
"ab"
},
{
Name
:
"bb"
},
{
Name
:
"ba"
}},
Remote
:
[]
Cap
{{
Name
:
"aa"
},
{
Name
:
"ab"
},
{
Name
:
"bb"
},
{
Name
:
"ba"
}},
Remote
:
[]
Protocol
{{
Name
:
"ba"
},
{
Name
:
"bb"
},
{
Name
:
"ab"
},
{
Name
:
"aa"
}},
Local
:
[]
Protocol
{{
Name
:
"ba"
},
{
Name
:
"bb"
},
{
Name
:
"ab"
},
{
Name
:
"aa"
}},
Match
:
map
[
string
]
protoRW
{
"aa"
:
{
Protocol
:
Protocol
{
Name
:
"aa"
}},
"ab"
:
{
Protocol
:
Protocol
{
Name
:
"ab"
}},
"ba"
:
{
Protocol
:
Protocol
{
Name
:
"ba"
}},
"bb"
:
{
Protocol
:
Protocol
{
Name
:
"bb"
}}},
Match
:
map
[
string
]
protoRW
{
"aa"
:
{
Protocol
:
Protocol
{
Name
:
"aa"
}},
"ab"
:
{
Protocol
:
Protocol
{
Name
:
"ab"
}},
"ba"
:
{
Protocol
:
Protocol
{
Name
:
"ba"
}},
"bb"
:
{
Protocol
:
Protocol
{
Name
:
"bb"
}}},
},
},
{
{
// No mutual versions
// No mutual versions
Local
:
[]
Cap
{{
Version
:
1
}},
Remote
:
[]
Cap
{{
Version
:
1
}},
Remote
:
[]
Protocol
{{
Version
:
2
}},
Local
:
[]
Protocol
{{
Version
:
2
}},
},
},
{
{
// Multiple versions, single common
// Multiple versions, single common
Local
:
[]
Cap
{{
Version
:
1
},
{
Version
:
2
}},
Remote
:
[]
Cap
{{
Version
:
1
},
{
Version
:
2
}},
Remote
:
[]
Protocol
{{
Version
:
2
},
{
Version
:
3
}},
Local
:
[]
Protocol
{{
Version
:
2
},
{
Version
:
3
}},
Match
:
map
[
string
]
protoRW
{
""
:
{
Protocol
:
Protocol
{
Version
:
2
}}},
Match
:
map
[
string
]
protoRW
{
""
:
{
Protocol
:
Protocol
{
Version
:
2
}}},
},
},
{
{
// Multiple versions, multiple common
// Multiple versions, multiple common
Local
:
[]
Cap
{{
Version
:
1
},
{
Version
:
2
},
{
Version
:
3
},
{
Version
:
4
}},
Remote
:
[]
Cap
{{
Version
:
1
},
{
Version
:
2
},
{
Version
:
3
},
{
Version
:
4
}},
Remote
:
[]
Protocol
{{
Version
:
2
},
{
Version
:
3
}},
Local
:
[]
Protocol
{{
Version
:
2
},
{
Version
:
3
}},
Match
:
map
[
string
]
protoRW
{
""
:
{
Protocol
:
Protocol
{
Version
:
3
}}},
Match
:
map
[
string
]
protoRW
{
""
:
{
Protocol
:
Protocol
{
Version
:
3
}}},
},
},
{
{
// Various version orderings
// Various version orderings
Local
:
[]
Cap
{{
Version
:
4
},
{
Version
:
1
},
{
Version
:
3
},
{
Version
:
2
}},
Remote
:
[]
Cap
{{
Version
:
4
},
{
Version
:
1
},
{
Version
:
3
},
{
Version
:
2
}},
Remote
:
[]
Protocol
{{
Version
:
2
},
{
Version
:
3
},
{
Version
:
1
}},
Local
:
[]
Protocol
{{
Version
:
2
},
{
Version
:
3
},
{
Version
:
1
}},
Match
:
map
[
string
]
protoRW
{
""
:
{
Protocol
:
Protocol
{
Version
:
3
}}},
Match
:
map
[
string
]
protoRW
{
""
:
{
Protocol
:
Protocol
{
Version
:
3
}}},
},
},
{
{
// Versions overriding sub-protocol lengths
// Versions overriding sub-protocol lengths
Local
:
[]
Cap
{{
Version
:
1
},
{
Version
:
2
},
{
Version
:
3
},
{
Name
:
"a"
}},
Remote
:
[]
Cap
{{
Version
:
1
},
{
Version
:
2
},
{
Version
:
3
},
{
Name
:
"a"
}},
Remote
:
[]
Protocol
{{
Version
:
1
,
Length
:
1
},
{
Version
:
2
,
Length
:
2
},
{
Version
:
3
,
Length
:
3
},
{
Name
:
"a"
}},
Local
:
[]
Protocol
{{
Version
:
1
,
Length
:
1
},
{
Version
:
2
,
Length
:
2
},
{
Version
:
3
,
Length
:
3
},
{
Name
:
"a"
}},
Match
:
map
[
string
]
protoRW
{
""
:
{
Protocol
:
Protocol
{
Version
:
3
}},
"a"
:
{
Protocol
:
Protocol
{
Name
:
"a"
},
offset
:
3
}},
Match
:
map
[
string
]
protoRW
{
""
:
{
Protocol
:
Protocol
{
Version
:
3
}},
"a"
:
{
Protocol
:
Protocol
{
Name
:
"a"
},
offset
:
3
}},
},
},
}
}
for
i
,
tt
:=
range
tests
{
for
i
,
tt
:=
range
tests
{
result
:=
matchProtocols
(
tt
.
Remote
,
tt
.
Local
,
nil
)
result
:=
matchProtocols
(
tt
.
Local
,
tt
.
Remote
,
nil
)
if
len
(
result
)
!=
len
(
tt
.
Match
)
{
if
len
(
result
)
!=
len
(
tt
.
Match
)
{
t
.
Errorf
(
"test %d: negotiation mismatch: have %v, want %v"
,
i
,
len
(
result
),
len
(
tt
.
Match
))
t
.
Errorf
(
"test %d: negotiation mismatch: have %v, want %v"
,
i
,
len
(
result
),
len
(
tt
.
Match
))
continue
continue
...
...
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