Skip to content

Commit

Permalink
fix(sharness): t0250: disambiguate online/offline
Browse files Browse the repository at this point in the history
  • Loading branch information
schomatis committed Jul 8, 2021
1 parent ae30699 commit 61f58c2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
5 changes: 5 additions & 0 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ test_launch_ipfs_daemon() {
'
}

test_launch_ipfs_daemon_without_network() {
test_launch_ipfs_daemon --offline "$@"
# FIXME: Check if this is the right way to concatenate arguments.
}

do_umount() {
if [ "$(uname -s)" = "Linux" ]; then
fusermount -u "$1"
Expand Down
30 changes: 19 additions & 11 deletions test/sharness/t0250-files-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,12 @@ test_files_api() {
echo "testing" | ipfs files write $ARGS $RAW_LEAVES -f=false -e /cats/walrus
'

# Skip this test if the commands are not being run through the daemon
# ($WITH_DAEMON not set) as standalone commands will *always* flush
# after being done and the 'no-flush' call from the previous test will
# not be enforced.
test_expect_success "root hash not bubbled up yet $EXTRA" '
test -z "$ONLINE" ||
test -z "$WITH_DAEMON" ||
(ipfs refs local > refsout &&
test_expect_code 1 grep $ROOT_HASH refsout)
'
Expand Down Expand Up @@ -693,8 +697,10 @@ test_files_api() {
'
}

# test offline and online

# test with and without the daemon (EXTRA="with-daemon" and EXTRA="no-daemon"
# respectively).
# FIXME: Check if we are correctly using the "no-daemon" flag in these test
# combinations.
tests_for_files_api() {
local EXTRA
EXTRA=$1
Expand All @@ -712,7 +718,7 @@ tests_for_files_api() {
create_files --raw-leaves
'

if [ "$EXTRA" = "offline" ]; then
if [ "$EXTRA" = "with-daemon" ]; then
ROOT_HASH=QmTpKiKcAj4sbeesN6vrs5w3QeVmd4QmGpxRL81hHut4dZ
CATS_HASH=QmPhPkmtUGGi8ySPHoPu1qbfryLJKKq1GYxpgLyyCruvGe
test_files_api "($EXTRA, partial raw-leaves)"
Expand All @@ -728,7 +734,7 @@ tests_for_files_api() {
CATS_HASH=bafybeig4cpvfu2qwwo3u4ffazhqdhyynfhnxqkzvbhrdbamauthf5mfpuq
FILE_HASH=bafybeibkrazpbejqh3qun7xfnsl7yofl74o4jwhxebpmtrcpavebokuqtm
TRUNC_HASH=bafybeigwhb3q36yrm37jv5fo2ap6r6eyohckqrxmlejrenex4xlnuxiy3e
if [ "$EXTRA" = "offline" ]; then
if [ "$EXTRA" = "with-daemon" ]; then
test_files_api "($EXTRA, cidv1)" --cid-version=1
fi

Expand All @@ -742,7 +748,7 @@ tests_for_files_api() {
ROOT_HASH=bafybeifxnoetaa2jetwmxubv3gqiyaknnujwkkkhdeua63kulm63dcr5wu
test_files_api "($EXTRA, cidv1 root)"

if [ "$EXTRA" = "offline" ]; then
if [ "$EXTRA" = "with-daemon" ]; then
test_expect_success "can update root hash to blake2b-256" '
ipfs files chcid --hash=blake2b-256 / &&
echo bafykbzacebugfutjir6qie7apo5shpry32ruwfi762uytd5g3u2gk7tpscndq > hash_expect &&
Expand All @@ -764,15 +770,17 @@ tests_for_files_api() {
'
}

tests_for_files_api "online"
tests_for_files_api "no-daemon"

test_launch_ipfs_daemon --offline
test_launch_ipfs_daemon_without_network

ONLINE=1 # set online flag so tests can easily tell
WITH_DAEMON=1
# FIXME: Used only on a specific test inside `test_files_api` but we should instead
# propagate the `"with-daemon"` argument in its caller `tests_for_files_api`.

tests_for_files_api "offline"
tests_for_files_api "with-daemon"

test_kill_ipfs_daemon --offline
test_kill_ipfs_daemon

test_expect_success "enable sharding in config" '
ipfs config --json Experimental.ShardingEnabled true
Expand Down

0 comments on commit 61f58c2

Please sign in to comment.