Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
zhifan huang
re6stnet
Commits
304784ba
Commit
304784ba
authored
Jun 13, 2022
by
zhifan huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: correct typo error
parent
7c56771f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
3 deletions
+46
-3
re6st/tests/test_unit/test_tunnel/test_base_tunnel_manager.py
...t/tests/test_unit/test_tunnel/test_base_tunnel_manager.py
+46
-3
No files found.
re6st/tests/test_unit/test_tunnel/test_base_tunnel_manager.py
View file @
304784ba
...
...
@@ -3,6 +3,7 @@ import os
import
sys
import
unittest
import
time
import
collections
from
mock
import
patch
,
Mock
...
...
@@ -23,11 +24,11 @@ class testBaseTunnelManager(unittest.TestCase):
def
setUp
(
self
):
patcher
=
patch
(
"re6st.cache.Cache"
)
pacher_sock
=
patch
(
"socket.socket"
)
pa
t
cher_sock
=
patch
(
"socket.socket"
)
self
.
addCleanup
(
patcher
.
stop
)
self
.
addCleanup
(
pacher_sock
.
stop
)
self
.
addCleanup
(
pa
t
cher_sock
.
stop
)
self
.
cache
=
patcher
.
start
()()
self
.
sock
=
pacher_sock
.
start
()
self
.
sock
=
pa
t
cher_sock
.
start
()
self
.
cache
.
same_country
=
False
address
=
[(
2
,
[(
'10.0.0.2'
,
'1194'
,
'udp'
),
(
'10.0.0.2'
,
'1194'
,
'tcp'
)])]
...
...
@@ -190,5 +191,47 @@ class testBaseTunnelManager(unittest.TestCase):
self
.
assertEqual
(
peer
.
version
,
version2
)
self
.
assertEqual
(
selectTimeout
.
call_args
[
0
][
1
],
self
.
tunnel
.
newVersion
)
def
test_invalidatePeers
(
self
):
Peer
=
collections
.
namedtuple
(
"Peer"
,
[
"prefix"
,
"stop_date"
])
p1
=
Peer
(
"0001"
,
0
)
p2
=
Peer
(
"0002"
,
time
.
time
()
+
30
)
p3
=
Peer
(
"0003"
,
time
.
time
()
+
100
)
self
.
tunnel
.
_peers
=
[
p1
,
p2
,
p3
]
self
.
tunnel
.
invalidatePeers
()
self
.
assertEqual
(
self
.
tunnel
.
_peers
,
[
p2
,
p3
])
self
.
assertIn
((
p2
.
stop_date
,
self
.
tunnel
.
invalidatePeers
),
self
.
tunnel
.
_timeouts
)
@
patch
(
"re6st.tunnel.BaseTunnelManager._sendto"
)
def
test_sendto
(
self
,
_sendto
):
"""send to known peer"""
p
=
Mock
()
p
.
prefix
=
format
(
3
,
'016b'
)
p
.
connected
=
True
self
.
tunnel
.
_peers
.
append
(
p
)
msg
=
"a msg"
self
.
tunnel
.
sendto
(
p
.
prefix
,
msg
)
self
.
assertIn
(
msg
,
_sendto
.
call_args
.
args
)
self
.
assertIn
(
p
,
_sendto
.
call_args
.
args
)
@
patch
(
"re6st.tunnel.BaseTunnelManager._sendto"
)
def
test_sendto_unknown
(
self
,
_sendto
):
"""send to known peer"""
prefix
=
format
(
3
,
'016b'
)
self
.
tunnel
.
sendto
(
prefix
,
"a msg"
)
peer
=
self
.
tunnel
.
_getPeer
(
prefix
)
self
.
assertEqual
(
peer
.
prefix
,
prefix
)
_sendto
.
assert_called_once
()
def
handlePeerEvent
(
self
):
pass
if
__name__
==
"__main__"
:
unittest
.
main
()
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