| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2014 Jeromy Johnson |
| 4 | # MIT Licensed; see the LICENSE file in this repository. |
| 5 | # |
| 6 | |
| 7 | test_description="Test ipfs repo operations" |
| 8 | |
| 9 | . lib/test-lib.sh |
| 10 | |
| 11 | num_nodes=4 |
| 12 | |
| 13 | test_expect_success "set up an iptb cluster" ' |
| 14 | iptb testbed create -type localipfs -count $num_nodes -force -init |
| 15 | ' |
| 16 | |
| 17 | startup_cluster $num_nodes |
| 18 | |
| 19 | test_expect_success "add an object on one node" ' |
| 20 | echo "ipns is super fun" > file && |
| 21 | HASH_FILE=$(ipfsi 1 add -q file) |
| 22 | ' |
| 23 | |
| 24 | test_expect_success "publish that object as an ipns entry" ' |
| 25 | ipfsi 1 name publish $HASH_FILE |
| 26 | ' |
| 27 | |
| 28 | test_expect_success "add an entry on another node pointing to that one" ' |
| 29 | NODE1_ID=$(iptb attr get 1 id) && |
| 30 | ipfsi 2 name publish /ipns/$NODE1_ID |
| 31 | ' |
| 32 | |
| 33 | test_expect_success "cat that entry on a third node" ' |
| 34 | NODE2_ID=$(iptb attr get 2 id) && |
| 35 | ipfsi 3 cat /ipns/$NODE2_ID > output |
| 36 | ' |
| 37 | |
| 38 | test_expect_success "ensure output was the same" ' |
| 39 | test_cmp file output |
| 40 | ' |
| 41 | |
| 42 | test_expect_success "shut down iptb" ' |
| 43 | iptb stop |
| 44 | ' |
| 45 | |
| 46 | test_done |