Skip to content

Commit

Permalink
use Charlie instead of Alice for sidechain demo to avoid genesis fund…
Browse files Browse the repository at this point in the history
…s change
  • Loading branch information
brenzi committed Oct 5, 2024
1 parent 0f236a9 commit 772901c
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions cli/demo_sidechain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,57 +104,57 @@ ICGACCOUNTBOB=//BobIncognito
echo " Bob's incognito account = ${ICGACCOUNTBOB}"
echo ""

echo "* Shield ${INITIALFUNDS} tokens to Alice's account on L2"
${CLIENT} transfer //Alice ${VAULT} ${INITIALFUNDS}
echo "* Shield ${INITIALFUNDS} tokens to Charlie's account on L2"
${CLIENT} transfer //Charlie ${VAULT} ${INITIALFUNDS}
echo ""

echo "* Waiting 30 seconds"
sleep 30
echo ""

echo "Get balance of Alice's incognito account (on worker 1)"
${CLIENTWORKER1} trusted --mrenclave ${MRENCLAVE} balance //Alice
echo "Get balance of Charlie's incognito account (on worker 1)"
${CLIENTWORKER1} trusted --mrenclave ${MRENCLAVE} balance //Charlie
echo ""

# Send funds from Alice to Bobs account, on worker 1.
echo "* First transfer: Send ${AMOUNTTRANSFER} funds from Alice's incognito account to Bob's incognito account (on worker 1)"
$CLIENTWORKER1 trusted --mrenclave ${MRENCLAVE} --direct transfer //Alice ${ICGACCOUNTBOB} ${AMOUNTTRANSFER}
# Send funds from Charlie to Bobs account, on worker 1.
echo "* First transfer: Send ${AMOUNTTRANSFER} funds from Charlie's incognito account to Bob's incognito account (on worker 1)"
$CLIENTWORKER1 trusted --mrenclave ${MRENCLAVE} --direct transfer //Charlie ${ICGACCOUNTBOB} ${AMOUNTTRANSFER}
echo ""

# Prevent nonce clash when sending direct trusted calls to different workers.
echo "* Waiting 2 seconds"
sleep 2
echo ""

# Send funds from Alice to Bobs account, on worker 2.
echo "* Second transfer: Send ${AMOUNTTRANSFER} funds from Alice's incognito account to Bob's incognito account (on worker 2)"
$CLIENTWORKER2 trusted --mrenclave ${MRENCLAVE} --direct transfer //Alice ${ICGACCOUNTBOB} ${AMOUNTTRANSFER}
# Send funds from Charlie to Bobs account, on worker 2.
echo "* Second transfer: Send ${AMOUNTTRANSFER} funds from Charlie's incognito account to Bob's incognito account (on worker 2)"
$CLIENTWORKER2 trusted --mrenclave ${MRENCLAVE} --direct transfer //Charlie ${ICGACCOUNTBOB} ${AMOUNTTRANSFER}
echo ""

# Prevent getter being executed too early and returning an outdated result, before the transfer was made.
echo "* Waiting 2 seconds"
sleep 2
echo ""

echo "* Get balance of Alice's incognito account (on worker 1)"
ALICE_BALANCE=$(${CLIENTWORKER1} trusted --mrenclave ${MRENCLAVE} balance //Alice | xargs)
echo "$ALICE_BALANCE"
echo "* Get balance of Charlie's incognito account (on worker 1)"
CHARLIE_BALANCE=$(${CLIENTWORKER1} trusted --mrenclave ${MRENCLAVE} balance //Charlie | xargs)
echo "$CHARLIE_BALANCE"
echo ""

echo "* Get balance of Bob's incognito account (on worker 2)"
BOB_BALANCE=$(${CLIENTWORKER2} trusted --mrenclave ${MRENCLAVE} balance ${ICGACCOUNTBOB} | xargs)
echo "$BOB_BALANCE"
echo ""

ALICE_EXPECTED_BALANCE=$(( 1 * UNIT ))
CHARLIE_EXPECTED_BALANCE=$(( 1 * UNIT ))
BOB_EXPECTED_BALANCE=$(( 4 * UNIT ))

echo "* Verifying Alice's balance"
if (( ALICE_BALANCE >= ALICE_EXPECTED_BALANCE ? ALICE_BALANCE - ALICE_EXPECTED_BALANCE > FEE_TOLERANCE : ALICE_EXPECTED_BALANCE - ALICE_BALANCE > FEE_TOLERANCE)); then
echo "Alice's balance is wrong (expected: $ALICE_EXPECTED_BALANCE, actual: $ALICE_BALANCE), tolerance = $FEE_TOLERANCE"
echo "* Verifying Charlie's balance"
if (( CHARLIE_BALANCE >= CHARLIE_EXPECTED_BALANCE ? CHARLIE_BALANCE - CHARLIE_EXPECTED_BALANCE > FEE_TOLERANCE : CHARLIE_EXPECTED_BALANCE - CHARLIE_BALANCE > FEE_TOLERANCE)); then
echo "Charlie's balance is wrong (expected: $CHARLIE_EXPECTED_BALANCE, actual: $CHARLIE_BALANCE), tolerance = $FEE_TOLERANCE"
exit 1
else
echo "Alice's balance is correct ($ALICE_BALANCE)"
echo "Charlie's balance is correct ($CHARLIE_BALANCE)"
fi
echo ""

Expand Down

0 comments on commit 772901c

Please sign in to comment.