good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
2b9fd6b4
Commit
2b9fd6b4
authored
10 years ago
by
Péter Szilágyi
Browse files
Options
Downloads
Patches
Plain Diff
whisper: add full filter test suite
parent
406e74e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
whisper/filter_test.go
+50
-0
50 additions, 0 deletions
whisper/filter_test.go
whisper/peer.go
+1
-2
1 addition, 2 deletions
whisper/peer.go
with
51 additions
and
2 deletions
whisper/filter_test.go
+
50
−
0
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
)
}
}
}
This diff is collapsed.
Click to expand it.
whisper/peer.go
+
1
−
2
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
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment