| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2021 Mohsin Zaidi |
| 4 | # MIT Licensed; see the LICENSE file in this repository. |
| 5 | # |
| 6 | |
| 7 | test_description="Test dag-jose plugin" |
| 8 | |
| 9 | . lib/test-lib.sh |
| 10 | |
| 11 | test_init_ipfs |
| 12 | |
| 13 | test_dag_jose() { |
| 14 | test_expect_success "encode as dag-jose, decode back to original, verify round-trip" $' |
| 15 | find ../t0280-plugin-dag-jose-data -type f | xargs -I {} sh -c \' \ |
| 16 | codec=$(basename $(dirname {})); \ |
| 17 | joseHash=$(ipfs dag put --store-codec dag-jose --input-codec=$codec {}); \ |
| 18 | ipfs dag get --output-codec $codec $joseHash > $(basename {}); \ |
| 19 | diff {} $(basename {}) \' |
| 20 | ' |
| 21 | |
| 22 | test_expect_success "retrieve dag-jose in non-dag-jose encodings" $' |
| 23 | find ../t0280-plugin-dag-jose-data -type f | xargs -I {} sh -c \' \ |
| 24 | codec=$(basename $(dirname {})); \ |
| 25 | joseHash=$(ipfs dag put --store-codec dag-jose --input-codec=$codec {}); \ |
| 26 | ipfs dag get --output-codec dag-cbor $joseHash > /dev/null; \ |
| 27 | ipfs dag get --output-codec dag-json $joseHash > /dev/null \' |
| 28 | ' |
| 29 | } |
| 30 | |
| 31 | # should work offline |
| 32 | test_dag_jose |
| 33 | |
| 34 | # should work online |
| 35 | test_launch_ipfs_daemon |
| 36 | test_dag_jose |
| 37 | test_kill_ipfs_daemon |
| 38 | |
| 39 | test_done |