-
Notifications
You must be signed in to change notification settings - Fork 9
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
Changes from 18 commits
6f7818d
34e709b
7bc49a4
f8dd0b8
9d0d3f2
89b74f5
c8c119f
5432694
69ff980
c250817
781a7d7
70b912c
58f1078
c492456
3665875
b947fd0
c79a538
d245c24
b293f57
6ba85d7
1985501
614f9d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#/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=35 | ||
num_msgs=30 | ||
kaustubhkapatral marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this and |
||
for (( b=0; b<$num_msgs; b++)) | ||
do | ||
cat unsignedto.json | jq '.body.messages |= . + [.[-1]]' > unsignedto.json.bk | ||
kaustubhkapatral marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mv unsignedto.json.bk unsignedto.json | ||
cat unsignedfrom.json | jq '.body.messages |= . + [.[-1]]' > unsignedfrom.json.bk | ||
mv unsignedfrom.json.bk unsignedfrom.json | ||
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ideally this should be run in parallel - |
||
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 | ||
|
||
|
||
kaustubhkapatral marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sleep 7s | ||
echo "** Balance of Account 1 after send_load :: **" | ||
balance_query $acc1 | ||
echo "** Balance of Account 2 after send_load :: **" | ||
balance_query $acc2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
This file was deleted.
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 **" |
There was a problem hiding this comment.
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.