aboutsummaryrefslogtreecommitdiff
path: root/keys_test.go
blob: c9d6d1e91281b8f40638c351be96d151abac634b (plain)
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
31
32
33
34
35
36
package main

import (
	"bytes"
	"testing"
)

func TestUnmarshalSig(t *testing.T) {
	b64sig := []byte(`RWRbOC0bBf7abaGwGtq45KLDK63tgcF7CO4qTZSlTKCSbZTYlDfFm/DISQ60u+/jEzrk22suvXXAEsxQTe2xUOfV90get1YRGQo=`)
	v := new(Sig)
	DecodeBase64(v, b64sig)
	out, _ := EncodeBase64(v)
	if !bytes.Equal(b64sig, out) {
		t.Errorf("expected %v, got %v", b64sig, out)
	}
}

func TestUnmarshalPub(t *testing.T) {
	b64pub := []byte(`RWRbOC0bBf7abfanaXuTYfCa6+YO69Kxyz8RD5nL/3Ta7umY6iOwnBrG`)
	v := new(PubKey)
	DecodeBase64(v, b64pub)
	out, _ := EncodeBase64(v)
	if !bytes.Equal(b64pub, out) {
		t.Errorf("expected %v, got %v", b64pub, out)
	}
}

func TestUnmarshalEnc(t *testing.T) {
	b64enc := []byte(`RWRCSwAAAACzJBN2gC5//jVvDiV76rs4m2aKXkljqDpbOC0bBf7abZhV/Zygr6b0KIbSI56JQutwzsQeouxnnHuVTZp3IW4M9qdpe5Nh8Jrr5g7r0rHLPxEPmcv/dNru6ZjqI7CcGsY=`)
	v := new(EncKey)
	DecodeBase64(v, b64enc)
	out, _ := EncodeBase64(v)
	if !bytes.Equal(b64enc, out) {
		t.Errorf("expected %v, got %v", b64enc, out)
	}
}