Skip to content

Commit

Permalink
test: move remaining onchain-fee tests to new integration
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Sep 27, 2023
1 parent 0a8c558 commit 3838a1e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 221 deletions.
57 changes: 57 additions & 0 deletions test/integration/app/wallets/get-on-chain-fee.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Wallets } from "@app"

import { getOnChainWalletConfig } from "@config"

import { PayoutSpeed } from "@domain/bitcoin/onchain"
import { LessThanDustThresholdError } from "@domain/errors"

import { AccountsRepository } from "@services/mongoose"

import { createRandomUserAndWallets } from "test/helpers"

let outsideAddress: OnChainAddress

beforeAll(async () => {
outsideAddress = "bcrt1qs758ursh4q9z627kt3pp5yysm78ddny6txaqgw" as OnChainAddress
})

const amountBelowDustThreshold = getOnChainWalletConfig().dustThreshold - 1

describe("onChainPay", () => {
describe("settles onchain", () => {
it("fails to fetch fee for dust amount", async () => {
const { btcWalletDescriptor, usdWalletDescriptor } =
await createRandomUserAndWallets()
const account = await AccountsRepository().findById(btcWalletDescriptor.accountId)
if (account instanceof Error) throw account

const resultBtcWallet = await Wallets.getOnChainFeeForBtcWallet({
walletId: btcWalletDescriptor.id,
account,
address: outsideAddress,
amount: amountBelowDustThreshold,
speed: PayoutSpeed.Fast,
})
expect(resultBtcWallet).toBeInstanceOf(LessThanDustThresholdError)

const resultUsdWallet = await Wallets.getOnChainFeeForUsdWallet({
walletId: usdWalletDescriptor.id,
account,
address: outsideAddress,
amount: 1,
speed: PayoutSpeed.Fast,
})
expect(resultUsdWallet).toBeInstanceOf(LessThanDustThresholdError)

const resultUsdWalletAndBtcAmount =
await Wallets.getOnChainFeeForUsdWalletAndBtcAmount({
walletId: usdWalletDescriptor.id,
account,
address: outsideAddress,
amount: amountBelowDustThreshold,
speed: PayoutSpeed.Fast,
})
expect(resultUsdWalletAndBtcAmount).toBeInstanceOf(LessThanDustThresholdError)
})
})
})
221 changes: 0 additions & 221 deletions test/legacy-integration/02-user-wallet/02-tx-onchain-fees.spec.ts

This file was deleted.

0 comments on commit 3838a1e

Please sign in to comment.