Skip to content

Commit

Permalink
Add sharness test for read blockstore rehashing
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
  • Loading branch information
Kubuxu committed Jun 26, 2016
1 parent 174ab12 commit e7f4f69
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/sharness/t0084-repo-read-rehash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
#
# Copyright (c) 2016 Mike Pfister
# 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

0 comments on commit e7f4f69

Please sign in to comment.