Skip to content

Commit

Permalink
ci: upload tilt log
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi committed Dec 18, 2023
1 parent 250c0be commit 44260a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 54 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/bats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,12 @@ jobs:
- name: Run bats tests
run: |
nix develop -c bats --setup-suite-file bats/ci_setup_suite.bash -t bats/core/**
- name: Rename Tilt log
if: always()
run: mv bats/.e2e-tilt.log bats/e2e-tilt.log
- name: Upload Tilt log
if: always()
uses: actions/upload-artifact@v2
with:
name: Tilt log
path: bats/e2e-tilt.log
6 changes: 3 additions & 3 deletions bats/ci_setup_suite.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ await_api_is_up() {
[[ "${network}" = "regtest" ]] || exit 1
}

retry 300 1 server_is_up
retry 360 1 server_is_up
}

await_pay_is_up() {
pay_is_up() {
curl localhost:3002 || exit 1
}

retry 300 1 pay_is_up
retry 360 1 pay_is_up
}

await_api_keys_is_up() {
api_keys_is_up() {
curl localhost:5397/auth/check || exit 1
}

retry 300 1 api_keys_is_up
retry 360 1 api_keys_is_up
}
51 changes: 0 additions & 51 deletions core/api/test/integration/services/lnurl-pay.spec.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,10 @@
import { decodeInvoice } from "@/domain/bitcoin/lightning"
import { ErrorFetchingLnurlInvoice } from "@/domain/bitcoin/lnurl/errors"
import { LnurlPayService } from "@/services/lnurl-pay"
import { createRandomUserAndWallets } from "test/helpers"
import { setUsername, usernameAvailable } from "@/app/accounts"
import { checkedToUsername } from "@/domain/accounts"

const usernameForLnAddress = checkedToUsername("lnurl_test_user")
const lnurlForUsername =
"lnurl1dp68gup69uhkcmmrv9kxsmmnwsarxvpsxghjuam9d3kz66mwdamkutmvde6hymrs9akxuatjd30hgetnw30h2um9wg3wjc63" // http://localhost:3002/.well-known/lnurlp/lnurl_test_user
if (usernameForLnAddress instanceof Error) {
throw usernameForLnAddress
}

beforeAll(async () => {
const isUsernameAvailable = await usernameAvailable(usernameForLnAddress)
if (isUsernameAvailable instanceof Error) {
throw isUsernameAvailable
}
if (isUsernameAvailable) {
const newUser = await createRandomUserAndWallets()
const setUsernameRes = await setUsername({
accountId: newUser.btcWalletDescriptor.accountId,
username: usernameForLnAddress,
})

if (setUsernameRes instanceof Error) {
throw setUsernameRes
}
}
})

describe("LnurlPayService", () => {
const lnurlPayService = LnurlPayService()

describe("fetchInvoiceFromLnAddressOrLnurl", () => {
it("fetches an invoice from an lnurl", async () => {
const invoice = await lnurlPayService.fetchInvoiceFromLnAddressOrLnurl({
amount: {
amount: BigInt(1000),
currency: "BTC",
} as BtcPaymentAmount,
lnAddressOrLnurl: lnurlForUsername,
})

if (invoice instanceof Error) {
throw invoice
}

const decodedInvoice = await decodeInvoice(invoice)

if (decodedInvoice instanceof Error) {
throw decodedInvoice
}

expect(decodedInvoice.amount).toEqual(1000)
})

it("returns an error if the lnurl is invalid", async () => {
const invoice = await lnurlPayService.fetchInvoiceFromLnAddressOrLnurl({
amount: {
Expand Down

0 comments on commit 44260a8

Please sign in to comment.