Skip to content

Commit

Permalink
Embed program at genesis for tests (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
armaniferrante authored Dec 16, 2021
1 parent 48603ff commit efe5766
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions scripts/travis/dex-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@ set -euxo pipefail
CLUSTER=localnet
KEYPAIR_FILE=$HOME/.config/solana/id.json
CLUSTER_URL=http://localhost:8899
PROGRAM_ID="2SXFv8tTmavm8uSAg3ft1JjttzJvgwXZiUPa9xuUbqH2"

#
# Assumes the current working directory is top-level serum-dex dir.
#
main() {
set +e
#
# Build the program.
#
cd ./dex && cargo build-bpf && cd ../
#
# Start the local validator.
#
solana-test-validator > validator.log &
solana-test-validator --bpf-program $PROGRAM_ID dex/target/deploy/serum_dex.so > validator.log &
#
# Wait for the validator to start.
#
sleep 5
#
# Run the whole-shebang.
#
pushd dex/crank
cargo run -- $CLUSTER whole-shebang $KEYPAIR_FILE $PROGRAM_ID
popd
#
# Create a keypair for the tests.
#
yes | solana-keygen new --outfile $KEYPAIR_FILE
Expand All @@ -34,27 +45,6 @@ main() {
pushd dex
cargo test
popd
#
# Run the integration tests.
#
dex_whole_shebang
}

dex_whole_shebang() {
#
# Build the program.
#
cd ./dex && cargo build-bpf && cd ../
#
# Deploy the program.
#
local dex_program_id="$(solana deploy --output json-compact --url ${CLUSTER_URL} dex/target/deploy/serum_dex.so | jq .programId -r)"
#
# Run the whole-shebang.
#
pushd dex/crank
cargo run -- $CLUSTER whole-shebang $KEYPAIR_FILE $dex_program_id
popd
}

main

0 comments on commit efe5766

Please sign in to comment.