@cryptotaxi247 / kubo / commits / 61f58c21c

fix(sharness): t0250: disambiguate online/offline

Lucas Molas committed Jul 8, 2021 at 13:47 UTC 61f58c21c4dd84f3e672c936766e60dadf11c25a
2 files changed +24 -11
test/sharness/lib/test-lib.sh
+5
@@ -280,6 +280,11 @@ test_launch_ipfs_daemon() {
280 '
281 }
282
283 +test_launch_ipfs_daemon_without_network() {
284 + test_launch_ipfs_daemon --offline "$@"
285 + # FIXME: Check if this is the right way to concatenate arguments.
286 +}
287 +
288 do_umount() {
289 if [ "$(uname -s)" = "Linux" ]; then
290 fusermount -u "$1"
test/sharness/t0250-files-api.sh
+19 -11
@@ -498,8 +498,12 @@ test_files_api() {
498 echo "testing" | ipfs files write $ARGS $RAW_LEAVES -f=false -e /cats/walrus
499 '
500
501 + # Skip this test if the commands are not being run through the daemon
502 + # ($WITH_DAEMON not set) as standalone commands will *always* flush
503 + # after being done and the 'no-flush' call from the previous test will
504 + # not be enforced.
505 test_expect_success "root hash not bubbled up yet $EXTRA" '
502 - test -z "$ONLINE" ||
506 + test -z "$WITH_DAEMON" ||
507 (ipfs refs local > refsout &&
508 test_expect_code 1 grep $ROOT_HASH refsout)
509 '
@@ -693,8 +697,10 @@ test_files_api() {
697 '
698 }
699
696 -# test offline and online
697 -
700 +# test with and without the daemon (EXTRA="with-daemon" and EXTRA="no-daemon"
701 +# respectively).
702 +# FIXME: Check if we are correctly using the "no-daemon" flag in these test
703 +# combinations.
704 tests_for_files_api() {
705 local EXTRA
706 EXTRA=$1
@@ -712,7 +718,7 @@ tests_for_files_api() {
718 create_files --raw-leaves
719 '
720
715 - if [ "$EXTRA" = "offline" ]; then
721 + if [ "$EXTRA" = "with-daemon" ]; then
722 ROOT_HASH=QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
723 CATS_HASH=QmPhPkmtUGGi8ySPHoPu1qbfryLJKKq1GYxpgLyyCruvGe
724 test_files_api "($EXTRA, partial raw-leaves)"
@@ -728,7 +734,7 @@ tests_for_files_api() {
734 CATS_HASH=bafybeig4cpvfu2qwwo3u4ffazhqdhyynfhnxqkzvbhrdbamauthf5mfpuq
735 FILE_HASH=bafybeibkrazpbejqh3qun7xfnsl7yofl74o4jwhxebpmtrcpavebokuqtm
736 TRUNC_HASH=bafybeigwhb3q36yrm37jv5fo2ap6r6eyohckqrxmlejrenex4xlnuxiy3e
731 - if [ "$EXTRA" = "offline" ]; then
737 + if [ "$EXTRA" = "with-daemon" ]; then
738 test_files_api "($EXTRA, cidv1)" --cid-version=1
739 fi
740
@@ -742,7 +748,7 @@ tests_for_files_api() {
748 ROOT_HASH=bafybeifxnoetaa2jetwmxubv3gqiyaknnujwkkkhdeua63kulm63dcr5wu
749 test_files_api "($EXTRA, cidv1 root)"
750
745 - if [ "$EXTRA" = "offline" ]; then
751 + if [ "$EXTRA" = "with-daemon" ]; then
752 test_expect_success "can update root hash to blake2b-256" '
753 ipfs files chcid --hash=blake2b-256 / &&
754 echo bafykbzacebugfutjir6qie7apo5shpry32ruwfi762uytd5g3u2gk7tpscndq > hash_expect &&
@@ -764,15 +770,17 @@ tests_for_files_api() {
770 '
771 }
772
767 -tests_for_files_api "online"
773 +tests_for_files_api "no-daemon"
774
769 -test_launch_ipfs_daemon --offline
775 +test_launch_ipfs_daemon_without_network
776
771 -ONLINE=1 # set online flag so tests can easily tell
777 +WITH_DAEMON=1
778 +# FIXME: Used only on a specific test inside `test_files_api` but we should instead
779 +# propagate the `"with-daemon"` argument in its caller `tests_for_files_api`.
780
773 -tests_for_files_api "offline"
781 +tests_for_files_api "with-daemon"
782
775 -test_kill_ipfs_daemon --offline
783 +test_kill_ipfs_daemon
784
785 test_expect_success "enable sharding in config" '
786 ipfs config --json Experimental.ShardingEnabled true