@cryptotaxi247 / kubo / commits / dff0c4705

improve keystore sharness tests

Adin Schmahmann committed Aug 4, 2020 at 11:28 UTC dff0c47050cb0404d0fefb7def9f8b7799e9ac2e
2 files changed +25 -15
test/sharness/lib/test-lib.sh
+1 -1
@@ -465,7 +465,7 @@ test_check_rsa2048_b58mh_peerid() {
465
466 test_check_ed25519_b58mh_peerid() {
467 peeridlen=$(echo "$1" | tr -dC "[:alnum:]" | wc -c | tr -d " ") &&
468 - test "$peeridlen" = "46" || {
468 + test "$peeridlen" = "52" || {
469 echo "Bad ED25519 B58MH peerid '$1' with len '$peeridlen'"
470 return 1
471 }
test/sharness/t0165-keystore.sh
+24 -14
@@ -12,9 +12,12 @@ test_init_ipfs
12
13 test_key_cmd() {
14 # test key output format
15 -test_expect_success "create an RSA key and test B58MH multihash output" '
15 +test_expect_success "create an RSA key and test B58MH/B36CID output formats" '
16 PEERID=$(ipfs key gen -f=b58mh --type=rsa --size=2048 key_rsa) &&
17 -test_check_rsa2048_b58mh_peerid $PEERID
17 +test_check_rsa2048_b58mh_peerid $PEERID &&
18 +ipfs key rm key_rsa &&
19 +PEERID=$(ipfs key gen -f=b36cid --type=rsa --size=2048 key_rsa) &&
20 +test_check_rsa2048_b36cid_peerid $PEERID
21 '
22
23 test_expect_success "test RSA key sk export format" '
@@ -23,13 +26,18 @@ test_check_rsa2048_sk key_rsa.key &&
26 rm key_rsa.key
27 '
28
26 -test_expect_success "test RSA key B36CID multihash format" '
29 +test_expect_success "test RSA key B58MH/B36CID multihash format" '
30 +PEERID=$(ipfs key list -f=b58mh -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
31 +test_check_rsa2048_b58mh_peerid $PEERID &&
32 PEERID=$(ipfs key list -f=b36cid -l | grep key_rsa | head -n 1 | cut -d " " -f1) &&
33 test_check_rsa2048_b36cid_peerid $PEERID &&
34 ipfs key rm key_rsa
35 '
36
32 -test_expect_success "create an ED25519 key and test multihash output" '
37 +test_expect_success "create an ED25519 key and test B58MH/B36CID output formats" '
38 +PEERID=$(ipfs key gen -f=b58mh --type=ed25519 key_ed25519) &&
39 +test_check_ed25519_b58mh_peerid $PEERID &&
40 +ipfs key rm key_ed25519 &&
41 PEERID=$(ipfs key gen -f=b36cid --type=ed25519 key_ed25519) &&
42 test_check_ed25519_b36cid_peerid $PEERID
43 '
@@ -40,7 +48,9 @@ test_check_ed25519_sk key_ed25519.key &&
48 rm key_ed25519.key
49 '
50
43 -test_expect_success "test ED25519 key B36CID multihash format" '
51 +test_expect_success "test ED25519 key B58MH/B36CID multihash format" '
52 +PEERID=$(ipfs key list -f=b58mh -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
53 +test_check_ed25519_b58mh_peerid $PEERID &&
54 PEERID=$(ipfs key list -f=b36cid -l | grep key_ed25519 | head -n 1 | cut -d " " -f1) &&
55 test_check_ed25519_b36cid_peerid $PEERID &&
56 ipfs key rm key_ed25519
@@ -49,12 +59,12 @@ ipfs key rm key_ed25519
59
60
61 test_expect_success "create a new rsa key" '
52 - rsahash=$(ipfs key gen -f=b58mh generated_rsa_key --type=rsa --size=2048)
62 + rsahash=$(ipfs key gen generated_rsa_key --type=rsa --size=2048)
63 echo $rsahash > rsa_key_id
64 '
65
66 test_expect_success "create a new ed25519 key" '
57 - edhash=$(ipfs key gen -f=b58mh generated_ed25519_key --type=ed25519)
67 + edhash=$(ipfs key gen generated_ed25519_key --type=ed25519)
68 echo $edhash > ed25519_key_id
69 '
70
@@ -104,18 +114,18 @@ ipfs key rm key_ed25519
114 echo generated_rsa_key >> list_exp &&
115 echo quxel >> list_exp &&
116 echo self >> list_exp
107 - ipfs key list -f=b58mh > list_out &&
117 + ipfs key list > list_out &&
118 test_sort_cmp list_exp list_out
119 '
120
121 test_expect_success "key hashes show up in long list output" '
112 - ipfs key list -f=b58mh -l | grep $edhash > /dev/null &&
113 - ipfs key list -f=b58mh -l | grep $rsahash > /dev/null
122 + ipfs key list -l | grep $edhash > /dev/null &&
123 + ipfs key list -l | grep $rsahash > /dev/null
124 '
125
126 test_expect_success "key list -l contains self key with peerID" '
127 PeerID="$(ipfs config Identity.PeerID)"
118 - ipfs key list -f=b58mh -l | grep "$PeerID\s\+self"
128 + ipfs key list -l | grep "$PeerID\s\+self"
129 '
130
131 test_expect_success "key rm remove a key" '
@@ -123,7 +133,7 @@ ipfs key rm key_ed25519
133 echo generated_ed25519_key > list_exp &&
134 echo quxel >> list_exp &&
135 echo self >> list_exp
126 - ipfs key list -f=b58mh > list_out &&
136 + ipfs key list > list_out &&
137 test_sort_cmp list_exp list_out
138 '
139
@@ -137,12 +147,12 @@ ipfs key rm key_ed25519
147 echo fooed > list_exp &&
148 echo quxel >> list_exp &&
149 echo self >> list_exp
140 - ipfs key list -f=b58mh > list_out &&
150 + ipfs key list > list_out &&
151 test_sort_cmp list_exp list_out
152 '
153
154 test_expect_success "key rename rename key output succeeds" '
145 - key_content=$(ipfs key gen -f=b58mh key1 --type=rsa --size=2048) &&
155 + key_content=$(ipfs key gen key1 --type=rsa --size=2048) &&
156 ipfs key rename key1 key2 >rs &&
157 echo "Key $key_content renamed to key2" >expect &&
158 test_cmp rs expect