2016-09-08 21:13:10 +04:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
DIR=$(dirname "$0")
|
|
|
|
cd "${DIR}"
|
|
|
|
|
2017-04-12 14:55:01 +04:00
|
|
|
DATA_DIR="$(mktemp -d -t tezos_node.XXXXXXXXXX)"
|
|
|
|
CLIENT_DIR="$(mktemp -d -t tezos_client.XXXXXXXXXX)"
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
cleanup() {
|
2017-03-31 19:09:11 +04:00
|
|
|
[ -z "${NODE_PID}" ] || kill -9 ${NODE_PID} || true
|
|
|
|
echo
|
|
|
|
echo "Node's log:"
|
|
|
|
echo
|
|
|
|
cat $DATA_DIR/LOG
|
2016-09-08 21:13:10 +04:00
|
|
|
rm -fr ${DATA_DIR} ${CLIENT_DIR}
|
|
|
|
}
|
|
|
|
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"
|
2017-03-31 19:09:11 +04:00
|
|
|
${NODE} run --data-dir "${DATA_DIR}" ${CUSTOM_PARAM} --rpc-addr "[::]:8732" > "$DATA_DIR"/LOG 2>&1 &
|
2016-09-08 21:13:10 +04:00
|
|
|
NODE_PID="$!"
|
|
|
|
|
2017-03-31 19:09:11 +04:00
|
|
|
echo "Created node, pid: ${NODE_PID}, log: $DATA_DIR/LOG"
|
2017-03-31 12:33:29 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
sleep 3
|
|
|
|
|
2016-10-20 20:54:16 +04:00
|
|
|
${CLIENT} -block genesis list versions
|
|
|
|
|
|
|
|
${CLIENT} -block genesis \
|
|
|
|
activate \
|
|
|
|
protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK \
|
|
|
|
with fitness 1 \
|
|
|
|
and key edskRhxswacLW6jF6ULavDdzwqnKJVS4UcDTNiCyiH6H8ZNnn2pmNviL7pRNz9kRxxaWQFzEQEcZExGHKbwmuaAcoMegj5T99z
|
2017-02-25 21:10:29 +04:00
|
|
|
|
2017-02-28 05:56:40 +04:00
|
|
|
${CLIENT} add identity bootstrap1 tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx
|
|
|
|
${CLIENT} add public key bootstrap1 edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav
|
|
|
|
${CLIENT} add secret key bootstrap1 edskRuR1azSfboG86YPTyxrQgosh5zChf5bVDmptqLTb5EuXAm9rsnDYfTKhq7rDQujdn5WWzwUMeV3agaZ6J2vPQT58jJAJPi
|
|
|
|
${CLIENT} add identity bootstrap2 tz1gjaF81ZRRvdzjobyfVNsAeSC6PScjfQwN
|
|
|
|
${CLIENT} add identity bootstrap3 tz1faswCTDciRzE4oJ9jn2Vm2dvjeyA9fUzU
|
|
|
|
${CLIENT} add identity bootstrap4 tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv
|
|
|
|
${CLIENT} add identity bootstrap5 tz1ddb9NMYHZi5UzPdzTZMYQQZoMub195zgv
|
|
|
|
|
2017-03-03 20:02:54 +04:00
|
|
|
sleep 2
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2017-05-19 07:14:14 +04:00
|
|
|
${CLIENT} get balance for ${KEY1} | assert "1,000.00 ꜩ"
|
|
|
|
${CLIENT} get balance for ${KEY2} | assert "2,000.00 ꜩ"
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
${CLIENT} transfer 1000 from ${KEY2} to ${KEY1}
|
|
|
|
|
2017-05-19 07:14:14 +04:00
|
|
|
${CLIENT} get balance for ${KEY1} | assert "2,000.00 ꜩ"
|
|
|
|
${CLIENT} get balance for ${KEY2} | assert "999.95 ꜩ"
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
# 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 \
|
2017-05-07 07:53:09 +04:00
|
|
|
for ${KEY1} transferring 1000 from bootstrap1 \
|
2016-09-08 21:13:10 +04:00
|
|
|
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 \
|
2017-05-07 07:53:09 +04:00
|
|
|
for ${KEY1} transferring 1000 from bootstrap1 \
|
2016-09-08 21:13:10 +04:00
|
|
|
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
|
|
|
|
2017-05-19 07:14:14 +04:00
|
|
|
${CLIENT} originate free account free_account for ${KEY1}
|
|
|
|
${CLIENT} get delegate for free_account
|
|
|
|
${CLIENT} set delegate for free_account to ${KEY2}
|
|
|
|
${CLIENT} get delegate for free_account
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
echo
|
|
|
|
echo End of test
|
|
|
|
echo
|