Skip to content

Commit

Permalink
Fix test-deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
ffakenz committed May 3, 2024
1 parent b329440 commit 42d8d68
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SHELL := /bin/bash
SHELL = /bin/bash

# Load environment variables from .env file
include .env
Expand Down Expand Up @@ -34,10 +34,10 @@ build: node_modules
.SILENT: install
install: build
dfx canister install identity --argument '(null)' --mode reinstall --yes
$(shell make/install_ledger.sh)
$(shell make/install_ledger_index.sh)
./make/install_ledger.sh
./make/install_ledger_index.sh
dfx canister install github --mode reinstall --yes
$(shell make/install_bounty.sh)
./make/install_bounty.sh

.PHONY: upgrade
.SILENT: upgrade
Expand Down Expand Up @@ -114,4 +114,4 @@ test-a: install
.PHONY: test-deposit
.SILENT: test-deposit
test-deposit: install
$(shell make/test/deposit.sh)
./make/test/deposit.sh | grep "PASS"
21 changes: 13 additions & 8 deletions make/test/deposit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
set -e

balance_of() {
dfx canister call icrc1_index icrc1_balance_of "(record{owner = principal \"$1\"; })"
dfx canister call --output=json icrc1_index icrc1_balance_of \
"(record{owner = principal \"$1\"; })"
}

approve_allowance() {
dfx canister call icrc1_ledger icrc2_approve "(record { amount = $1; spender = record{owner = principal \"$2\";} })"
dfx canister call --output=json icrc1_ledger icrc2_approve \
"(record { amount = $1; spender = record{owner = principal \"$2\";} })"
}

deposit() {
dfx canister call bounty deposit "()"
dfx canister call --output=json bounty deposit "()"
}

CALLER=$(dfx identity get-principal)
Expand All @@ -21,13 +23,16 @@ BOUNTY=$(dfx canister id bounty)
echo "Calling deposit on bounty canister..."

# check initial balances
echo "Caller initial balance: $(balance_of "$CALLER")"
echo "Bounty initial balance: $(balance_of "$BOUNTY")"
echo "Caller initial balance: $(balance_of $CALLER)"
echo "Bounty initial balance: $(balance_of $BOUNTY)"

# deposit
echo "Bounty allowance: $(approve_allowance 100_000 "$BOUNTY")"
echo "Bounty allowance: $(approve_allowance 100_000 $BOUNTY)"
echo "Bounty deposit: $(deposit)"

# check final balances
echo "Caller final balance: $(balance_of "$CALLER")"
echo "Bounty final balance: $(balance_of "$BOUNTY")"
sleep 1
echo "Caller final balance: $(balance_of $CALLER)"
echo "Bounty final balance: $(balance_of $BOUNTY)"

echo "PASS"

0 comments on commit 42d8d68

Please sign in to comment.