ligo/test/test-basic.sh

80 lines
1.9 KiB
Bash
Raw Normal View History

2016-09-08 21:13:10 +04:00
#! /bin/sh
set -e
DIR=$(dirname "$0")
cd "${DIR}"
2017-01-23 14:10:07 +04:00
DATA_DIR="$(mktemp -td tezos_node.XXXXXXXXXX)"
CLIENT_DIR="$(mktemp -td tezos_client.XXXXXXXXXX)"
2016-09-08 21:13:10 +04:00
cleanup() {
rm -fr ${DATA_DIR} ${CLIENT_DIR}
[ -z "${NODE_PID}" ] || kill -9 ${NODE_PID}
}
trap cleanup EXIT QUIT INT
NODE=../tezos-node
CLIENT="../tezos-client -base-dir ${CLIENT_DIR}"
2017-01-23 14:10:07 +04:00
CUSTOM_PARAM="--sandbox ./sandbox.json"
${NODE} run --data-dir "${DATA_DIR}" ${CUSTOM_PARAM} --rpc-addr "[::]:8732" > LOG 2>&1 &
2016-09-08 21:13:10 +04:00
NODE_PID="$!"
sleep 3
${CLIENT} list versions
${CLIENT} bootstrap
KEY1=foo
KEY2=bar
${CLIENT} gen keys ${KEY1}
${CLIENT} gen keys ${KEY2}
${CLIENT} list known identities
${CLIENT} transfer 1000 from bootstrap1 to ${KEY1}
${CLIENT} transfer 2000 from bootstrap1 to ${KEY2}
assert() {
local expected="$1"
local result="$(cat)"
if [ "${result}" != "${expected}" ]; then
echo "Unexpected result: \"${result}\""
echo "Expected: \"${expected}\""
exit 2
fi
}
${CLIENT} get balance ${KEY1} | assert "1,000.00 ꜩ"
${CLIENT} get balance ${KEY2} | assert "2,000.00 ꜩ"
${CLIENT} transfer 1000 from ${KEY2} to ${KEY1}
${CLIENT} get balance ${KEY1} | assert "2,000.00 ꜩ"
${CLIENT} get balance ${KEY2} | assert "999.95 ꜩ"
# Should fail
# ${CLIENT} transfer 999.95 from ${KEY2} to ${KEY1}
${CLIENT} mine for bootstrap1
${CLIENT} remember program noop file:scripts/noop.tez
${CLIENT} typecheck program noop
${CLIENT} originate contract noop \
for ${KEY1} transfering 1000 from bootstrap1 \
running noop
2017-01-11 19:15:38 +04:00
${CLIENT} transfer 10 from bootstrap1 to noop -arg "Unit"
2016-09-08 21:13:10 +04:00
${CLIENT} originate contract hardlimit \
for ${KEY1} transfering 1000 from bootstrap1 \
running file:scripts/hardlimit.tez -init "3"
2017-01-11 19:15:38 +04:00
${CLIENT} transfer 10 from bootstrap1 to hardlimit -arg "Unit"
${CLIENT} transfer 10 from bootstrap1 to hardlimit -arg "Unit"
# ${CLIENT} transfer 10 from bootstrap1 to hardlimit -arg "unit" # should fail
2016-09-08 21:13:10 +04:00
echo
echo End of test
echo