serval-dna/tests/meshmb
2017-04-19 14:46:36 +09:30

101 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
source "${0%/*}/../testframework.sh"
source "${0%/*}/../testdefs.sh"
source "${0%/*}/../testdefs_rhizome.sh"
rexp_age='[0-9]*'
setup_identities() {
setup_servald
set_instance +A
executeOk_servald config \
set debug.meshmb on \
set log.console.level debug \
set log.console.show_time on
create_identities $1
}
teardown() {
stop_all_servald_servers
kill_all_servald_processes
assert_no_servald_processes
report_all_servald_servers
}
doc_meshmbSend="Send broadcast meshmb message"
setup_meshmbSend() {
setup_identities 1
}
test_meshmbSend() {
executeOk_servald meshmb send $IDA1 "Message 1"
tfw_cat --stdout --stderr
executeOk_servald rhizome export bundle $IDA1 broadcast.manifest broadcast
tfw_cat -h broadcast.manifest
tfw_cat -h broadcast
executeOk_servald meshmb send $IDA1 "Message 2"
tfw_cat --stdout --stderr
executeOk_servald rhizome export bundle $IDA1 broadcast2.manifest broadcast2
tfw_cat -h broadcast2.manifest
tfw_cat -h broadcast2
}
doc_meshmbRead="Read meshmb messages"
setup_meshmbRead() {
setup_identities 1
executeOk_servald meshmb send $IDA1 "Message 1"
executeOk_servald meshmb send $IDA1 "Message 2"
}
test_meshmbRead() {
executeOk_servald meshmb read $IDA1
assertStdoutGrep --matches=1 "^_id:offset:age:message$"
assertStdoutGrep --matches=1 "^0:30:${rexp_age}:Message 2$"
assertStdoutGrep --matches=1 "^1:12:${rexp_age}:Message 1$"
assertStdoutLineCount '==' 4
}
doc_meshmbListFeeds="List meshmb feeds"
setup_meshmbListFeeds() {
setup_identities 3
executeOk_servald meshmb send $IDA1 "Message 1"
executeOk_servald meshmb send $IDA2 "Message 2"
executeOk_servald meshmb send $IDA3 "Message 3"
}
test_meshmbListFeeds() {
executeOk_servald meshmb find
tfw_cat --stdout
assertStdoutGrep --matches=1 "^_id:id:version:date:name$"
assertStdoutGrep --matches=1 ":${IDA1}:"
assertStdoutGrep --matches=1 ":${IDA2}:"
assertStdoutGrep --matches=1 ":${IDA3}:"
assertStdoutLineCount '==' 5
}
doc_meshmbFollow="Follow another feed"
setup_meshmbFollow() {
setup_identities 3
executeOk_servald keyring set did $SIDA1 "" "Feed A"
executeOk_servald keyring set did $SIDA2 "" "Feed B"
executeOk_servald keyring set did $SIDA3 "" "Feed C"
executeOk_servald meshmb send $IDA1 "Message 1"
executeOk_servald meshmb send $IDA2 "Message 2"
executeOk_servald meshmb send $IDA3 "Message 3"
}
test_meshmbFollow() {
executeOk_servald meshmb follow $IDA1 $IDA2
executeOk_servald meshmb list following $IDA1
assertStdoutGrep --matches=1 ":$IDA2:Feed B:[0-9]\+:Message 2\$"
assertStdoutGrep --matches=0 ":$IDA3:Feed C:[0-9]\+:Message 3\$"
executeOk_servald meshmb follow $IDA1 $IDA3
executeOk_servald meshmb list following $IDA1
assertStdoutGrep --matches=1 ":$IDA2:Feed B:[0-9]\+:Message 2\$"
assertStdoutGrep --matches=1 ":$IDA3:Feed C:[0-9]\+:Message 3\$"
executeOk_servald meshmb ignore $IDA1 $IDA2
executeOk_servald meshmb list following $IDA1
assertStdoutGrep --matches=0 ":$IDA2:Feed B:[0-9]\+:Message 2\$"
assertStdoutGrep --matches=1 ":$IDA3:Feed C:[0-9]\+:Message 3\$"
}
runTests "$@"