| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # Copyright (c) 2017 Jakub Sztandera |
| 4 | # MIT Licensed; see the LICENSE file in this repository. |
| 5 | # |
| 6 | |
| 7 | test_description="Test peerlog plugin" |
| 8 | |
| 9 | . lib/test-lib.sh |
| 10 | |
| 11 | test_expect_success "setup testbed" ' |
| 12 | iptb testbed create -type localipfs -count 2 -force -init |
| 13 | ' |
| 14 | |
| 15 | startup_cluster 2 |
| 16 | |
| 17 | test_expect_success "peerlog is disabled by default" ' |
| 18 | go-sleep 100ms |
| 19 | iptb logs 0 >node0logs |
| 20 | test_expect_code 1 grep peerlog node0logs |
| 21 | ' |
| 22 | |
| 23 | test_expect_success 'stop iptb' 'iptb stop' |
| 24 | |
| 25 | |
| 26 | |
| 27 | test_expect_success "setup testbed" ' |
| 28 | iptb testbed create -type localipfs -count 2 -force -init |
| 29 | ' |
| 30 | |
| 31 | test_expect_success "enable peerlog config setting" ' |
| 32 | iptb run -- ipfs config --json Plugins.Plugins.peerlog.Config.Enabled true |
| 33 | ' |
| 34 | |
| 35 | startup_cluster 2 |
| 36 | |
| 37 | test_expect_success "peerlog plugin is logged" ' |
| 38 | go-sleep 100ms |
| 39 | iptb logs 0 >node0logs |
| 40 | grep peerlog node0logs |
| 41 | ' |
| 42 | |
| 43 | test_expect_success 'peer id' ' |
| 44 | PEERID_1=$(iptb attr get 1 id) |
| 45 | ' |
| 46 | |
| 47 | test_expect_success "peer id is logged" ' |
| 48 | iptb logs 0 | grep -q "$PEERID_1" |
| 49 | ' |
| 50 | |
| 51 | test_expect_success 'stop iptb' 'iptb stop' |
| 52 | |
| 53 | test_done |