mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-08 23:30:53 +00:00
Add tests, fix some bugs uncovered by the tests
This commit is contained in:
parent
8a24ac37ab
commit
0c9e7bb97d
7 changed files with 261 additions and 30 deletions
|
@ -6,29 +6,32 @@ import (
|
|||
"crypto/rand"
|
||||
)
|
||||
|
||||
func TestSealRequest(t *testing.T) {
|
||||
senderPublic, senderPrivate, err := box.GenerateKey(rand.Reader)
|
||||
func SetupRandomKeys(t testing.TB) {
|
||||
_, senderPrivate, err := box.GenerateKey(rand.Reader)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
receiverPublic, receiverPrivate, err := box.GenerateKey(rand.Reader)
|
||||
receiverPublic, _, err := box.GenerateKey(rand.Reader)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
box.Precompute(&backendSharedKey, receiverPublic, senderPrivate)
|
||||
messageBufferPool.New = New4KByteBuffer
|
||||
}
|
||||
|
||||
func TestSealRequest(t *testing.T) {
|
||||
SetupRandomKeys(t)
|
||||
|
||||
values := url.Values{
|
||||
"QuickBrownFox": []string{"LazyDog"},
|
||||
}
|
||||
|
||||
box.Precompute(&backendSharedKey, receiverPublic, senderPrivate)
|
||||
sealedValues, err := SealRequest(values)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
box.Precompute(&backendSharedKey, senderPublic, receiverPrivate)
|
||||
unsealedValues, err := UnsealRequest(sealedValues)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue