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
2b9fd6b4
Commit
2b9fd6b4
authored
Apr 22, 2015
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whisper: add full filter test suite
parent
406e74e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
2 deletions
+51
-2
filter_test.go
whisper/filter_test.go
+50
-0
peer.go
whisper/peer.go
+1
-2
No files found.
whisper/filter_test.go
View file @
2b9fd6b4
...
...
@@ -147,3 +147,53 @@ func TestFilterTopicsCreation(t *testing.T) {
}
}
}
var
filterCompareTests
=
[]
struct
{
matcher
filterer
message
filterer
match
bool
}{
{
// Wild-card filter matching anything
matcher
:
filterer
{
to
:
""
,
from
:
""
,
matcher
:
newTopicMatcher
()},
message
:
filterer
{
to
:
"to"
,
from
:
"from"
,
matcher
:
newTopicMatcher
(
NewFilterTopicsFromStringsFlat
(
"topic"
)
...
)},
match
:
true
,
},
{
// Filter matching the to field
matcher
:
filterer
{
to
:
"to"
,
from
:
""
,
matcher
:
newTopicMatcher
()},
message
:
filterer
{
to
:
"to"
,
from
:
"from"
,
matcher
:
newTopicMatcher
(
NewFilterTopicsFromStringsFlat
(
"topic"
)
...
)},
match
:
true
,
},
{
// Filter rejecting the to field
matcher
:
filterer
{
to
:
"to"
,
from
:
""
,
matcher
:
newTopicMatcher
()},
message
:
filterer
{
to
:
""
,
from
:
"from"
,
matcher
:
newTopicMatcher
(
NewFilterTopicsFromStringsFlat
(
"topic"
)
...
)},
match
:
false
,
},
{
// Filter matching the from field
matcher
:
filterer
{
to
:
""
,
from
:
"from"
,
matcher
:
newTopicMatcher
()},
message
:
filterer
{
to
:
"to"
,
from
:
"from"
,
matcher
:
newTopicMatcher
(
NewFilterTopicsFromStringsFlat
(
"topic"
)
...
)},
match
:
true
,
},
{
// Filter rejecting the from field
matcher
:
filterer
{
to
:
""
,
from
:
"from"
,
matcher
:
newTopicMatcher
()},
message
:
filterer
{
to
:
"to"
,
from
:
""
,
matcher
:
newTopicMatcher
(
NewFilterTopicsFromStringsFlat
(
"topic"
)
...
)},
match
:
false
,
},
{
// Filter matching the topic field
matcher
:
filterer
{
to
:
""
,
from
:
"from"
,
matcher
:
newTopicMatcher
(
NewFilterTopicsFromStringsFlat
(
"topic"
)
...
)},
message
:
filterer
{
to
:
"to"
,
from
:
"from"
,
matcher
:
newTopicMatcher
(
NewFilterTopicsFromStringsFlat
(
"topic"
)
...
)},
match
:
true
,
},
{
// Filter rejecting the topic field
matcher
:
filterer
{
to
:
""
,
from
:
""
,
matcher
:
newTopicMatcher
(
NewFilterTopicsFromStringsFlat
(
"topic"
)
...
)},
message
:
filterer
{
to
:
"to"
,
from
:
"from"
,
matcher
:
newTopicMatcher
()},
match
:
false
,
},
}
func
TestFilterCompare
(
t
*
testing
.
T
)
{
for
i
,
tt
:=
range
filterCompareTests
{
if
match
:=
tt
.
matcher
.
Compare
(
tt
.
message
);
match
!=
tt
.
match
{
t
.
Errorf
(
"test %d: match mismatch: have %v, want %v"
,
i
,
match
,
tt
.
match
)
}
}
}
whisper/peer.go
View file @
2b9fd6b4
...
...
@@ -21,8 +21,7 @@ type peer struct {
quit
chan
struct
{}
}
// newPeer creates and initializes a new whisper peer connection, returning either
// the newly constructed link or a failure reason.
// newPeer creates a new whisper peer object, but does not run the handshake itself.
func
newPeer
(
host
*
Whisper
,
remote
*
p2p
.
Peer
,
rw
p2p
.
MsgReadWriter
)
*
peer
{
return
&
peer
{
host
:
host
,
...
...
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