-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sharness test for read blockstore rehashing
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) Jakub Sztandera | ||
# MIT Licensed; see the LICENSE file in this repository. | ||
# | ||
|
||
test_description="Test ipfs blockstore repo read check." | ||
|
||
. lib/test-lib.sh | ||
|
||
rm -rf "$IPF_PATH/*" | ||
|
||
test_init_ipfs | ||
|
||
|
||
H_BLOCK1=$(echo "Block 1" | ipfs add -q) | ||
H_BLOCK2=$(echo "Block 2" | ipfs add -q) | ||
|
||
BS_BLOCK1="1220f18e/1220f18e07ebc69997909358f28b9d2c327eb032b0afab6bbc7fd7f399a7b7590be4.data" | ||
BS_BLOCK2="1220dc58/1220dc582e51f1f98b1f2d1c1baaa9f7b11602239ed42fbdf8f52d67e63cc03df12a.data" | ||
|
||
|
||
test_expect_success 'blocks are swapped' ' | ||
ipfs cat $H_BLOCK2 > noswap && | ||
cp -f "$IPFS_PATH/blocks/$BS_BLOCK1" "$IPFS_PATH/blocks/$BS_BLOCK2" && | ||
ipfs cat $H_BLOCK2 > swap && | ||
test_must_fail test_cmp noswap swap | ||
' | ||
|
||
ipfs config --bool Datastore.HashOnRead true | ||
|
||
test_expect_success 'getting modified block fails' ' | ||
(test_must_fail ipfs cat $H_BLOCK2 2> err_msg) && | ||
grep "block in storage has different hash than requested" err_msg | ||
' | ||
|
||
test_done |