t0165-keystore.sh 965 Bytes
Newer Older
Jeromy's avatar
Jeromy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#!/bin/sh
#
# Copyright (c) 2017 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test keystore commands"

. lib/test-lib.sh

test_init_ipfs

test_key_cmd() {
	test_expect_success "create a new rsa key" '
		rsahash=$(ipfs key gen foobarsa --type=rsa --size=2048)
	'

	test_expect_success "create a new ed25519 key" '
		edhash=$(ipfs key gen bazed --type=ed25519)
	'

	test_expect_success "both keys show up in list output" '
		echo bazed > list_exp &&
		echo foobarsa >> list_exp &&
25
		echo self >> list_exp
Jeromy's avatar
Jeromy committed
26 27 28 29 30 31 32 33
		ipfs key list | sort > list_out &&
		test_cmp list_exp list_out
	'

	test_expect_success "key hashes show up in long list output" '
		ipfs key list -l | grep $edhash > /dev/null &&
		ipfs key list -l | grep $rsahash > /dev/null
	'
34 35

	test_expect_success "key list -l contains self key with peerID" '
36 37
		PeerID="$(ipfs config Identity.PeerID)"
		ipfs key list -l | grep "$PeerID self"
38
	'
Jeromy's avatar
Jeromy committed
39 40 41 42 43
}

test_key_cmd

test_done