|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +filename=$(basename "$0") |
| 4 | +scriptname="${filename%.*}" |
| 5 | +date "+${scriptname} start %Y%m%d_%H%M%S" |
| 6 | + |
| 7 | +set -e |
| 8 | +set -x |
| 9 | +set -o pipefail |
| 10 | +export SHELLOPTS |
| 11 | + |
| 12 | +WALLET=$1 |
| 13 | + |
| 14 | +gcmd="goal -w ${WALLET}" |
| 15 | + |
| 16 | +PAYER=$(${gcmd} account list|awk '{ print $3 }') |
| 17 | +MOOCHER=$(${gcmd} account new|awk '{ print $6 }') |
| 18 | + |
| 19 | +# Fund MOOCHER, 1M |
| 20 | +${gcmd} clerk send -a 1000000 -f "${PAYER}" -t "${MOOCHER}" |
| 21 | + |
| 22 | +# Payer and Moocher are going to pay each other 100 mAlgos, but |
| 23 | +# Moocher is not going to pay the minfee (Payer will pay double) |
| 24 | + |
| 25 | +# Fair number of temporary files, just cd into TEMPDIR first |
| 26 | +cd ${TEMPDIR} |
| 27 | + |
| 28 | +# Check a low fee from moocher |
| 29 | +${gcmd} clerk send -a 100 -f "${MOOCHER}" -t "${PAYER}" --fee 2 -o cheap.txn |
| 30 | +# Since goal was modified to allow < minfee when this feature was added, let's confirm |
| 31 | +msgpacktool -d < cheap.txn | grep fee | grep 2 |
| 32 | +${gcmd} clerk send -a 100 -f "${PAYER}" -t "${MOOCHER}" --fee 2000 -o expensive.txn |
| 33 | +cat cheap.txn expensive.txn > both.txn |
| 34 | +${gcmd} clerk group -i both.txn -o group.txn |
| 35 | +${gcmd} clerk sign -i group.txn -o group.stx |
| 36 | +${gcmd} clerk rawsend -f group.stx |
| 37 | + |
| 38 | +# Check a zero fee from moocher |
| 39 | +${gcmd} clerk send -a 100 -f "${MOOCHER}" -t "${PAYER}" --fee 0 -o cheap.txn |
| 40 | +# Since goal was modified to allow zero when this feature was added, let's confirm |
| 41 | +# that it's not encoded (should be "omitempty") |
| 42 | +set +e |
| 43 | +FOUND=$(msgpacktool -d < cheap.txn | grep fee) |
| 44 | +set -e |
| 45 | +if [[ $FOUND != "" ]]; then |
| 46 | + date "+{scriptname} FAIL fee was improperly encoded $FOUND %Y%m%d_%H%M%S" |
| 47 | + false |
| 48 | +fi |
| 49 | + |
| 50 | +${gcmd} clerk send -a 100 -f "${PAYER}" -t "${MOOCHER}" --fee 2000 -o expensive.txn |
| 51 | +cat cheap.txn expensive.txn > both.txn |
| 52 | +${gcmd} clerk group -i both.txn -o group.txn |
| 53 | +${gcmd} clerk sign -i group.txn -o group.stx |
| 54 | +${gcmd} clerk rawsend -f group.stx |
| 55 | + |
| 56 | + |
| 57 | +date "+${scriptname} OK %Y%m%d_%H%M%S" |
0 commit comments