diff --git a/.travis.yml b/.travis.yml index 84532dd9c59bdd0c0d333703e1cf6012100bba7e..c98addb56656ea6d8b5b8f0472d6a4d8ed9208fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,7 +75,7 @@ script: - mkdir build && cd build - ${CMAKE_DIR}cmake -G Ninja -DWASM_LLVM_CONFIG=$TRAVIS_BUILD_DIR/ext/wasm-compiler/bin/llvm-config -DSecp256k1_ROOT_DIR=$TRAVIS_BUILD_DIR/ext -DBINARYEN_ROOT=$TRAVIS_BUILD_DIR/ext/wasm-compiler -DCMAKE_PREFIX_PATH=$TRAVIS_BUILD_DIR/ext -DCMAKE_BUILD_TYPE=Release $EOS_CMAKE_OPTIONS .. - ninja -j4 - - tests/eosd_run_test.sh + - tests/eosd_run_test.sh --host=localhost --port=8888 - '[ "$TRAVIS_OS_NAME" == "osx" ] || tests/chain_test' - '[ "$TRAVIS_OS_NAME" == "osx" ] || tests/slow_test' - tests/api_test diff --git a/tests/eosd_run_test.sh b/tests/eosd_run_test.sh index 41a1d24b2f72aa37feea9fa4a5be880913589fad..6eb68774519c2195a626b062a6c029779966741c 100755 --- a/tests/eosd_run_test.sh +++ b/tests/eosd_run_test.sh @@ -3,6 +3,36 @@ # prevent bc from adding \ at end of large hex values export BC_LINE_LENGTH=9999 +TEST_OUTPUT="test_output_0.txt" + +if [ $# -lt 2 ]; then + echo "usage: eosd_run_test.sh --host=host_name --port=port --output=test_output_0.txt" + echo " If --host==localhost then this script also launches an eosd for the test." + echo " Example: eosd_run_test_sh --host=localhost --port=8888 --output=test_output_0.txt" + exit 1 +fi + +for i in "$@" +do +case $i in + -o*|--output=*) + TEST_OUTPUT="${i#*=}" + shift + ;; + -h*|--host=*) + SERVER="${i#*=}" + shift + ;; + -p*|--port=*) + PORT="${i#*=}" + shift + ;; + *) + ;; +esac +done + + # $1 - error message error() { @@ -17,6 +47,8 @@ error() echo ================================================================= echo Contents of test_walletd_output.log: cat test_walletd_output.log + echo ================================================================= + echo == Errors see above == exit 1 } @@ -30,7 +62,9 @@ verifyErrorCode() killAll() { - programs/launcher/launcher -k 9 + if [ "$SERVER" == "localhost" ]; then + programs/launcher/launcher -k 9 + fi kill -9 $WALLETD_PROC_ID } @@ -53,7 +87,7 @@ getTransactionId() # result stored in HEAD_BLOCK_NUM getHeadBlockNum() { - INFO="$(programs/eosc/eosc get info)" + INFO="$(programs/eosc/eosc --host $SERVER --port $PORT get info)" verifyErrorCode "eosc get info" HEAD_BLOCK_NUM="$(echo "$INFO" | awk '/head_block_num/ {print $2}')" # remove trailing coma @@ -73,17 +107,24 @@ waitForNextBlock() # cleanup from last run cleanup +echo "BEGIN" > $TEST_OUTPUT +echo "TEST_OUTPUT: ${TEST_OUTPUT}" +echo "SERVER: ${SERVER}" +echo "PORT: ${PORT}" + INITA_PRV_KEY="5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" INITB_PRV_KEY="5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3" LOG_FILE=eosd_run_test.log # eosd -programs/launcher/launcher -verifyErrorCode "launcher" -sleep 7 -count=`grep -c "generated block" tn_data_0/stderr.txt` -if [[ $count == 0 ]]; then - error "FAILURE - no blocks produced" +if [ "$SERVER" == "localhost" ]; then + programs/launcher/launcher + verifyErrorCode "launcher" + sleep 7 + count=`grep -c "generated block" tn_data_0/stderr.txt` + if [[ $count == 0 ]]; then + error "FAILURE - no blocks produced" + fi fi # save starting block number @@ -197,12 +238,12 @@ fi # # create new account -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 create account inita testera $PUB_KEY1 $PUB_KEY3)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 create account inita testera $PUB_KEY1 $PUB_KEY3)" verifyErrorCode "eosc create account" waitForNextBlock # verify account created -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account testera)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get account testera)" verifyErrorCode "eosc get account" count=`echo $ACCOUNT_INFO | grep -c "staked_balance"` if [ $count == 0 ]; then @@ -210,18 +251,30 @@ if [ $count == 0 ]; then fi # transfer -TRANSFER_INFO="$(programs/eosc/eosc --wallet-port 8899 transfer inita testera 975321 "test transfer")" +TRANSFER_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 transfer inita testera 975321 "test transfer") -x 3000" verifyErrorCode "eosc transfer" # verify transfer -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account testera)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get account testera)" count=`echo $ACCOUNT_INFO | grep -c "97.5321"` if [ $count == 0 ]; then error "FAILURE - transfer failed: $ACCOUNT_INFO" fi +# force transfer +TRANSFER_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 transfer inita testera 100 "test transfer" -f) -x 3000" +verifyErrorCode "eosc force transfer" + +# verify force transfer +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get account testera)" +count=`echo $ACCOUNT_INFO | grep -c "97.5421"` +if [ $count == 0 ]; then + error "FAILURE - transfer failed: $ACCOUNT_INFO" +fi + + # create another new account via initb -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 create account initb currency $PUB_KEY2 $PUB_KEY3)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 create account initb currency $PUB_KEY2 $PUB_KEY3)" verifyErrorCode "eosc create account" waitForNextBlock @@ -236,13 +289,13 @@ echo $PASSWORD | programs/eosc/eosc --wallet-port 8899 wallet unlock --name test verifyErrorCode "eosc wallet unlock" # transfer -TRANSFER_INFO="$(programs/eosc/eosc --wallet-port 8899 transfer testera currency 975311 "test transfer a->b")" +TRANSFER_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 transfer testera currency 975311 "test transfer a->b") -x 3000" verifyErrorCode "eosc transfer" waitForNextBlock getTransactionId "$TRANSFER_INFO" # verify transfer -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account currency)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get account currency)" verifyErrorCode "eosc get account currency" count=`echo $ACCOUNT_INFO | grep -c "97.5311"` if [ $count == 0 ]; then @@ -250,7 +303,7 @@ if [ $count == 0 ]; then fi # get accounts via public key -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get accounts $PUB_KEY3)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get accounts $PUB_KEY3)" verifyErrorCode "eosc get accounts pub_key3" count=`echo $ACCOUNT_INFO | grep -c "testera"` if [ $count == 0 ]; then @@ -260,7 +313,7 @@ count=`echo $ACCOUNT_INFO | grep -c "currency"` if [ $count == 0 ]; then error "FAILURE - get accounts failed: $ACCOUNT_INFO" fi -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get accounts $PUB_KEY1)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get accounts $PUB_KEY1)" verifyErrorCode "eosc get accounts pub_key1" count=`echo $ACCOUNT_INFO | grep -c "testera"` if [ $count == 0 ]; then @@ -272,7 +325,7 @@ if [ $count != 0 ]; then fi # get servant accounts -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get servants inita)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get servants inita)" verifyErrorCode "eosc get servants inita" count=`echo $ACCOUNT_INFO | grep -c "testera"` if [ $count == 0 ]; then @@ -282,7 +335,7 @@ count=`echo $ACCOUNT_INFO | grep -c "currency"` if [ $count != 0 ]; then error "FAILURE - get servants failed: $ACCOUNT_INFO" fi -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get servants testera)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get servants testera)" verifyErrorCode "eosc get servants testera" count=`echo $ACCOUNT_INFO | grep -c "testera"` if [ $count != 0 ]; then @@ -290,7 +343,7 @@ if [ $count != 0 ]; then fi # get transaction -TRANS_INFO="$(programs/eosc/eosc --wallet-port 8899 get transaction $TRANS_ID)" +TRANS_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get transaction $TRANS_ID)" verifyErrorCode "eosc get transaction trans_id of $TRANS_INFO" count=`echo $TRANS_INFO | grep -c "transfer"` if [ $count == 0 ]; then @@ -302,7 +355,7 @@ if [ $count == 0 ]; then fi # get transactions -TRANS_INFO="$(programs/eosc/eosc --wallet-port 8899 get transactions testera)" +TRANS_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get transactions testera)" verifyErrorCode "eosc get transactions testera" count=`echo $TRANS_INFO | grep -c "$TRANS_ID"` if [ $count == 0 ]; then @@ -314,7 +367,7 @@ fi # # verify no contract in place -CODE_INFO="$(programs/eosc/eosc --wallet-port 8899 get code currency)" +CODE_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get code currency)" verifyErrorCode "eosc get code currency" # convert to num CODE_HASH="$(echo "$CODE_INFO" | awk '/code hash/ {print $3}')" @@ -325,7 +378,7 @@ if [ $CODE_HASH != 0 ]; then fi # upload a contract -INFO="$(programs/eosc/eosc --wallet-port 8899 set contract currency contracts/currency/currency.wast contracts/currency/currency.abi)" +INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 set contract currency contracts/currency/currency.wast contracts/currency/currency.abi)" verifyErrorCode "eosc set contract testera" count=`echo $INFO | grep -c "processed"` if [ $count == 0 ]; then @@ -335,11 +388,11 @@ getTransactionId "$INFO" waitForNextBlock # verify transaction exists -TRANS_INFO="$(programs/eosc/eosc --wallet-port 8899 get transaction $TRANS_ID)" +TRANS_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get transaction $TRANS_ID)" verifyErrorCode "eosc get transaction trans_id of $TRANS_INFO" # verify code is set -CODE_INFO="$(programs/eosc/eosc --wallet-port 8899 get code currency)" +CODE_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get code currency)" verifyErrorCode "eosc get code currency" # convert to num CODE_HASH="$(echo "$CODE_INFO" | awk '/code hash/ {print $3}')" @@ -350,7 +403,7 @@ if [ $CODE_HASH == 0 ]; then fi # verify currency contract has proper initial balance -INFO="$(programs/eosc/eosc --wallet-port 8899 get table currency currency account)" +INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get table currency currency account)" verifyErrorCode "eosc get table currency account" count=`echo $INFO | grep -c "1000000000"` if [ $count == 0 ]; then @@ -358,24 +411,24 @@ if [ $count == 0 ]; then fi # push message to currency contract -INFO="$(programs/eosc/eosc --wallet-port 8899 push message currency transfer '{"from":"currency","to":"inita","amount":50}' --scope currency,inita --permission currency@active)" +INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 push message currency transfer '{"from":"currency","to":"inita","amount":50}' --scope currency,inita --permission currency@active)" verifyErrorCode "eosc push message currency transfer" getTransactionId "$INFO" # verify transaction exists waitForNextBlock -TRANS_INFO="$(programs/eosc/eosc --wallet-port 8899 get transaction $TRANS_ID)" +TRANS_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get transaction $TRANS_ID)" verifyErrorCode "eosc get transaction trans_id of $TRANS_INFO" # read current contract balance -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get table inita currency account)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get table inita currency account)" verifyErrorCode "eosc get table currency account" count=`echo $ACCOUNT_INFO | grep "balance" | grep -c "50"` if [ $count == 0 ]; then error "FAILURE - get table inita account failed: $ACCOUNT_INFO" fi -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get table currency currency account)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get table currency currency account)" verifyErrorCode "eosc get table currency account" count=`echo $ACCOUNT_INFO | grep "balance" | grep -c "999999950"` if [ $count == 0 ]; then @@ -386,27 +439,35 @@ fi # Producer # -INFO="$(programs/eosc/eosc --wallet-port 8899 create producer testera $PUB_KEY1)" +INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 create producer testera $PUB_KEY1)" verifyErrorCode "eosc create producer" getTransactionId "$INFO" +# set permission +#INFO="$(programs/eosc/eosc --host $SERVER --port $PORT set action permission testera currency transfer active)" +#verifyErrorCode "eosc set action permission set" + +# remove permission +#INFO="$(programs/eosc/eosc --host $SERVER --port $PORT set action permission testera currency transfer)" +#verifyErrorCode "eosc set action permission delete" + # lock via lock_all -programs/eosc/eosc --wallet-port 8899 wallet lock_all +programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 wallet lock_all verifyErrorCode "eosc wallet lock_all" # unlock wallet inita -echo $PASSWORD_INITA | programs/eosc/eosc --wallet-port 8899 wallet unlock --name inita +echo $PASSWORD_INITA | programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 wallet unlock --name inita verifyErrorCode "eosc wallet unlock inita" # approve producer -INFO="$(programs/eosc/eosc --wallet-port 8899 set producer inita testera approve)" +INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 set producer inita testera approve)" verifyErrorCode "eosc approve producer" -ACCOUNT_INFO="$(programs/eosc/eosc --wallet-port 8899 get account inita)" +ACCOUNT_INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 get account inita)" verifyErrorCode "eosc get account" # unapprove producer -INFO="$(programs/eosc/eosc --wallet-port 8899 set producer inita testera unapprove)" +INFO="$(programs/eosc/eosc --host $SERVER --port $PORT --wallet-port 8899 set producer inita testera unapprove)" verifyErrorCode "eosc unapprove producer" # @@ -419,11 +480,13 @@ getHeadBlockNum CURRENT_BLOCK_NUM=$HEAD_BLOCK_NUM NEXT_BLOCK_NUM=1 while [ "$NEXT_BLOCK_NUM" -le "$HEAD_BLOCK_NUM" ]; do - INFO="$(programs/eosc/eosc get block $NEXT_BLOCK_NUM)" + INFO="$(programs/eosc/eosc --host $SERVER --port $PORT get block $NEXT_BLOCK_NUM)" verifyErrorCode "eosc get block" NEXT_BLOCK_NUM=$((NEXT_BLOCK_NUM+1)) done killAll cleanup +echo "END" >> $TEST_OUTPUT echo SUCCESS! +