Skip to content

Commit

Permalink
test: add realtime price to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Nov 10, 2023
1 parent 4c49faa commit 4bf4ccb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 81 deletions.
14 changes: 14 additions & 0 deletions bats/core/api/public.bats
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,17 @@ load "../../helpers/subscriber.bash"

stop_subscriber
}

@test "public: can subscribe to realtime price" {
subscribe_to 'anon' real-time-price-sub '{"currency": "EUR"}'
retry 10 1 grep 'Data.*\brealtimePrice\b.*EUR' "${SUBSCRIBER_LOG_FILE}"

num_errors=$(
grep 'Data.*\brealtimePrice\b.*EUR' "${SUBSCRIBER_LOG_FILE}" \
| awk '{print $2}' \
| jq -r '.data.brealtimePrice.errors | length'
)
[[ "$num_errors" == "0" ]] || exit 1

stop_subscriber
}
22 changes: 22 additions & 0 deletions bats/gql/real-time-price-sub.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
subscription realtimePrice($currency: DisplayCurrency!) {
realtimePrice(input: { currency: $currency }) {
errors {
message
}
realtimePrice {
id
timestamp
denominatorCurrency
btcSatPrice {
base
offset
currencyUnit
}
usdCentPrice {
base
offset
currencyUnit
}
}
}
}
2 changes: 2 additions & 0 deletions bats/helpers/subscriber.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ source "$(dirname "$CURRENT_FILE")/_common.bash"

export SUBSCRIBER_PID_FILE="${BATS_ROOT_DIR}/.gql_subscriber_pid"
export SUBSCRIBER_LOG_FILE="${BATS_ROOT_DIR}/.e2e-subscriber.log"

subscribe_to() {
stop_subscriber > /dev/null 2>&1 || true
rm -f "$SUBSCRIBER_LOG_FILE" "$SUBSCRIBER_PID_FILE" || true

token_name=$1
if [[ -n "$token_name" && "$token_name" != 'anon' ]]; then
Expand Down
81 changes: 0 additions & 81 deletions core/api/test/bats/public.bats

This file was deleted.

0 comments on commit 4bf4ccb

Please sign in to comment.