Skip to content

Commit

Permalink
test(core): remove redundant 'createAccount' helper
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Jan 11, 2024
1 parent 20d25c9 commit 6afa82f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 31 deletions.
28 changes: 1 addition & 27 deletions core/api/test/helpers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ import { Account } from "@/services/mongoose/schema"

import { baseLogger } from "@/services/logger"

import { Accounts, Wallets } from "@/app"
import { Wallets } from "@/app"

import { sleep } from "@/utils"

import { AccountLevel, AccountStatus } from "@/domain/accounts"

const accounts = AccountsRepository()

export const getAccountByPhone = async (phone: PhoneNumber): Promise<Account> => {
Expand Down Expand Up @@ -180,30 +178,6 @@ export const createUserAndWalletFromPhone = async (
}
}

export const createAccount = async ({
initialWallets,
userId,
}: {
initialWallets: WalletCurrency[]
userId?: UserId
}) => {
const phone = randomPhone()

const kratosUserId = userId || randomUserId()

const account = await Accounts.createAccountWithPhoneIdentifier({
newAccountInfo: { phone, kratosUserId },
config: {
initialStatus: AccountStatus.Active,
initialWallets,
initialLevel: AccountLevel.One,
},
})
if (account instanceof Error) throw account

return account
}

export const createRandomUserAndBtcWallet = async () => {
const phone = randomPhone()
return createUserAndWallet(phone)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Payments, Wallets } from "@/app"
import { Accounts, Payments, Wallets } from "@/app"
import { getMidPriceRatio } from "@/app/prices"
import { getDealerConfig } from "@/config"

import { AccountLevel, AccountStatus } from "@/domain/accounts"
import { toSats } from "@/domain/bitcoin"
import { toCents } from "@/domain/fiat"
import { SubOneCentSatAmountForUsdSelfSendError } from "@/domain/payments"
Expand All @@ -17,7 +18,6 @@ import { AccountsRepository, WalletsRepository } from "@/services/mongoose"
import {
bitcoindClient,
bitcoindOutside,
createAccount,
createMandatoryUsers,
fundLnd,
fundWallet,
Expand All @@ -28,6 +28,8 @@ import {
loadBitcoindWallet,
mineAndConfirm,
openChannelTesting,
randomPhone,
randomUserId,
resetLegacyIntegrationLnds,
} from "test/helpers"

Expand Down Expand Up @@ -128,9 +130,15 @@ if (usdFundingAmount instanceof Error) throw usdFundingAmount

const newAccountAndWallets = async () => {
const initialWallets = [WalletCurrency.Btc, WalletCurrency.Usd]
const account: Account | RepositoryError = await createAccount({
initialWallets,
const account = await Accounts.createAccountWithPhoneIdentifier({
newAccountInfo: { phone: randomPhone(), kratosUserId: randomUserId() },
config: {
initialStatus: AccountStatus.Active,
initialWallets,
initialLevel: AccountLevel.One,
},
})
if (account instanceof Error) throw account

const accountId = account.id
const accountWallets =
Expand Down

0 comments on commit 6afa82f

Please sign in to comment.