-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathstrategy_test.go
66 lines (56 loc) · 1.35 KB
/
strategy_test.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package handshake
import (
"encoding/base64"
"testing"
)
func TestExportStrategy(t *testing.T) {
privateKeyString := "6zjTWCoDkKESjroDj26qrw0/xSU0B14Co/lIZZHhbHUFFt6rMcqyLt21y1PmoPJbokhXrvO4p+zauvk+GuujzA=="
privateKey, err := base64.StdEncoding.DecodeString(privateKeyString)
if err != nil {
t.Errorf("base64 failed to decode: %v\n", err)
}
publicKey := privateKey[32:]
n := node{
URL: "https://prototype.hashmap.sh",
}
sig := signatureAlgorithm{
Type: ed25519,
PrivateKey: privateKey,
PublicKey: publicKey,
}
rOpts := StorageOptions{
WriteNodes: []node{n},
Signatures: []signatureAlgorithm{sig},
WriteRule: defaultConsensusRule,
}
r, err := newHashmapStorage(rOpts)
if err != nil {
t.Errorf("new hashmapStore failed: %v\n", err)
}
settings := make(map[string]string)
settings["query_type"] = "api"
n2 := node{
URL: "https://ipfs.infura.io:5001/",
Settings: settings,
}
sOpts := StorageOptions{
WriteNodes: []node{n2},
WriteRule: defaultConsensusRule,
}
s, err := newIPFSStorage(sOpts)
if err != nil {
t.Errorf("new IPFS storage failed: %v\n", err)
}
c := newDefaultSBCipher()
strat := strategy{
Rendezvous: r,
Storage: s,
Cipher: c,
}
t.Log(strat.Share())
stratJson, err := strat.ShareJSONBytes()
if err != nil {
t.Errorf("failed on json bytes %v", err)
}
t.Log(string(stratJson))
}