forked from ooni/minivpn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package reliabletransport | ||
|
||
import ( | ||
"github.com/apex/log" | ||
"github.com/ooni/minivpn/internal/bytesx" | ||
"github.com/ooni/minivpn/internal/model" | ||
"github.com/ooni/minivpn/internal/session" | ||
"github.com/ooni/minivpn/internal/workers" | ||
) | ||
|
||
// | ||
// Common utilities for tests in this package. | ||
// | ||
|
||
// initManagers initializes a workers manager and a session manager. | ||
func initManagers() (*workers.Manager, *session.Manager) { | ||
w := workers.NewManager(log.Log) | ||
s, err := session.NewManager(log.Log) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return w, s | ||
} | ||
|
||
// newRandomSessionID returns a random session ID to initialize mock sessions. | ||
func newRandomSessionID() model.SessionID { | ||
b, err := bytesx.GenRandomBytes(8) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return model.SessionID(b) | ||
} | ||
|
||
func ackSetFromInts(s []int) *ackSet { | ||
acks := make([]model.PacketID, 0) | ||
for _, i := range s { | ||
acks = append(acks, model.PacketID(i)) | ||
} | ||
return newACKSet(acks...) | ||
} | ||
|
||
func ackSetFromRange(start, total int) *ackSet { | ||
acks := make([]model.PacketID, 0) | ||
for i := 0; i < total; i++ { | ||
acks = append(acks, model.PacketID(start+i)) | ||
} | ||
return newACKSet(acks...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters