Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
a few more view-state test
Browse files Browse the repository at this point in the history
  • Loading branch information
ailisp authored and Mike Purvis committed Jun 28, 2021
1 parent 4129d3b commit 54261db
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test_account_operations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,39 @@ if [[ ! "$RESULT" == $EXPECTED ]]; then
exit 1
fi

bin/near state $testaccount > ${testaccount}.json
BLOCK_HEIGHT=$(grep block_height ${testaccount}.json | grep -o '[[:digit:]]\+')
BLOCK_HASH=$(grep block_hash ${testaccount}.json | grep -o "[[:alnum:]]\{10,\}")

echo Get account storage --blockId $BLOCK_HEIGHT
RESULT=$(./bin/near view-state $testaccount --blockId $BLOCK_HEIGHT)
EXPECTED="[]"
if [[ ! "$RESULT" == $EXPECTED ]]; then
echo FAILURE Unexpected output from near view-state
exit 1
fi

echo Get account storage --blockId $BLOCK_HASH
RESULT=$(./bin/near view-state $testaccount --blockId $BLOCK_HASH)
EXPECTED="[]"
if [[ ! "$RESULT" == $EXPECTED ]]; then
echo FAILURE Unexpected output from near view-state
exit 1
fi

echo Get account storage --blockId $BLOCK_HASH --finality optimistic should fail
EXPECTED="Only one of --finality and --blockId can be provided"
set +e
./bin/near view-state $testaccount --blockId $BLOCK_HASH --finality optimistic 2> ${testaccount}.stderr
if [[ ! $? == 1 ]]; then
echo view-state should fail given both blockId and finality
exit 1
fi
if [[ ! $(cat ${testaccount}.stderr) == $EXPECTED ]]; then
echo FAILURE Unexpected output from near view-state
exit 1
fi
set -e


./bin/near delete $testaccount test.near

0 comments on commit 54261db

Please sign in to comment.