-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: clean up onchain-fee legacy integration tests (#3273)
* test: add onchain fee bats tests * test: remove redundant onchain-fee success tests * test: move remaining onchain-fee tests to new integration
- Loading branch information
Showing
6 changed files
with
195 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query onChainTxFee($walletId: WalletId!, $address: OnChainAddress!, $amount: SatAmount!) { | ||
onChainTxFee(walletId: $walletId, address: $address, amount: $amount) { | ||
amount | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
query onChainUsdTxFeeAsBtcDenominated( | ||
$walletId: WalletId! | ||
$address: OnChainAddress! | ||
$amount: SatAmount! | ||
) { | ||
onChainUsdTxFeeAsBtcDenominated( | ||
walletId: $walletId | ||
address: $address | ||
amount: $amount | ||
) { | ||
amount | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
query onChainUsdTxFee( | ||
$walletId: WalletId! | ||
$address: OnChainAddress! | ||
$amount: CentAmount! | ||
) { | ||
onChainUsdTxFee(walletId: $walletId, address: $address, amount: $amount) { | ||
amount | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.