Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for back and forth send #12

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions load-test/multi_msg_load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#/bin/sh

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a documentation to this script. What are the parameters? Also we need a help message.

FROM=$1
if [ -z $FROM ]
then
FROM=1
fi

TO=$2
if [ -z $TO ]
then
TO=2
fi

if [ -z $NUM_TXS ] ; then
num_txs=1000
else
num_txs=$NUM_TXS
fi


balance_query() {
balance=$("${DAEMON}" q bank balances $1 --node $RPC --output json)
balanceres=$(echo "${balance}" | jq -r '.balances')
return "$balanceres"
}

RPC="http://127.0.0.1:16657"
num_msgs=30
acc1=$($DAEMON keys show account$FROM -a --home $DAEMON_HOME-1 --keyring-backend test)
acc2=$($DAEMON keys show account$TO -a --home $DAEMON_HOME-1 --keyring-backend test)
echo "** Balance of Account 1 before send_load :: **"
balance_query "$acc1"
echo "** Balance of Account 2 before send_load :: **"
balance_query "$acc2"
cd ~/
seq1=$("${DAEMON}" q account "${acc1}" --node $RPC --output json)
seq1no=$(echo "${seq1}" | jq -r '.sequence')
seq2=$("${DAEMON}" q account "${acc2}" --node $RPC --output json)
seq2no=$(echo "${seq2}" | jq -r '.sequence')
for (( a=0; a<$num_txs; a++ ))
do
unsignedTxto=$("${DAEMON}" tx bank send "${acc1}" "${acc2}" 1000000"${DENOM}" --chain-id "${CHAINID}" --output json --generate-only --gas 500000 > unsignedto.json)
unsignedTxtores=$(echo "${unsignedTxto}")
unsignedTxfrom=$("${DAEMON}" tx bank send "${acc2}" "${acc1}" 1000000"${DENOM}" --chain-id "${CHAINID}" --output json --generate-only --gas 500000 > unsignedfrom.json)
unsignedTxfromres=$(echo "${unsignedTxfrom}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this and unsignedTxtores is not used

for (( b=0; b<$num_msgs; b++))
do
cat unsignedto.json | jq '.body.messages |= . + [.[-1]]' > unsignedto.json.bk
mv unsignedto.json.bk unsignedto.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just write it to unsignedto.json? Any issues with that?

cat unsignedfrom.json | jq '.body.messages |= . + [.[-1]]' > unsignedfrom.json.bk
mv unsignedfrom.json.bk unsignedfrom.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I feel that some of this operations would be better done in a Go or JS script - for example this one.

done
seqto=$(expr $seq1no + $a)
signTxto=$("${DAEMON}" tx sign unsignedto.json --from "${acc1}" --chain-id "${CHAINID}" --keyring-backend test --home $DAEMON_HOME-1 --node $RPC --signature-only=false --sequence $seqto --gas 500000 > signedto.json)
signTxtores=$(echo "${signTxto}")
broadcastto=$("${DAEMON}" tx broadcast signedto.json --output json --chain-id "${CHAINID}" --gas 500000 --node $RPC --broadcast-mode async)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally this should be run in parallel - &, same for the "from" tx below.

broadcasttoRes=$(echo "${broadcastto}" | jq .txhash)
echo $broadcasttoRes

seqfrom=$(expr $seq2no + $a)
signTxfrom=$("${DAEMON}" tx sign unsignedfrom.json --from "${acc2}" --chain-id "${CHAINID}" --keyring-backend test --home $DAEMON_HOME-1 --node $RPC --signature-only=false --sequence $seqfrom --gas 500000 > signedfrom.json)
signTxfromres=$(echo "${signTxfrom}")
broadcastfrom=$("${DAEMON}" tx broadcast signedfrom.json --output json --chain-id "${CHAINID}" --gas 500000 --node $RPC --broadcast-mode async)
broadcastfromRes=$(echo "${broadcastfrom}" | jq .txhash)
echo $broadcastfromRes
done

sleep 7s
echo "** Balance of Account 1 after send_load :: **"
balance_query $acc1
echo "** Balance of Account 2 after send_load :: **"
balance_query $acc2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to print, we want to check that the balance is correct. Please add an assertion to check that the balance didn't change.

36 changes: 0 additions & 36 deletions load-test/send_load.sh

This file was deleted.

51 changes: 51 additions & 0 deletions load-test/single_msg_load.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#/bin/sh

FROM=$1
if [ -z $FROM ]
then
FROM=1
fi

TO=$2
if [ -z $TO ]
then
TO=2
fi

balance_query() {
balance=$("${DAEMON}" q bank balances $1 --node $RPC --output json)
balanceres=$(echo "${balance}" | jq -r '.balances')
return "$balanceres"
}

RPC="http://127.0.0.1:16657"
num_txs=1000
acc1=$($DAEMON keys show account$FROM -a --home $DAEMON_HOME-1 --keyring-backend test)
acc2=$($DAEMON keys show account$TO -a --home $DAEMON_HOME-1 --keyring-backend test)
echo "** Balance of Account 1 before send_load :: **"
balance_query "$acc1"
echo "** Balance of Account 2 before send_load :: **"
balance_query "$acc2"
cd ~/
seq1=$("${DAEMON}" q account "${acc1}" --node $RPC --output json)
seq1no=$(echo "${seq1}" | jq -r '.sequence')
seq2=$("${DAEMON}" q account "${acc2}" --node $RPC --output json)
seq2no=$(echo "${seq2}" | jq -r '.sequence')
for (( a=0; a<$num_txs; a++ ))
do
seqto=$(expr $seq1no + $a)
seqfrom=$(expr $seq2no + $a)
sTxto=$("${DAEMON}" tx bank send "${acc1}" "${acc2}" 1000000"${DENOM}" --chain-id "${CHAINID}" --keyring-backend test --home $DAEMON_HOME-1 --node $RPC --output json -y --sequence $seqto)
sTxtoHash=$(echo "${sTxto}" | jq -r '.txhash')
echo "** TX HASH :: $sTxtoHash **"
sTxfrom=$("${DAEMON}" tx bank send "${acc2}" "${acc1}" 1000000"${DENOM}" --chain-id "${CHAINID}" --keyring-backend test --home $DAEMON_HOME-1 --node $RPC --output json -y --sequence $seqfrom)
sTxfromHash=$(echo "${sTxfrom}" | jq -r '.txhash')
echo "** TX HASH :: $sTxfromHash **"
done

balance1=$("${DAEMON}" q bank balances "${acc1}" --node $RPC --output json)
balance1res=$(echo "${balance1}" | jq -r '.balances')
echo "** Balance of Account 1 after send_load :: $balance1res **"
balance2=$("${DAEMON}" q bank balances "${acc2}" --node $RPC --output json)
balance2res=$(echo "${balance1}" | jq -r '.balances')
echo "** Balance of Account 2 after send_load :: $balance2res **"