forked from perlin-network/noise
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_test.go
More file actions
30 lines (23 loc) · 675 Bytes
/
mod_test.go
File metadata and controls
30 lines (23 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package noise_test
import (
"encoding/hex"
"encoding/json"
"github.com/oasislabs/ed25519"
"github.com/perlin-network/noise"
"github.com/stretchr/testify/assert"
"testing"
)
func TestMarshalJSON(t *testing.T) {
pub, priv, err := ed25519.GenerateKey(nil)
assert.NoError(t, err)
var pubKey noise.PublicKey
var privKey noise.PrivateKey
copy(pubKey[:], pub)
copy(privKey[:], priv)
pubKeyJSON, err := json.Marshal(pubKey)
assert.NoError(t, err)
privKeyJSON, err := json.Marshal(privKey)
assert.NoError(t, err)
assert.Equal(t, "\""+hex.EncodeToString(pub)+"\"", string(pubKeyJSON))
assert.Equal(t, "\""+hex.EncodeToString(priv)+"\"", string(privKeyJSON))
}