Skip to content

Commit 226f0c2

Browse files
script to create an admin account, deploy the on-chain program and create and initialize a mapping account for testing
1 parent f2f942d commit 226f0c2

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

pctest/setup_local.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
PYTH=./pyth
4+
SOLANA=../../solana/target/release/solana
5+
SOL_OPT="-u localhost --commitment finalized"
6+
RPC="-r localhost"
7+
FINAL="-c finalized"
8+
9+
check()
10+
{
11+
CMD=$1
12+
echo "$CMD"
13+
eval $CMD
14+
RC=$?
15+
if [ $RC -ne 0 ]; then
16+
echo "unexpected error executing rc= $RC"
17+
exit 1
18+
fi
19+
}
20+
21+
setup_admin()
22+
{
23+
DIR=$1
24+
OPT="-k $DIR $RPC $FINAL"
25+
chmod 0700 $DIR
26+
27+
# create publisher key and fund it
28+
check "$PYTH init_key $OPT"
29+
check "$SOLANA airdrop 10 -k $DIR/publish_key_pair.json $SOL_OPT"
30+
31+
# create program key
32+
check "$PYTH init_program $OPT"
33+
34+
# setup program key and deploy
35+
check "$SOLANA program deploy ../target/oracle.so -k $DIR/publish_key_pair.json --program-id $DIR/program_key_pair.json $SOL_OPT"
36+
37+
# setup mapping account
38+
check "$PYTH init_mapping $OPT"
39+
}
40+
41+
# create key_store directory and initialize key, program and mapping
42+
# accounts assuming you have a local build of solana and are running
43+
# both a solana-validator and solana-faucet on localhost
44+
# run from build/ directory
45+
KDIR=$1
46+
if [ -z "$KDIR" ] ; then
47+
echo "set_local.sh <key_store_directory>"
48+
exit 1
49+
fi
50+
setup_admin $KDIR

0 commit comments

Comments
 (0)