From 13c52859eb8f99bbc41d1c830942716639eab0b3 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Thu, 16 Sep 2021 21:14:22 -0400 Subject: [PATCH] fix: renames `verify...` methods to `validate...` (#1624) * rename verify -> validate * fix imports * run eslint --fix on test/ --- src/index.ts | 2 +- src/models/transactions/accountDelete.ts | 6 +- src/models/transactions/accountSet.ts | 8 +- src/models/transactions/checkCancel.ts | 6 +- src/models/transactions/checkCash.ts | 8 +- src/models/transactions/checkCreate.ts | 8 +- src/models/transactions/common.ts | 10 +-- src/models/transactions/depositPreauth.ts | 8 +- src/models/transactions/escrowCancel.ts | 6 +- src/models/transactions/escrowCreate.ts | 8 +- src/models/transactions/escrowFinish.ts | 6 +- src/models/transactions/index.ts | 14 ++-- src/models/transactions/offerCancel.ts | 6 +- src/models/transactions/offerCreate.ts | 8 +- src/models/transactions/payment.ts | 10 +-- .../transactions/paymentChannelClaim.ts | 8 +- .../transactions/paymentChannelCreate.ts | 10 ++- src/models/transactions/paymentChannelFund.ts | 6 +- src/models/transactions/setRegularKey.ts | 6 +- src/models/transactions/signerListSet.ts | 6 +- src/models/transactions/ticketCreate.ts | 6 +- src/models/transactions/transaction.ts | 82 ++++++++++--------- src/models/transactions/trustSet.ts | 6 +- src/wallet/signer.ts | 10 +-- test/client/autofill.ts | 8 +- test/integration/integration.ts | 4 +- test/integration/utils.ts | 4 +- test/models/accountDelete.ts | 18 ++-- test/models/accountSet.ts | 40 +++++---- test/models/baseTransaction.ts | 29 ++++--- test/models/checkCancel.ts | 12 ++- test/models/checkCash.ts | 24 +++--- test/models/checkCreate.ts | 28 +++---- test/models/depositPreauth.ts | 34 ++++---- test/models/escrowCancel.ts | 25 +++--- test/models/escrowCreate.ts | 46 +++++------ test/models/escrowFinish.ts | 28 +++---- test/models/offerCancel.ts | 20 ++--- test/models/offerCreate.ts | 32 ++++---- test/models/payment.ts | 59 ++++++------- test/models/paymentChannelClaim.ts | 36 ++++---- test/models/paymentChannelCreate.ts | 52 ++++++------ test/models/paymentChannelFund.ts | 32 ++++---- test/models/setRegularKey.ts | 16 ++-- test/models/signerListSet.ts | 20 ++--- test/models/ticketCreate.ts | 28 +++---- test/models/trustSet.ts | 24 +++--- test/models/utils.ts | 3 +- test/utils/hashes.ts | 2 +- test/wallet/index.ts | 3 +- test/wallet/signer.ts | 3 +- 51 files changed, 423 insertions(+), 461 deletions(-) diff --git a/src/index.ts b/src/index.ts index 195eff91..e38a6226 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,7 @@ export * from './common/types/objects/ledger' export * from './models/methods' -export * from './models/methods' +export * from './models/transactions' export * from './utils' diff --git a/src/models/transactions/accountDelete.ts b/src/models/transactions/accountDelete.ts index 19ce1bfa..682e5d09 100644 --- a/src/models/transactions/accountDelete.ts +++ b/src/models/transactions/accountDelete.ts @@ -1,6 +1,6 @@ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface AccountDelete extends BaseTransaction { TransactionType: 'AccountDelete' @@ -14,8 +14,8 @@ export interface AccountDelete extends BaseTransaction { * @param tx - An AccountDelete Transaction. * @throws When the AccountDelete is Malformed. */ -export function verifyAccountDelete(tx: Record): void { - verifyBaseTransaction(tx) +export function validateAccountDelete(tx: Record): void { + validateBaseTransaction(tx) if (tx.Destination === undefined) { throw new ValidationError('AccountDelete: missing field Destination') diff --git a/src/models/transactions/accountSet.ts b/src/models/transactions/accountSet.ts index 62badcc3..dec622b8 100644 --- a/src/models/transactions/accountSet.ts +++ b/src/models/transactions/accountSet.ts @@ -1,7 +1,7 @@ -/* eslint-disable complexity -- Necessary for verifyAccountSet */ +/* eslint-disable complexity -- Necessary for validateAccountSet */ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export enum AccountSetFlags { asfRequireDest = 1, @@ -54,8 +54,8 @@ const MAX_TICK_SIZE = 15 * @param tx - An AccountSet Transaction. * @throws When the AccountSet is Malformed. */ -export function verifyAccountSet(tx: Record): void { - verifyBaseTransaction(tx) +export function validateAccountSet(tx: Record): void { + validateBaseTransaction(tx) if (tx.ClearFlag !== undefined) { if (typeof tx.ClearFlag !== 'number') { diff --git a/src/models/transactions/checkCancel.ts b/src/models/transactions/checkCancel.ts index 7ed859f5..739e88b5 100644 --- a/src/models/transactions/checkCancel.ts +++ b/src/models/transactions/checkCancel.ts @@ -1,6 +1,6 @@ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface CheckCancel extends BaseTransaction { TransactionType: 'CheckCancel' @@ -13,8 +13,8 @@ export interface CheckCancel extends BaseTransaction { * @param tx - An CheckCancel Transaction. * @throws When the CheckCancel is Malformed. */ -export function verifyCheckCancel(tx: Record): void { - verifyBaseTransaction(tx) +export function validateCheckCancel(tx: Record): void { + validateBaseTransaction(tx) if (tx.CheckID !== undefined && typeof tx.CheckID !== 'string') { throw new ValidationError('CheckCancel: invalid CheckID') diff --git a/src/models/transactions/checkCash.ts b/src/models/transactions/checkCash.ts index b203e817..92b0f965 100644 --- a/src/models/transactions/checkCash.ts +++ b/src/models/transactions/checkCash.ts @@ -1,8 +1,8 @@ -/* eslint-disable complexity -- Necessary for verifyCheckCash */ +/* eslint-disable complexity -- Necessary for validateCheckCash */ import { ValidationError } from '../../common/errors' import { Amount } from '../common' -import { BaseTransaction, verifyBaseTransaction, isAmount } from './common' +import { BaseTransaction, validateBaseTransaction, isAmount } from './common' export interface CheckCash extends BaseTransaction { TransactionType: 'CheckCash' @@ -17,8 +17,8 @@ export interface CheckCash extends BaseTransaction { * @param tx - An CheckCash Transaction. * @throws When the CheckCash is Malformed. */ -export function verifyCheckCash(tx: Record): void { - verifyBaseTransaction(tx) +export function validateCheckCash(tx: Record): void { + validateBaseTransaction(tx) if (tx.Amount == null && tx.DeliverMin == null) { throw new ValidationError( diff --git a/src/models/transactions/checkCreate.ts b/src/models/transactions/checkCreate.ts index 488b6f8f..096ef4f8 100644 --- a/src/models/transactions/checkCreate.ts +++ b/src/models/transactions/checkCreate.ts @@ -1,10 +1,10 @@ -/* eslint-disable complexity -- Necessary for verifyCheckCreate */ +/* eslint-disable complexity -- Necessary for validateCheckCreate */ import { ValidationError } from '../../common/errors' import { Amount } from '../common' import { BaseTransaction, - verifyBaseTransaction, + validateBaseTransaction, isIssuedCurrency, } from './common' @@ -23,8 +23,8 @@ export interface CheckCreate extends BaseTransaction { * @param tx - An CheckCreate Transaction. * @throws When the CheckCreate is Malformed. */ -export function verifyCheckCreate(tx: Record): void { - verifyBaseTransaction(tx) +export function validateCheckCreate(tx: Record): void { + validateBaseTransaction(tx) if (tx.SendMax === undefined) { throw new ValidationError('CheckCreate: missing field SendMax') diff --git a/src/models/transactions/common.ts b/src/models/transactions/common.ts index 476b839a..3264c554 100644 --- a/src/models/transactions/common.ts +++ b/src/models/transactions/common.ts @@ -1,6 +1,6 @@ -/* eslint-disable max-lines-per-function -- Necessary for verifyBaseTransaction */ -/* eslint-disable complexity -- Necessary for verifyBaseTransaction */ -/* eslint-disable max-statements -- Necessary for verifyBaseTransaction */ +/* eslint-disable max-lines-per-function -- Necessary for validateBaseTransaction */ +/* eslint-disable complexity -- Necessary for validateBaseTransaction */ +/* eslint-disable max-statements -- Necessary for validateBaseTransaction */ import { ValidationError } from '../../common/errors' import { Memo, Signer } from '../common' import { onlyHasFields } from '../utils' @@ -121,14 +121,14 @@ export interface BaseTransaction { } /** - * Verify the common fields of a transaction. The verify functionality will be + * Verify the common fields of a transaction. The validate functionality will be * optional, and will check transaction form at runtime. This should be called * any time a transaction will be verified. * * @param common - An interface w/ common transaction fields. * @throws When the common param is malformed. */ -export function verifyBaseTransaction(common: Record): void { +export function validateBaseTransaction(common: Record): void { if (common.Account === undefined) { throw new ValidationError('BaseTransaction: missing field Account') } diff --git a/src/models/transactions/depositPreauth.ts b/src/models/transactions/depositPreauth.ts index 48044abe..c0d2a6ac 100644 --- a/src/models/transactions/depositPreauth.ts +++ b/src/models/transactions/depositPreauth.ts @@ -1,7 +1,7 @@ -/* eslint-disable complexity -- Necessary for verifyDepositPreauth */ +/* eslint-disable complexity -- Necessary for validateDepositPreauth */ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface DepositPreauth extends BaseTransaction { TransactionType: 'DepositPreauth' @@ -15,8 +15,8 @@ export interface DepositPreauth extends BaseTransaction { * @param tx - A DepositPreauth Transaction. * @throws When the DepositPreauth is malformed. */ -export function verifyDepositPreauth(tx: Record): void { - verifyBaseTransaction(tx) +export function validateDepositPreauth(tx: Record): void { + validateBaseTransaction(tx) if (tx.Authorize !== undefined && tx.Unauthorize !== undefined) { throw new ValidationError( diff --git a/src/models/transactions/escrowCancel.ts b/src/models/transactions/escrowCancel.ts index 9e62ced9..34183f42 100644 --- a/src/models/transactions/escrowCancel.ts +++ b/src/models/transactions/escrowCancel.ts @@ -1,6 +1,6 @@ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface EscrowCancel extends BaseTransaction { TransactionType: 'EscrowCancel' @@ -14,8 +14,8 @@ export interface EscrowCancel extends BaseTransaction { * @param tx - An EscrowCancel Transaction. * @throws When the EscrowCancel is Malformed. */ -export function verifyEscrowCancel(tx: Record): void { - verifyBaseTransaction(tx) +export function validateEscrowCancel(tx: Record): void { + validateBaseTransaction(tx) if (tx.Owner === undefined) { throw new ValidationError('EscrowCancel: missing Owner') diff --git a/src/models/transactions/escrowCreate.ts b/src/models/transactions/escrowCreate.ts index 2ae199f6..cea7685c 100644 --- a/src/models/transactions/escrowCreate.ts +++ b/src/models/transactions/escrowCreate.ts @@ -1,7 +1,7 @@ -/* eslint-disable complexity -- Necessary for verifyEscrowCreate */ +/* eslint-disable complexity -- Necessary for validateEscrowCreate */ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface EscrowCreate extends BaseTransaction { TransactionType: 'EscrowCreate' @@ -19,8 +19,8 @@ export interface EscrowCreate extends BaseTransaction { * @param tx - An EscrowCreate Transaction. * @throws When the EscrowCreate is Malformed. */ -export function verifyEscrowCreate(tx: Record): void { - verifyBaseTransaction(tx) +export function validateEscrowCreate(tx: Record): void { + validateBaseTransaction(tx) if (tx.Amount === undefined) { throw new ValidationError('EscrowCreate: missing field Amount') diff --git a/src/models/transactions/escrowFinish.ts b/src/models/transactions/escrowFinish.ts index b8f1eccb..ad6c56cb 100644 --- a/src/models/transactions/escrowFinish.ts +++ b/src/models/transactions/escrowFinish.ts @@ -1,6 +1,6 @@ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface EscrowFinish extends BaseTransaction { TransactionType: 'EscrowFinish' @@ -16,8 +16,8 @@ export interface EscrowFinish extends BaseTransaction { * @param tx - An EscrowFinish Transaction. * @throws When the EscrowFinish is Malformed. */ -export function verifyEscrowFinish(tx: Record): void { - verifyBaseTransaction(tx) +export function validateEscrowFinish(tx: Record): void { + validateBaseTransaction(tx) if (tx.Owner === undefined) { throw new ValidationError('EscrowFinish: missing field Owner') diff --git a/src/models/transactions/index.ts b/src/models/transactions/index.ts index 7c7f6ead..50c8bc3c 100644 --- a/src/models/transactions/index.ts +++ b/src/models/transactions/index.ts @@ -1,11 +1,11 @@ -/* eslint-disable import/no-unused-modules -- Needs to export all types + verify methods */ -/* eslint-disable import/max-dependencies -- Needs to export all types + verify methods */ +/* eslint-disable import/no-unused-modules -- Needs to export all types + validate methods */ +/* eslint-disable import/max-dependencies -- Needs to export all types + validate methods */ // TODO: replace * imports with direct imports export * from './transaction' export { AccountSetFlagsInterface, AccountSet, - verifyAccountSet, + validateAccountSet, } from './accountSet' export * from './accountDelete' export * from './checkCancel' @@ -19,17 +19,17 @@ export * from './offerCancel' export { OfferCreateFlagsInterface, OfferCreate, - verifyOfferCreate, + validateOfferCreate, } from './offerCreate' -export { PaymentFlagsInterface, Payment, verifyPayment } from './payment' +export { PaymentFlagsInterface, Payment, validatePayment } from './payment' export { PaymentChannelClaimFlagsInterface, PaymentChannelClaim, - verifyPaymentChannelClaim, + validatePaymentChannelClaim, } from './paymentChannelClaim' export * from './paymentChannelCreate' export * from './paymentChannelFund' export * from './setRegularKey' export * from './signerListSet' export * from './ticketCreate' -export { TrustSetFlagsInterface, TrustSet, verifyTrustSet } from './trustSet' +export { TrustSetFlagsInterface, TrustSet, validateTrustSet } from './trustSet' diff --git a/src/models/transactions/offerCancel.ts b/src/models/transactions/offerCancel.ts index f0c7f85b..bfe64299 100644 --- a/src/models/transactions/offerCancel.ts +++ b/src/models/transactions/offerCancel.ts @@ -1,6 +1,6 @@ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface OfferCancel extends BaseTransaction { TransactionType: 'OfferCancel' @@ -13,8 +13,8 @@ export interface OfferCancel extends BaseTransaction { * @param tx - An OfferCancel Transaction. * @throws When the OfferCancel is Malformed. */ -export function verifyOfferCancel(tx: Record): void { - verifyBaseTransaction(tx) +export function validateOfferCancel(tx: Record): void { + validateBaseTransaction(tx) if (tx.OfferSequence === undefined) { throw new ValidationError('OfferCancel: missing field OfferSequence') diff --git a/src/models/transactions/offerCreate.ts b/src/models/transactions/offerCreate.ts index 8585aa47..a350034e 100644 --- a/src/models/transactions/offerCreate.ts +++ b/src/models/transactions/offerCreate.ts @@ -1,11 +1,11 @@ -/* eslint-disable complexity -- Necessary for verifyOfferCreate */ +/* eslint-disable complexity -- Necessary for validateOfferCreate */ import { ValidationError } from '../../common/errors' import { Amount } from '../common' import { BaseTransaction, GlobalFlags, - verifyBaseTransaction, + validateBaseTransaction, isAmount, } from './common' @@ -39,8 +39,8 @@ export interface OfferCreate extends BaseTransaction { * @param tx - An OfferCreate Transaction. * @throws When the OfferCreate is Malformed. */ -export function verifyOfferCreate(tx: Record): void { - verifyBaseTransaction(tx) +export function validateOfferCreate(tx: Record): void { + validateBaseTransaction(tx) if (tx.TakerGets === undefined) { throw new ValidationError('OfferCreate: missing field TakerGets') diff --git a/src/models/transactions/payment.ts b/src/models/transactions/payment.ts index b4f2c9c9..caff8da0 100644 --- a/src/models/transactions/payment.ts +++ b/src/models/transactions/payment.ts @@ -1,5 +1,5 @@ -/* eslint-disable max-statements -- Necessary for verifyPayment */ -/* eslint-disable complexity -- Necessary for verifyPayment */ +/* eslint-disable max-statements -- Necessary for validatePayment */ +/* eslint-disable complexity -- Necessary for validatePayment */ import { ValidationError } from '../../common/errors' import { Amount, Path } from '../common' import { isFlagEnabled } from '../utils' @@ -8,7 +8,7 @@ import { BaseTransaction, isAmount, GlobalFlags, - verifyBaseTransaction, + validateBaseTransaction, } from './common' export enum PaymentTransactionFlags { @@ -40,8 +40,8 @@ export interface Payment extends BaseTransaction { * @param tx - A Payment Transaction. * @throws When the Payment is malformed. */ -export function verifyPayment(tx: Record): void { - verifyBaseTransaction(tx) +export function validatePayment(tx: Record): void { + validateBaseTransaction(tx) if (tx.Amount === undefined) { throw new ValidationError('PaymentTransaction: missing field Amount') diff --git a/src/models/transactions/paymentChannelClaim.ts b/src/models/transactions/paymentChannelClaim.ts index 81b4f552..596d1e95 100644 --- a/src/models/transactions/paymentChannelClaim.ts +++ b/src/models/transactions/paymentChannelClaim.ts @@ -1,7 +1,7 @@ -/* eslint-disable complexity -- Necessary for verifyPaymentChannelClaim */ +/* eslint-disable complexity -- Necessary for validatePaymentChannelClaim */ import { ValidationError } from '../../common/errors' -import { BaseTransaction, GlobalFlags, verifyBaseTransaction } from './common' +import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common' export enum PaymentChannelClaimTransactionFlags { tfRenew = 0x00010000, @@ -29,8 +29,8 @@ export interface PaymentChannelClaim extends BaseTransaction { * @param tx - An PaymentChannelClaim Transaction. * @throws When the PaymentChannelClaim is Malformed. */ -export function verifyPaymentChannelClaim(tx: Record): void { - verifyBaseTransaction(tx) +export function validatePaymentChannelClaim(tx: Record): void { + validateBaseTransaction(tx) if (tx.Channel === undefined) { throw new ValidationError('PaymentChannelClaim: missing Channel') diff --git a/src/models/transactions/paymentChannelCreate.ts b/src/models/transactions/paymentChannelCreate.ts index 1ddabdfb..c6405865 100644 --- a/src/models/transactions/paymentChannelCreate.ts +++ b/src/models/transactions/paymentChannelCreate.ts @@ -1,7 +1,7 @@ -/* eslint-disable complexity -- Necessary for verifyPaymentChannelCreate */ +/* eslint-disable complexity -- Necessary for validatePaymentChannelCreate */ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface PaymentChannelCreate extends BaseTransaction { TransactionType: 'PaymentChannelCreate' @@ -19,8 +19,10 @@ export interface PaymentChannelCreate extends BaseTransaction { * @param tx - An PaymentChannelCreate Transaction. * @throws When the PaymentChannelCreate is Malformed. */ -export function verifyPaymentChannelCreate(tx: Record): void { - verifyBaseTransaction(tx) +export function validatePaymentChannelCreate( + tx: Record, +): void { + validateBaseTransaction(tx) if (tx.Amount === undefined) { throw new ValidationError('PaymentChannelCreate: missing Amount') diff --git a/src/models/transactions/paymentChannelFund.ts b/src/models/transactions/paymentChannelFund.ts index abbddbf5..026c3dff 100644 --- a/src/models/transactions/paymentChannelFund.ts +++ b/src/models/transactions/paymentChannelFund.ts @@ -1,6 +1,6 @@ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface PaymentChannelFund extends BaseTransaction { TransactionType: 'PaymentChannelFund' @@ -15,8 +15,8 @@ export interface PaymentChannelFund extends BaseTransaction { * @param tx - An PaymentChannelFund Transaction. * @throws When the PaymentChannelFund is Malformed. */ -export function verifyPaymentChannelFund(tx: Record): void { - verifyBaseTransaction(tx) +export function validatePaymentChannelFund(tx: Record): void { + validateBaseTransaction(tx) if (tx.Channel === undefined) { throw new ValidationError('PaymentChannelFund: missing Channel') diff --git a/src/models/transactions/setRegularKey.ts b/src/models/transactions/setRegularKey.ts index 17124aa4..9b9b25e8 100644 --- a/src/models/transactions/setRegularKey.ts +++ b/src/models/transactions/setRegularKey.ts @@ -1,6 +1,6 @@ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface SetRegularKey extends BaseTransaction { TransactionType: 'SetRegularKey' @@ -13,8 +13,8 @@ export interface SetRegularKey extends BaseTransaction { * @param tx - A SetRegularKey Transaction. * @throws When the SetRegularKey is malformed. */ -export function verifySetRegularKey(tx: Record): void { - verifyBaseTransaction(tx) +export function validateSetRegularKey(tx: Record): void { + validateBaseTransaction(tx) if (tx.RegularKey !== undefined && typeof tx.RegularKey !== 'string') { throw new ValidationError('SetRegularKey: RegularKey must be a string') diff --git a/src/models/transactions/signerListSet.ts b/src/models/transactions/signerListSet.ts index cebbfa31..8a9a277c 100644 --- a/src/models/transactions/signerListSet.ts +++ b/src/models/transactions/signerListSet.ts @@ -1,7 +1,7 @@ import { ValidationError } from '../../common/errors' import { SignerEntry } from '../common' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface SignerListSet extends BaseTransaction { TransactionType: 'SignerListSet' @@ -17,8 +17,8 @@ const MAX_SIGNERS = 8 * @param tx - An SignerListSet Transaction. * @throws When the SignerListSet is Malformed. */ -export function verifySignerListSet(tx: Record): void { - verifyBaseTransaction(tx) +export function validateSignerListSet(tx: Record): void { + validateBaseTransaction(tx) if (tx.SignerQuorum === undefined) { throw new ValidationError('SignerListSet: missing field SignerQuorum') diff --git a/src/models/transactions/ticketCreate.ts b/src/models/transactions/ticketCreate.ts index fd83da07..0f5388b5 100644 --- a/src/models/transactions/ticketCreate.ts +++ b/src/models/transactions/ticketCreate.ts @@ -1,6 +1,6 @@ import { ValidationError } from '../../common/errors' -import { BaseTransaction, verifyBaseTransaction } from './common' +import { BaseTransaction, validateBaseTransaction } from './common' export interface TicketCreate extends BaseTransaction { TransactionType: 'TicketCreate' @@ -15,8 +15,8 @@ const MAX_TICKETS = 250 * @param tx - A TicketCreate Transaction. * @throws When the TicketCreate is malformed. */ -export function verifyTicketCreate(tx: Record): void { - verifyBaseTransaction(tx) +export function validateTicketCreate(tx: Record): void { + validateBaseTransaction(tx) const { TicketCount } = tx if (TicketCount === undefined) { diff --git a/src/models/transactions/transaction.ts b/src/models/transactions/transaction.ts index d199d7b9..205bfb80 100644 --- a/src/models/transactions/transaction.ts +++ b/src/models/transactions/transaction.ts @@ -7,45 +7,49 @@ import { encode, decode } from 'ripple-binary-codec' import { ValidationError } from '../../common/errors' import { setTransactionFlagsToNumber } from '../utils' -import { AccountDelete, verifyAccountDelete } from './accountDelete' +import { AccountDelete, validateAccountDelete } from './accountDelete' import { AccountSet, - verifyAccountSet, + validateAccountSet, AccountSetFlags, AccountSetTransactionFlags, } from './accountSet' -import { CheckCancel, verifyCheckCancel } from './checkCancel' -import { CheckCash, verifyCheckCash } from './checkCash' -import { CheckCreate, verifyCheckCreate } from './checkCreate' -import { DepositPreauth, verifyDepositPreauth } from './depositPreauth' -import { EscrowCancel, verifyEscrowCancel } from './escrowCancel' -import { EscrowCreate, verifyEscrowCreate } from './escrowCreate' -import { EscrowFinish, verifyEscrowFinish } from './escrowFinish' +import { CheckCancel, validateCheckCancel } from './checkCancel' +import { CheckCash, validateCheckCash } from './checkCash' +import { CheckCreate, validateCheckCreate } from './checkCreate' +import { DepositPreauth, validateDepositPreauth } from './depositPreauth' +import { EscrowCancel, validateEscrowCancel } from './escrowCancel' +import { EscrowCreate, validateEscrowCreate } from './escrowCreate' +import { EscrowFinish, validateEscrowFinish } from './escrowFinish' import TransactionMetadata from './metadata' -import { OfferCancel, verifyOfferCancel } from './offerCancel' +import { OfferCancel, validateOfferCancel } from './offerCancel' import { OfferCreate, - verifyOfferCreate, + validateOfferCreate, OfferCreateTransactionFlags, } from './offerCreate' -import { Payment, verifyPayment, PaymentTransactionFlags } from './payment' +import { Payment, validatePayment, PaymentTransactionFlags } from './payment' import { PaymentChannelClaim, - verifyPaymentChannelClaim, + validatePaymentChannelClaim, PaymentChannelClaimTransactionFlags, } from './paymentChannelClaim' import { PaymentChannelCreate, - verifyPaymentChannelCreate, + validatePaymentChannelCreate, } from './paymentChannelCreate' import { PaymentChannelFund, - verifyPaymentChannelFund, + validatePaymentChannelFund, } from './paymentChannelFund' -import { SetRegularKey, verifySetRegularKey } from './setRegularKey' -import { SignerListSet, verifySignerListSet } from './signerListSet' -import { TicketCreate, verifyTicketCreate } from './ticketCreate' -import { TrustSet, verifyTrustSet, TrustSetTransactionFlags } from './trustSet' +import { SetRegularKey, validateSetRegularKey } from './setRegularKey' +import { SignerListSet, validateSignerListSet } from './signerListSet' +import { TicketCreate, validateTicketCreate } from './ticketCreate' +import { + TrustSet, + validateTrustSet, + TrustSetTransactionFlags, +} from './trustSet' export type Transaction = | AccountDelete @@ -80,84 +84,84 @@ export interface TransactionAndMetadata { * @param transaction - A Transaction. * @throws ValidationError When the Transaction is malformed. */ -export function verify(transaction: Record): void { +export function validate(transaction: Record): void { const tx = { ...transaction } setTransactionFlagsToNumber(tx as unknown as Transaction) switch (tx.TransactionType) { case 'AccountDelete': - verifyAccountDelete(tx) + validateAccountDelete(tx) break case 'AccountSet': - verifyAccountSet(tx) + validateAccountSet(tx) break case 'CheckCancel': - verifyCheckCancel(tx) + validateCheckCancel(tx) break case 'CheckCash': - verifyCheckCash(tx) + validateCheckCash(tx) break case 'CheckCreate': - verifyCheckCreate(tx) + validateCheckCreate(tx) break case 'DepositPreauth': - verifyDepositPreauth(tx) + validateDepositPreauth(tx) break case 'EscrowCancel': - verifyEscrowCancel(tx) + validateEscrowCancel(tx) break case 'EscrowCreate': - verifyEscrowCreate(tx) + validateEscrowCreate(tx) break case 'EscrowFinish': - verifyEscrowFinish(tx) + validateEscrowFinish(tx) break case 'OfferCancel': - verifyOfferCancel(tx) + validateOfferCancel(tx) break case 'OfferCreate': - verifyOfferCreate(tx) + validateOfferCreate(tx) break case 'Payment': - verifyPayment(tx) + validatePayment(tx) break case 'PaymentChannelClaim': - verifyPaymentChannelClaim(tx) + validatePaymentChannelClaim(tx) break case 'PaymentChannelCreate': - verifyPaymentChannelCreate(tx) + validatePaymentChannelCreate(tx) break case 'PaymentChannelFund': - verifyPaymentChannelFund(tx) + validatePaymentChannelFund(tx) break case 'SetRegularKey': - verifySetRegularKey(tx) + validateSetRegularKey(tx) break case 'SignerListSet': - verifySignerListSet(tx) + validateSignerListSet(tx) break case 'TicketCreate': - verifyTicketCreate(tx) + validateTicketCreate(tx) break case 'TrustSet': - verifyTrustSet(tx) + validateTrustSet(tx) break default: diff --git a/src/models/transactions/trustSet.ts b/src/models/transactions/trustSet.ts index a18dedbe..e8af0c49 100644 --- a/src/models/transactions/trustSet.ts +++ b/src/models/transactions/trustSet.ts @@ -5,7 +5,7 @@ import { BaseTransaction, GlobalFlags, isAmount, - verifyBaseTransaction, + validateBaseTransaction, } from './common' export enum TrustSetTransactionFlags { @@ -38,8 +38,8 @@ export interface TrustSet extends BaseTransaction { * @param tx - A TrustSet Transaction. * @throws When the TrustSet is malformed. */ -export function verifyTrustSet(tx: Record): void { - verifyBaseTransaction(tx) +export function validateTrustSet(tx: Record): void { + validateBaseTransaction(tx) const { LimitAmount, QualityIn, QualityOut } = tx if (LimitAmount === undefined) { diff --git a/src/wallet/signer.ts b/src/wallet/signer.ts index b76105ed..d0a09eef 100644 --- a/src/wallet/signer.ts +++ b/src/wallet/signer.ts @@ -12,7 +12,7 @@ import { sign as signWithKeypair, verify } from 'ripple-keypairs' import { ValidationError } from '../common/errors' import { Signer } from '../models/common' import { Transaction } from '../models/transactions' -import { verifyBaseTransaction } from '../models/transactions/common' +import { validateBaseTransaction } from '../models/transactions/common' import Wallet from '.' @@ -52,10 +52,10 @@ function multisign(transactions: Array): string { const tx: Transaction = getDecodedTransaction(txOrBlob) // This will throw a more clear error for JS users if any of the supplied transactions has incorrect formatting - // TODO: Replace this with verify() (The general validation function for all Transactions) - // , also make verify accept '| Transaction' to avoid type casting here. - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- verify does not accept Transaction type - verifyBaseTransaction(tx as unknown as Record) + // TODO: Replace this with validate() (The general validation function for all Transactions) + // also make validate accept '| Transaction' to avoid type casting here. + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- validate does not accept Transaction type + validateBaseTransaction(tx as unknown as Record) if (tx.Signers == null || tx.Signers.length === 0) { throw new ValidationError( "For multisigning all transactions must include a Signers field containing an array of signatures. You may have forgotten to pass the 'forMultisign' parameter when signing.", diff --git a/test/client/autofill.ts b/test/client/autofill.ts index 7e0404fc..ec887c65 100644 --- a/test/client/autofill.ts +++ b/test/client/autofill.ts @@ -1,11 +1,7 @@ import { assert } from 'chai' -import { - AccountDelete, - EscrowFinish, - Payment, - Transaction, -} from '../../src/models/transactions' +import { AccountDelete, EscrowFinish, Payment, Transaction } from 'xrpl-local' + import rippled from '../fixtures/rippled' import { setupClient, teardownClient } from '../setupClient' diff --git a/test/integration/integration.ts b/test/integration/integration.ts index 1c883bf3..6962bfa8 100644 --- a/test/integration/integration.ts +++ b/test/integration/integration.ts @@ -3,13 +3,11 @@ import assert from 'assert' import _ from 'lodash' import { decode } from 'ripple-binary-codec' -import { Client, Wallet } from 'xrpl-local' +import { Client, Wallet, Transaction } from 'xrpl-local' import { AccountSet, SignerListSet } from 'xrpl-local/models/transactions' import { convertStringToHex } from 'xrpl-local/utils' import { sign, multisign } from 'xrpl-local/wallet/signer' -import { Transaction } from '../../src/models/transactions' - import serverUrl from './serverUrl' import { setupClient, suiteClientSetup, teardownClient } from './setup' import { diff --git a/test/integration/utils.ts b/test/integration/utils.ts index 3651b175..f2b58ea7 100644 --- a/test/integration/utils.ts +++ b/test/integration/utils.ts @@ -5,7 +5,7 @@ import { decode } from 'ripple-binary-codec' import { Client, SubmitResponse, Wallet } from 'xrpl-local' import { - verifyPayment, + validatePayment, Payment, Transaction, } from 'xrpl-local/models/transactions' @@ -46,7 +46,7 @@ export async function fundAccount( Amount: '400000000', } const paymentTx = await client.autofill(payment) - verifyPayment(paymentTx) + validatePayment(paymentTx) const response = await submitTransaction(client, masterSecret, paymentTx) if (response.result.engine_result !== 'tesSUCCESS') { diff --git a/test/models/accountDelete.ts b/test/models/accountDelete.ts index c98f95e8..a7a517c6 100644 --- a/test/models/accountDelete.ts +++ b/test/models/accountDelete.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateAccountDelete, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyAccountDelete } from '../../src/models/transactions/accountDelete' - /** * AccountDelete Transaction Verification Testing. * @@ -22,7 +20,7 @@ describe('AccountDelete', function () { Flags: 2147483648, } as any - assert.doesNotThrow(() => verifyAccountDelete(validAccountDelete)) + assert.doesNotThrow(() => validateAccountDelete(validAccountDelete)) }) it(`throws w/ missing Destination`, function () { @@ -35,13 +33,13 @@ describe('AccountDelete', function () { } as any assert.throws( - () => verifyAccountDelete(invalidDestination), + () => validateAccountDelete(invalidDestination), ValidationError, 'AccountDelete: missing field Destination', ) assert.throws( - () => verify(invalidDestination), + () => validate(invalidDestination), ValidationError, 'AccountDelete: missing field Destination', ) @@ -58,12 +56,12 @@ describe('AccountDelete', function () { } as any assert.throws( - () => verifyAccountDelete(invalidDestination), + () => validateAccountDelete(invalidDestination), ValidationError, 'AccountDelete: invalid Destination', ) assert.throws( - () => verify(invalidDestination), + () => validate(invalidDestination), ValidationError, 'AccountDelete: invalid Destination', ) @@ -81,13 +79,13 @@ describe('AccountDelete', function () { } as any assert.throws( - () => verifyAccountDelete(invalidDestinationTag), + () => validateAccountDelete(invalidDestinationTag), ValidationError, 'AccountDelete: invalid DestinationTag', ) assert.throws( - () => verify(invalidDestinationTag), + () => validate(invalidDestinationTag), ValidationError, 'AccountDelete: invalid DestinationTag', ) diff --git a/test/models/accountSet.ts b/test/models/accountSet.ts index 6f3ce356..b8bd8bc8 100644 --- a/test/models/accountSet.ts +++ b/test/models/accountSet.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateAccountSet, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyAccountSet } from '../../src/models/transactions/accountSet' - /** * AccountSet Transaction Verification Testing. * @@ -27,20 +25,20 @@ describe('AccountSet', function () { }) it(`verifies valid AccountSet`, function () { - assert.doesNotThrow(() => verifyAccountSet(account)) - assert.doesNotThrow(() => verify(account)) + assert.doesNotThrow(() => validateAccountSet(account)) + assert.doesNotThrow(() => validate(account)) }) it(`throws w/ invalid SetFlag (out of range)`, function () { account.SetFlag = 12 assert.throws( - () => verifyAccountSet(account), + () => validateAccountSet(account), ValidationError, 'AccountSet: invalid SetFlag', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'AccountSet: invalid SetFlag', ) @@ -50,12 +48,12 @@ describe('AccountSet', function () { account.SetFlag = 'abc' assert.throws( - () => verifyAccountSet(account), + () => validateAccountSet(account), ValidationError, 'AccountSet: invalid SetFlag', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'AccountSet: invalid SetFlag', ) @@ -65,12 +63,12 @@ describe('AccountSet', function () { account.ClearFlag = 12 assert.throws( - () => verifyAccountSet(account), + () => validateAccountSet(account), ValidationError, 'AccountSet: invalid ClearFlag', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'AccountSet: invalid ClearFlag', ) @@ -80,12 +78,12 @@ describe('AccountSet', function () { account.Domain = 6578616 assert.throws( - () => verifyAccountSet(account), + () => validateAccountSet(account), ValidationError, 'AccountSet: invalid Domain', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'AccountSet: invalid Domain', ) @@ -95,12 +93,12 @@ describe('AccountSet', function () { account.EmailHash = 6578656789876543 assert.throws( - () => verifyAccountSet(account), + () => validateAccountSet(account), ValidationError, 'AccountSet: invalid EmailHash', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'AccountSet: invalid EmailHash', ) @@ -110,12 +108,12 @@ describe('AccountSet', function () { account.MessageKey = 6578656789876543 assert.throws( - () => verifyAccountSet(account), + () => validateAccountSet(account), ValidationError, 'AccountSet: invalid MessageKey', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'AccountSet: invalid MessageKey', ) @@ -125,12 +123,12 @@ describe('AccountSet', function () { account.TransferRate = '1000000001' assert.throws( - () => verifyAccountSet(account), + () => validateAccountSet(account), ValidationError, 'AccountSet: invalid TransferRate', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'AccountSet: invalid TransferRate', ) @@ -140,12 +138,12 @@ describe('AccountSet', function () { account.TickSize = 20 assert.throws( - () => verifyAccountSet(account), + () => validateAccountSet(account), ValidationError, 'AccountSet: invalid TickSize', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'AccountSet: invalid TickSize', ) diff --git a/test/models/baseTransaction.ts b/test/models/baseTransaction.ts index d054db76..26f905f7 100644 --- a/test/models/baseTransaction.ts +++ b/test/models/baseTransaction.ts @@ -1,8 +1,7 @@ import { assert } from 'chai' import { ValidationError } from 'xrpl-local/common/errors' - -import { verifyBaseTransaction } from '../../src/models/transactions/common' +import { validateBaseTransaction } from 'xrpl-local/models/transactions/common' /** * Transaction Verification Testing. @@ -57,7 +56,7 @@ describe('BaseTransaction', function () { '3045022100C6708538AE5A697895937C758E99A595B57A16393F370F11B8D4C032E80B532002207776A8E85BB9FAF460A92113B9C60F170CD964196B1F084E0DAB65BAEC368B66', } - assert.doesNotThrow(() => verifyBaseTransaction(txJson)) + assert.doesNotThrow(() => validateBaseTransaction(txJson)) }) it(`Verifies only required BaseTransaction`, function () { @@ -66,7 +65,7 @@ describe('BaseTransaction', function () { TransactionType: 'Payment', } - assert.doesNotThrow(() => verifyBaseTransaction(txJson)) + assert.doesNotThrow(() => validateBaseTransaction(txJson)) }) it(`Handles invalid Fee`, function () { @@ -77,7 +76,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidFee), + () => validateBaseTransaction(invalidFee), ValidationError, 'BaseTransaction: invalid Fee', ) @@ -91,7 +90,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidSeq), + () => validateBaseTransaction(invalidSeq), ValidationError, 'BaseTransaction: invalid Sequence', ) @@ -105,7 +104,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidID), + () => validateBaseTransaction(invalidID), ValidationError, 'BaseTransaction: invalid AccountTxnID', ) @@ -119,7 +118,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidLastLedgerSequence), + () => validateBaseTransaction(invalidLastLedgerSequence), ValidationError, 'BaseTransaction: invalid LastLedgerSequence', ) @@ -133,7 +132,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidSourceTag), + () => validateBaseTransaction(invalidSourceTag), ValidationError, 'BaseTransaction: invalid SourceTag', ) @@ -147,7 +146,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidSigningPubKey), + () => validateBaseTransaction(invalidSigningPubKey), ValidationError, 'BaseTransaction: invalid SigningPubKey', ) @@ -161,7 +160,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidTicketSequence), + () => validateBaseTransaction(invalidTicketSequence), ValidationError, 'BaseTransaction: invalid TicketSequence', ) @@ -175,7 +174,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidTxnSignature), + () => validateBaseTransaction(invalidTxnSignature), ValidationError, 'BaseTransaction: invalid TxnSignature', ) @@ -189,7 +188,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidSigners), + () => validateBaseTransaction(invalidSigners), ValidationError, 'BaseTransaction: invalid Signers', ) @@ -207,7 +206,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidSigners2), + () => validateBaseTransaction(invalidSigners2), ValidationError, 'BaseTransaction: invalid Signers', ) @@ -228,7 +227,7 @@ describe('BaseTransaction', function () { } as any assert.throws( - () => verifyBaseTransaction(invalidMemo), + () => validateBaseTransaction(invalidMemo), ValidationError, 'BaseTransaction: invalid Memos', ) diff --git a/test/models/checkCancel.ts b/test/models/checkCancel.ts index 70b2b503..aed98773 100644 --- a/test/models/checkCancel.ts +++ b/test/models/checkCancel.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateCheckCancel, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyCheckCancel } from '../../src/models/transactions/checkCancel' - /** * CheckCancel Transaction Verification Testing. * @@ -19,8 +17,8 @@ describe('CheckCancel', function () { '49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0', } as any - assert.doesNotThrow(() => verifyCheckCancel(validCheckCancel)) - assert.doesNotThrow(() => verify(validCheckCancel)) + assert.doesNotThrow(() => validateCheckCancel(validCheckCancel)) + assert.doesNotThrow(() => validate(validCheckCancel)) }) it(`throws w/ invalid CheckCancel`, function () { @@ -31,12 +29,12 @@ describe('CheckCancel', function () { } as any assert.throws( - () => verifyCheckCancel(invalidCheckID), + () => validateCheckCancel(invalidCheckID), ValidationError, 'CheckCancel: invalid CheckID', ) assert.throws( - () => verify(invalidCheckID), + () => validate(invalidCheckID), ValidationError, 'CheckCancel: invalid CheckID', ) diff --git a/test/models/checkCash.ts b/test/models/checkCash.ts index 1118c721..5a5b1ae5 100644 --- a/test/models/checkCash.ts +++ b/test/models/checkCash.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateCheckCash, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyCheckCash } from '../../src/models/transactions/checkCash' - /** * CheckCash Transaction Verification Testing. * @@ -21,8 +19,8 @@ describe('CheckCash', function () { Fee: '12', } as any - assert.doesNotThrow(() => verifyCheckCash(validCheckCash)) - assert.doesNotThrow(() => verify(validCheckCash)) + assert.doesNotThrow(() => validateCheckCash(validCheckCash)) + assert.doesNotThrow(() => validate(validCheckCash)) }) it(`throws w/ invalid CheckID`, function () { @@ -34,12 +32,12 @@ describe('CheckCash', function () { } as any assert.throws( - () => verifyCheckCash(invalidCheckID), + () => validateCheckCash(invalidCheckID), ValidationError, 'CheckCash: invalid CheckID', ) assert.throws( - () => verify(invalidCheckID), + () => validate(invalidCheckID), ValidationError, 'CheckCash: invalid CheckID', ) @@ -55,12 +53,12 @@ describe('CheckCash', function () { } as any assert.throws( - () => verifyCheckCash(invalidAmount), + () => validateCheckCash(invalidAmount), ValidationError, 'CheckCash: invalid Amount', ) assert.throws( - () => verify(invalidAmount), + () => validate(invalidAmount), ValidationError, 'CheckCash: invalid Amount', ) @@ -77,12 +75,12 @@ describe('CheckCash', function () { } as any assert.throws( - () => verifyCheckCash(invalidDeliverMin), + () => validateCheckCash(invalidDeliverMin), ValidationError, 'CheckCash: cannot have both Amount and DeliverMin', ) assert.throws( - () => verify(invalidDeliverMin), + () => validate(invalidDeliverMin), ValidationError, 'CheckCash: cannot have both Amount and DeliverMin', ) @@ -98,12 +96,12 @@ describe('CheckCash', function () { } as any assert.throws( - () => verifyCheckCash(invalidDeliverMin), + () => validateCheckCash(invalidDeliverMin), ValidationError, 'CheckCash: invalid DeliverMin', ) assert.throws( - () => verify(invalidDeliverMin), + () => validate(invalidDeliverMin), ValidationError, 'CheckCash: invalid DeliverMin', ) diff --git a/test/models/checkCreate.ts b/test/models/checkCreate.ts index 84bbfadd..ae37cdbd 100644 --- a/test/models/checkCreate.ts +++ b/test/models/checkCreate.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateCheckCreate, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyCheckCreate } from '../../src/models/transactions/checkCreate' - /** * CheckCreate Transaction Verification Testing. * @@ -24,8 +22,8 @@ describe('CheckCreate', function () { Fee: '12', } as any - assert.doesNotThrow(() => verifyCheckCreate(validCheck)) - assert.doesNotThrow(() => verify(validCheck)) + assert.doesNotThrow(() => validateCheckCreate(validCheck)) + assert.doesNotThrow(() => validate(validCheck)) }) it(`throws w/ invalid Destination`, function () { @@ -42,12 +40,12 @@ describe('CheckCreate', function () { } as any assert.throws( - () => verifyCheckCreate(invalidDestination), + () => validateCheckCreate(invalidDestination), ValidationError, 'CheckCreate: invalid Destination', ) assert.throws( - () => verify(invalidDestination), + () => validate(invalidDestination), ValidationError, 'CheckCreate: invalid Destination', ) @@ -67,12 +65,12 @@ describe('CheckCreate', function () { } as any assert.throws( - () => verifyCheckCreate(invalidSendMax), + () => validateCheckCreate(invalidSendMax), ValidationError, 'CheckCreate: invalid SendMax', ) assert.throws( - () => verify(invalidSendMax), + () => validate(invalidSendMax), ValidationError, 'CheckCreate: invalid SendMax', ) @@ -92,12 +90,12 @@ describe('CheckCreate', function () { } as any assert.throws( - () => verifyCheckCreate(invalidDestinationTag), + () => validateCheckCreate(invalidDestinationTag), ValidationError, 'CheckCreate: invalid DestinationTag', ) assert.throws( - () => verify(invalidDestinationTag), + () => validate(invalidDestinationTag), ValidationError, 'CheckCreate: invalid DestinationTag', ) @@ -117,12 +115,12 @@ describe('CheckCreate', function () { } as any assert.throws( - () => verifyCheckCreate(invalidExpiration), + () => validateCheckCreate(invalidExpiration), ValidationError, 'CheckCreate: invalid Expiration', ) assert.throws( - () => verify(invalidExpiration), + () => validate(invalidExpiration), ValidationError, 'CheckCreate: invalid Expiration', ) @@ -141,12 +139,12 @@ describe('CheckCreate', function () { } as any assert.throws( - () => verifyCheckCreate(invalidInvoiceID), + () => validateCheckCreate(invalidInvoiceID), ValidationError, 'CheckCreate: invalid InvoiceID', ) assert.throws( - () => verify(invalidInvoiceID), + () => validate(invalidInvoiceID), ValidationError, 'CheckCreate: invalid InvoiceID', ) diff --git a/test/models/depositPreauth.ts b/test/models/depositPreauth.ts index 5e22868b..b9996e12 100644 --- a/test/models/depositPreauth.ts +++ b/test/models/depositPreauth.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateDepositPreauth, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyDepositPreauth } from '../../src/models/transactions/depositPreauth' - /** * DepositPreauth Transaction Verification Testing. * @@ -22,26 +20,26 @@ describe('DepositPreauth', function () { it('verifies valid DepositPreauth when only Authorize is provided', function () { depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW' - assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth)) - assert.doesNotThrow(() => verify(depositPreauth)) + assert.doesNotThrow(() => validateDepositPreauth(depositPreauth)) + assert.doesNotThrow(() => validate(depositPreauth)) }) it('verifies valid DepositPreauth when only Unauthorize is provided', function () { depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n' - assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth)) - assert.doesNotThrow(() => verify(depositPreauth)) + assert.doesNotThrow(() => validateDepositPreauth(depositPreauth)) + assert.doesNotThrow(() => validate(depositPreauth)) }) it('throws when both Authorize and Unauthorize are provided', function () { depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW' depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n' assert.throws( - () => verifyDepositPreauth(depositPreauth), + () => validateDepositPreauth(depositPreauth), ValidationError, "DepositPreauth: can't provide both Authorize and Unauthorize fields", ) assert.throws( - () => verify(depositPreauth), + () => validate(depositPreauth), ValidationError, "DepositPreauth: can't provide both Authorize and Unauthorize fields", ) @@ -49,12 +47,12 @@ describe('DepositPreauth', function () { it('throws when neither Authorize nor Unauthorize are provided', function () { assert.throws( - () => verifyDepositPreauth(depositPreauth), + () => validateDepositPreauth(depositPreauth), ValidationError, 'DepositPreauth: must provide either Authorize or Unauthorize field', ) assert.throws( - () => verify(depositPreauth), + () => validate(depositPreauth), ValidationError, 'DepositPreauth: must provide either Authorize or Unauthorize field', ) @@ -63,12 +61,12 @@ describe('DepositPreauth', function () { it('throws when Authorize is not a string', function () { depositPreauth.Authorize = 1234 assert.throws( - () => verifyDepositPreauth(depositPreauth), + () => validateDepositPreauth(depositPreauth), ValidationError, 'DepositPreauth: Authorize must be a string', ) assert.throws( - () => verify(depositPreauth), + () => validate(depositPreauth), ValidationError, 'DepositPreauth: Authorize must be a string', ) @@ -77,7 +75,7 @@ describe('DepositPreauth', function () { it('throws when an Account attempts to preauthorize its own address', function () { depositPreauth.Authorize = depositPreauth.Account assert.throws( - () => verifyDepositPreauth(depositPreauth), + () => validateDepositPreauth(depositPreauth), ValidationError, "DepositPreauth: Account can't preauthorize its own address", ) @@ -86,12 +84,12 @@ describe('DepositPreauth', function () { it('throws when Unauthorize is not a string', function () { depositPreauth.Unauthorize = 1234 assert.throws( - () => verifyDepositPreauth(depositPreauth), + () => validateDepositPreauth(depositPreauth), ValidationError, 'DepositPreauth: Unauthorize must be a string', ) assert.throws( - () => verify(depositPreauth), + () => validate(depositPreauth), ValidationError, 'DepositPreauth: Unauthorize must be a string', ) @@ -100,12 +98,12 @@ describe('DepositPreauth', function () { it('throws when an Account attempts to unauthorize its own address', function () { depositPreauth.Unauthorize = depositPreauth.Account assert.throws( - () => verifyDepositPreauth(depositPreauth), + () => validateDepositPreauth(depositPreauth), ValidationError, "DepositPreauth: Account can't unauthorize its own address", ) assert.throws( - () => verify(depositPreauth), + () => validate(depositPreauth), ValidationError, "DepositPreauth: Account can't unauthorize its own address", ) diff --git a/test/models/escrowCancel.ts b/test/models/escrowCancel.ts index b5a7648a..92b42001 100644 --- a/test/models/escrowCancel.ts +++ b/test/models/escrowCancel.ts @@ -1,8 +1,7 @@ import { assert } from 'chai' -import { ValidationError } from '../../src/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyEscrowCancel } from '../../src/models/transactions/escrowCancel' +import { validateEscrowCancel, validate } from 'xrpl-local' +import { ValidationError } from 'xrpl-local/common/errors' /** * Transaction Verification Testing. @@ -22,20 +21,20 @@ describe('EscrowCancel', function () { }) it(`Valid EscrowCancel`, function () { - assert.doesNotThrow(() => verifyEscrowCancel(cancel)) - assert.doesNotThrow(() => verify(cancel)) + assert.doesNotThrow(() => validateEscrowCancel(cancel)) + assert.doesNotThrow(() => validate(cancel)) }) it(`Invalid EscrowCancel missing owner`, function () { delete cancel.Owner assert.throws( - () => verifyEscrowCancel(cancel), + () => validateEscrowCancel(cancel), ValidationError, 'EscrowCancel: missing Owner', ) assert.throws( - () => verify(cancel), + () => validate(cancel), ValidationError, 'EscrowCancel: missing Owner', ) @@ -45,12 +44,12 @@ describe('EscrowCancel', function () { delete cancel.OfferSequence assert.throws( - () => verifyEscrowCancel(cancel), + () => validateEscrowCancel(cancel), ValidationError, 'EscrowCancel: missing OfferSequence', ) assert.throws( - () => verify(cancel), + () => validate(cancel), ValidationError, 'EscrowCancel: missing OfferSequence', ) @@ -60,12 +59,12 @@ describe('EscrowCancel', function () { cancel.Owner = 10 assert.throws( - () => verifyEscrowCancel(cancel), + () => validateEscrowCancel(cancel), ValidationError, 'EscrowCancel: Owner must be a string', ) assert.throws( - () => verify(cancel), + () => validate(cancel), ValidationError, 'EscrowCancel: Owner must be a string', ) @@ -75,12 +74,12 @@ describe('EscrowCancel', function () { cancel.OfferSequence = '10' assert.throws( - () => verifyEscrowCancel(cancel), + () => validateEscrowCancel(cancel), ValidationError, 'EscrowCancel: OfferSequence must be a number', ) assert.throws( - () => verify(cancel), + () => validate(cancel), ValidationError, 'EscrowCancel: OfferSequence must be a number', ) diff --git a/test/models/escrowCreate.ts b/test/models/escrowCreate.ts index eb57550d..52fc7e33 100644 --- a/test/models/escrowCreate.ts +++ b/test/models/escrowCreate.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateEscrowCreate, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyEscrowCreate } from '../../src/models/transactions/escrowCreate' - /** * EscrowCreate Transaction Verification Testing. * @@ -29,20 +27,20 @@ describe('EscrowCreate', function () { }) it(`verifies valid EscrowCreate`, function () { - assert.doesNotThrow(() => verifyEscrowCreate(escrow)) - assert.doesNotThrow(() => verify(escrow)) + assert.doesNotThrow(() => validateEscrowCreate(escrow)) + assert.doesNotThrow(() => validate(escrow)) }) it(`Missing amount`, function () { delete escrow.Amount assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: missing field Amount', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: missing field Amount', ) @@ -52,12 +50,12 @@ describe('EscrowCreate', function () { delete escrow.Destination assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: missing field Destination', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: missing field Destination', ) @@ -67,12 +65,12 @@ describe('EscrowCreate', function () { escrow.Destination = 10 assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: Destination must be a string', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: Destination must be a string', ) @@ -82,12 +80,12 @@ describe('EscrowCreate', function () { escrow.Amount = 1000 assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: Amount must be a string', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: Amount must be a string', ) @@ -97,12 +95,12 @@ describe('EscrowCreate', function () { escrow.CancelAfter = '100' assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: CancelAfter must be a number', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: CancelAfter must be a number', ) @@ -112,7 +110,7 @@ describe('EscrowCreate', function () { escrow.FinishAfter = '1000' assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: FinishAfter must be a number', ) @@ -122,12 +120,12 @@ describe('EscrowCreate', function () { escrow.Condition = 0x141243 assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: Condition must be a string', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: Condition must be a string', ) @@ -137,12 +135,12 @@ describe('EscrowCreate', function () { escrow.DestinationTag = '100' assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: DestinationTag must be a number', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: DestinationTag must be a number', ) @@ -153,12 +151,12 @@ describe('EscrowCreate', function () { delete escrow.FinishAfter assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: Either CancelAfter or FinishAfter must be specified', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: Either CancelAfter or FinishAfter must be specified', ) @@ -169,12 +167,12 @@ describe('EscrowCreate', function () { delete escrow.FinishAfter assert.throws( - () => verifyEscrowCreate(escrow), + () => validateEscrowCreate(escrow), ValidationError, 'EscrowCreate: Either Condition or FinishAfter must be specified', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowCreate: Either Condition or FinishAfter must be specified', ) diff --git a/test/models/escrowFinish.ts b/test/models/escrowFinish.ts index 3f06693b..d83e27d0 100644 --- a/test/models/escrowFinish.ts +++ b/test/models/escrowFinish.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateEscrowFinish, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyEscrowFinish } from '../../src/models/transactions/escrowFinish' - /** * EscrowFinish Transaction Verification Testing. * @@ -25,28 +23,28 @@ describe('EscrowFinish', function () { } }) it(`verifies valid EscrowFinish`, function () { - assert.doesNotThrow(() => verifyEscrowFinish(escrow)) - assert.doesNotThrow(() => verify(escrow)) + assert.doesNotThrow(() => validateEscrowFinish(escrow)) + assert.doesNotThrow(() => validate(escrow)) }) it(`verifies valid EscrowFinish w/o optional`, function () { delete escrow.Condition delete escrow.Fulfillment - assert.doesNotThrow(() => verifyEscrowFinish(escrow)) - assert.doesNotThrow(() => verify(escrow)) + assert.doesNotThrow(() => validateEscrowFinish(escrow)) + assert.doesNotThrow(() => validate(escrow)) }) it(`throws w/ invalid Owner`, function () { escrow.Owner = 0x15415253 assert.throws( - () => verifyEscrowFinish(escrow), + () => validateEscrowFinish(escrow), ValidationError, 'EscrowFinish: Owner must be a string', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowFinish: Owner must be a string', ) @@ -56,12 +54,12 @@ describe('EscrowFinish', function () { escrow.OfferSequence = '10' assert.throws( - () => verifyEscrowFinish(escrow), + () => validateEscrowFinish(escrow), ValidationError, 'EscrowFinish: OfferSequence must be a number', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowFinish: OfferSequence must be a number', ) @@ -71,12 +69,12 @@ describe('EscrowFinish', function () { escrow.Condition = 10 assert.throws( - () => verifyEscrowFinish(escrow), + () => validateEscrowFinish(escrow), ValidationError, 'EscrowFinish: Condition must be a string', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowFinish: Condition must be a string', ) @@ -86,12 +84,12 @@ describe('EscrowFinish', function () { escrow.Fulfillment = 0x142341 assert.throws( - () => verifyEscrowFinish(escrow), + () => validateEscrowFinish(escrow), ValidationError, 'EscrowFinish: Fulfillment must be a string', ) assert.throws( - () => verify(escrow), + () => validate(escrow), ValidationError, 'EscrowFinish: Fulfillment must be a string', ) diff --git a/test/models/offerCancel.ts b/test/models/offerCancel.ts index 6b97d9bd..3ef30eba 100644 --- a/test/models/offerCancel.ts +++ b/test/models/offerCancel.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateOfferCancel, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyOfferCancel } from '../../src/models/transactions/offerCancel' - /** * OfferCancel Transaction Verification Testing. * @@ -30,25 +28,25 @@ describe('OfferCancel', function () { }) it(`verifies valid OfferCancel`, function () { - assert.doesNotThrow(() => verifyOfferCancel(offer)) - assert.doesNotThrow(() => verify(offer)) + assert.doesNotThrow(() => validateOfferCancel(offer)) + assert.doesNotThrow(() => validate(offer)) }) it(`verifies valid OfferCancel with flags`, function () { offer.Flags = 2147483648 - assert.doesNotThrow(() => verifyOfferCancel(offer)) - assert.doesNotThrow(() => verify(offer)) + assert.doesNotThrow(() => validateOfferCancel(offer)) + assert.doesNotThrow(() => validate(offer)) }) it(`throws w/ OfferSequence must be a number`, function () { offer.OfferSequence = '99' assert.throws( - () => verifyOfferCancel(offer), + () => validateOfferCancel(offer), ValidationError, 'OfferCancel: OfferSequence must be a number', ) assert.throws( - () => verify(offer), + () => validate(offer), ValidationError, 'OfferCancel: OfferSequence must be a number', ) @@ -57,12 +55,12 @@ describe('OfferCancel', function () { it(`throws w/ missing OfferSequence`, function () { delete offer.OfferSequence assert.throws( - () => verifyOfferCancel(offer), + () => validateOfferCancel(offer), ValidationError, 'OfferCancel: missing field OfferSequence', ) assert.throws( - () => verify(offer), + () => validate(offer), ValidationError, 'OfferCancel: missing field OfferSequence', ) diff --git a/test/models/offerCreate.ts b/test/models/offerCreate.ts index 543efa5b..31d068f8 100644 --- a/test/models/offerCreate.ts +++ b/test/models/offerCreate.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateOfferCreate, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyOfferCreate } from '../../src/models/transactions/offerCreate' - /** * OfferCreate Transaction Verification Testing. * @@ -33,8 +31,8 @@ describe('OfferCreate', function () { '3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91', } as any - assert.doesNotThrow(() => verifyOfferCreate(offer)) - assert.doesNotThrow(() => verify(offer)) + assert.doesNotThrow(() => validateOfferCreate(offer)) + assert.doesNotThrow(() => validate(offer)) const offer2 = { Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W', @@ -55,8 +53,8 @@ describe('OfferCreate', function () { '3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91', } as any - assert.doesNotThrow(() => verifyOfferCreate(offer2)) - assert.doesNotThrow(() => verify(offer2)) + assert.doesNotThrow(() => validateOfferCreate(offer2)) + assert.doesNotThrow(() => validate(offer2)) const offer3 = { Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W', @@ -81,8 +79,8 @@ describe('OfferCreate', function () { '3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91', } as any - assert.doesNotThrow(() => verifyOfferCreate(offer3)) - assert.doesNotThrow(() => verify(offer3)) + assert.doesNotThrow(() => validateOfferCreate(offer3)) + assert.doesNotThrow(() => validate(offer3)) }) it(`throws w/ invalid Expiration`, function () { @@ -107,12 +105,12 @@ describe('OfferCreate', function () { } as any assert.throws( - () => verifyOfferCreate(offer), + () => validateOfferCreate(offer), ValidationError, 'OfferCreate: invalid Expiration', ) assert.throws( - () => verify(offer), + () => validate(offer), ValidationError, 'OfferCreate: invalid Expiration', ) @@ -140,12 +138,12 @@ describe('OfferCreate', function () { } as any assert.throws( - () => verifyOfferCreate(offer), + () => validateOfferCreate(offer), ValidationError, 'OfferCreate: invalid OfferSequence', ) assert.throws( - () => verify(offer), + () => validate(offer), ValidationError, 'OfferCreate: invalid OfferSequence', ) @@ -169,12 +167,12 @@ describe('OfferCreate', function () { } as any assert.throws( - () => verifyOfferCreate(offer), + () => validateOfferCreate(offer), ValidationError, 'OfferCreate: invalid TakerPays', ) assert.throws( - () => verify(offer), + () => validate(offer), ValidationError, 'OfferCreate: invalid TakerPays', ) @@ -202,12 +200,12 @@ describe('OfferCreate', function () { } as any assert.throws( - () => verifyOfferCreate(offer), + () => validateOfferCreate(offer), ValidationError, 'OfferCreate: invalid TakerGets', ) assert.throws( - () => verify(offer), + () => validate(offer), ValidationError, 'OfferCreate: invalid TakerGets', ) diff --git a/test/models/payment.ts b/test/models/payment.ts index 5edfcaf0..f6461565 100644 --- a/test/models/payment.ts +++ b/test/models/payment.ts @@ -1,13 +1,8 @@ import { assert } from 'chai' +import { validatePayment, validate, PaymentTransactionFlags } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { - verifyPayment, - verify, - PaymentTransactionFlags, -} from '../../src/models/transactions' - /** * PaymentTransaction Verification Testing. * @@ -41,19 +36,19 @@ describe('Payment', function () { }) it(`verifies valid PaymentTransaction`, function () { - assert.doesNotThrow(() => verifyPayment(paymentTransaction)) - assert.doesNotThrow(() => verify(paymentTransaction)) + assert.doesNotThrow(() => validatePayment(paymentTransaction)) + assert.doesNotThrow(() => validate(paymentTransaction)) }) it(`throws when Amount is missing`, function () { delete paymentTransaction.Amount assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: missing field Amount', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: missing field Amount', ) @@ -62,12 +57,12 @@ describe('Payment', function () { it(`throws when Amount is invalid`, function () { paymentTransaction.Amount = 1234 assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: invalid Amount', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: invalid Amount', ) @@ -76,12 +71,12 @@ describe('Payment', function () { it(`throws when Destination is missing`, function () { delete paymentTransaction.Destination assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: missing field Destination', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: missing field Destination', ) @@ -90,12 +85,12 @@ describe('Payment', function () { it(`throws when Destination is invalid`, function () { paymentTransaction.Destination = 7896214 assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: invalid Destination', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: invalid Destination', ) @@ -104,12 +99,12 @@ describe('Payment', function () { it(`throws when DestinationTag is not a number`, function () { paymentTransaction.DestinationTag = '1' assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: DestinationTag must be a number', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: DestinationTag must be a number', ) @@ -118,12 +113,12 @@ describe('Payment', function () { it(`throws when InvoiceID is not a string`, function () { paymentTransaction.InvoiceID = 19832 assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: InvoiceID must be a string', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: InvoiceID must be a string', ) @@ -132,12 +127,12 @@ describe('Payment', function () { it(`throws when Paths is invalid`, function () { paymentTransaction.Paths = [[{ account: 123 }]] assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: invalid Paths', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: invalid Paths', ) @@ -146,12 +141,12 @@ describe('Payment', function () { it(`throws when SendMax is invalid`, function () { paymentTransaction.SendMax = 100000000 assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: invalid SendMax', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: invalid SendMax', ) @@ -160,27 +155,27 @@ describe('Payment', function () { it(`verifies valid DeliverMin with tfPartialPayment flag set as a number`, function () { paymentTransaction.DeliverMin = '10000' paymentTransaction.Flags = PaymentTransactionFlags.tfPartialPayment - assert.doesNotThrow(() => verifyPayment(paymentTransaction)) - assert.doesNotThrow(() => verify(paymentTransaction)) + assert.doesNotThrow(() => validatePayment(paymentTransaction)) + assert.doesNotThrow(() => validate(paymentTransaction)) }) it(`verifies valid DeliverMin with tfPartialPayment flag set as a boolean`, function () { paymentTransaction.DeliverMin = '10000' paymentTransaction.Flags = { tfPartialPayment: true } - assert.doesNotThrow(() => verifyPayment(paymentTransaction)) - assert.doesNotThrow(() => verify(paymentTransaction)) + assert.doesNotThrow(() => validatePayment(paymentTransaction)) + assert.doesNotThrow(() => validate(paymentTransaction)) }) it(`throws when DeliverMin is invalid`, function () { paymentTransaction.DeliverMin = 10000 paymentTransaction.Flags = { tfPartialPayment: true } assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: invalid DeliverMin', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: invalid DeliverMin', ) @@ -189,12 +184,12 @@ describe('Payment', function () { it(`throws when tfPartialPayment flag is missing with valid DeliverMin`, function () { paymentTransaction.DeliverMin = '10000' assert.throws( - () => verifyPayment(paymentTransaction), + () => validatePayment(paymentTransaction), ValidationError, 'PaymentTransaction: tfPartialPayment flag required with DeliverMin', ) assert.throws( - () => verify(paymentTransaction), + () => validate(paymentTransaction), ValidationError, 'PaymentTransaction: tfPartialPayment flag required with DeliverMin', ) diff --git a/test/models/paymentChannelClaim.ts b/test/models/paymentChannelClaim.ts index 67874b9e..ee6aa247 100644 --- a/test/models/paymentChannelClaim.ts +++ b/test/models/paymentChannelClaim.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validatePaymentChannelClaim, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyPaymentChannelClaim } from '../../src/models/transactions/paymentChannelClaim' - /** * PaymentChannelClaim Transaction Verification Testing. * @@ -29,8 +27,8 @@ describe('PaymentChannelClaim', function () { }) it(`verifies valid PaymentChannelClaim`, function () { - assert.doesNotThrow(() => verifyPaymentChannelClaim(channel)) - assert.doesNotThrow(() => verify(channel)) + assert.doesNotThrow(() => validatePaymentChannelClaim(channel)) + assert.doesNotThrow(() => validate(channel)) }) it(`verifies valid PaymentChannelClaim w/o optional`, function () { @@ -39,20 +37,20 @@ describe('PaymentChannelClaim', function () { delete channel.Signature delete channel.PublicKey - assert.doesNotThrow(() => verifyPaymentChannelClaim(channel)) - assert.doesNotThrow(() => verify(channel)) + assert.doesNotThrow(() => validatePaymentChannelClaim(channel)) + assert.doesNotThrow(() => validate(channel)) }) it(`throws w/ missing Channel`, function () { delete channel.Channel assert.throws( - () => verifyPaymentChannelClaim(channel), + () => validatePaymentChannelClaim(channel), ValidationError, 'PaymentChannelClaim: missing Channel', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelClaim: missing Channel', ) @@ -62,12 +60,12 @@ describe('PaymentChannelClaim', function () { channel.Channel = 100 assert.throws( - () => verifyPaymentChannelClaim(channel), + () => validatePaymentChannelClaim(channel), ValidationError, 'PaymentChannelClaim: Channel must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelClaim: Channel must be a string', ) @@ -77,12 +75,12 @@ describe('PaymentChannelClaim', function () { channel.Balance = 100 assert.throws( - () => verifyPaymentChannelClaim(channel), + () => validatePaymentChannelClaim(channel), ValidationError, 'PaymentChannelClaim: Balance must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelClaim: Balance must be a string', ) @@ -92,12 +90,12 @@ describe('PaymentChannelClaim', function () { channel.Amount = 1000 assert.throws( - () => verifyPaymentChannelClaim(channel), + () => validatePaymentChannelClaim(channel), ValidationError, 'PaymentChannelClaim: Amount must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelClaim: Amount must be a string', ) @@ -107,12 +105,12 @@ describe('PaymentChannelClaim', function () { channel.Signature = 1000 assert.throws( - () => verifyPaymentChannelClaim(channel), + () => validatePaymentChannelClaim(channel), ValidationError, 'PaymentChannelClaim: Signature must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelClaim: Signature must be a string', ) @@ -122,12 +120,12 @@ describe('PaymentChannelClaim', function () { channel.PublicKey = ['100000'] assert.throws( - () => verifyPaymentChannelClaim(channel), + () => validatePaymentChannelClaim(channel), ValidationError, 'PaymentChannelClaim: PublicKey must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelClaim: PublicKey must be a string', ) diff --git a/test/models/paymentChannelCreate.ts b/test/models/paymentChannelCreate.ts index 3a400476..7e1cdf3c 100644 --- a/test/models/paymentChannelCreate.ts +++ b/test/models/paymentChannelCreate.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validatePaymentChannelCreate, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyPaymentChannelCreate } from '../../src/models/transactions/paymentChannelCreate' - /** * PaymentChannelCreate Transaction Verification Testing. * @@ -29,8 +27,8 @@ describe('PaymentChannelCreate', function () { }) it(`verifies valid PaymentChannelCreate`, function () { - assert.doesNotThrow(() => verifyPaymentChannelCreate(channel)) - assert.doesNotThrow(() => verify(channel)) + assert.doesNotThrow(() => validatePaymentChannelCreate(channel)) + assert.doesNotThrow(() => validate(channel)) }) it(`verifies valid PaymentChannelCreate w/o optional`, function () { @@ -38,20 +36,20 @@ describe('PaymentChannelCreate', function () { delete channel.DestinationTag delete channel.SourceTag - assert.doesNotThrow(() => verifyPaymentChannelCreate(channel)) - assert.doesNotThrow(() => verify(channel)) + assert.doesNotThrow(() => validatePaymentChannelCreate(channel)) + assert.doesNotThrow(() => validate(channel)) }) it(`missing Amount`, function () { delete channel.Amount assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: missing Amount', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: missing Amount', ) @@ -61,12 +59,12 @@ describe('PaymentChannelCreate', function () { delete channel.Destination assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: missing Destination', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: missing Destination', ) @@ -76,12 +74,12 @@ describe('PaymentChannelCreate', function () { delete channel.SettleDelay assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: missing SettleDelay', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: missing SettleDelay', ) @@ -91,12 +89,12 @@ describe('PaymentChannelCreate', function () { delete channel.PublicKey assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: missing PublicKey', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: missing PublicKey', ) @@ -106,12 +104,12 @@ describe('PaymentChannelCreate', function () { channel.Amount = 1000 assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: Amount must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: Amount must be a string', ) @@ -121,12 +119,12 @@ describe('PaymentChannelCreate', function () { channel.Destination = 10 assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: Destination must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: Destination must be a string', ) @@ -136,12 +134,12 @@ describe('PaymentChannelCreate', function () { channel.SettleDelay = '10' assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: SettleDelay must be a number', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: SettleDelay must be a number', ) @@ -151,12 +149,12 @@ describe('PaymentChannelCreate', function () { channel.PublicKey = 10 assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: PublicKey must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: PublicKey must be a string', ) @@ -166,12 +164,12 @@ describe('PaymentChannelCreate', function () { channel.DestinationTag = '10' assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: DestinationTag must be a number', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: DestinationTag must be a number', ) @@ -181,12 +179,12 @@ describe('PaymentChannelCreate', function () { channel.CancelAfter = '100' assert.throws( - () => verifyPaymentChannelCreate(channel), + () => validatePaymentChannelCreate(channel), ValidationError, 'PaymentChannelCreate: CancelAfter must be a number', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelCreate: CancelAfter must be a number', ) diff --git a/test/models/paymentChannelFund.ts b/test/models/paymentChannelFund.ts index de30292a..44884a09 100644 --- a/test/models/paymentChannelFund.ts +++ b/test/models/paymentChannelFund.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validatePaymentChannelFund, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyPaymentChannelFund } from '../../src/models/transactions/paymentChannelFund' - /** * PaymentChannelFund Transaction Verification Testing. * @@ -25,27 +23,27 @@ describe('PaymentChannelFund', function () { }) it(`verifies valid PaymentChannelFund`, function () { - assert.doesNotThrow(() => verifyPaymentChannelFund(channel)) - assert.doesNotThrow(() => verify(channel)) + assert.doesNotThrow(() => validatePaymentChannelFund(channel)) + assert.doesNotThrow(() => validate(channel)) }) it(`verifies valid PaymentChannelFund w/o optional`, function () { delete channel.Expiration - assert.doesNotThrow(() => verifyPaymentChannelFund(channel)) - assert.doesNotThrow(() => verify(channel)) + assert.doesNotThrow(() => validatePaymentChannelFund(channel)) + assert.doesNotThrow(() => validate(channel)) }) it(`throws w/ missing Amount`, function () { delete channel.Amount assert.throws( - () => verifyPaymentChannelFund(channel), + () => validatePaymentChannelFund(channel), ValidationError, 'PaymentChannelFund: missing Amount', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelFund: missing Amount', ) @@ -55,12 +53,12 @@ describe('PaymentChannelFund', function () { delete channel.Channel assert.throws( - () => verifyPaymentChannelFund(channel), + () => validatePaymentChannelFund(channel), ValidationError, 'PaymentChannelFund: missing Channel', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelFund: missing Channel', ) @@ -70,12 +68,12 @@ describe('PaymentChannelFund', function () { channel.Amount = 100 assert.throws( - () => verifyPaymentChannelFund(channel), + () => validatePaymentChannelFund(channel), ValidationError, 'PaymentChannelFund: Amount must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelFund: Amount must be a string', ) @@ -85,12 +83,12 @@ describe('PaymentChannelFund', function () { channel.Channel = 1000 assert.throws( - () => verifyPaymentChannelFund(channel), + () => validatePaymentChannelFund(channel), ValidationError, 'PaymentChannelFund: Channel must be a string', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelFund: Channel must be a string', ) @@ -100,12 +98,12 @@ describe('PaymentChannelFund', function () { channel.Expiration = '1000' assert.throws( - () => verifyPaymentChannelFund(channel), + () => validatePaymentChannelFund(channel), ValidationError, 'PaymentChannelFund: Expiration must be a number', ) assert.throws( - () => verify(channel), + () => validate(channel), ValidationError, 'PaymentChannelFund: Expiration must be a number', ) diff --git a/test/models/setRegularKey.ts b/test/models/setRegularKey.ts index f9c1d761..0ae95079 100644 --- a/test/models/setRegularKey.ts +++ b/test/models/setRegularKey.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validate, validateSetRegularKey } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifySetRegularKey } from '../../src/models/transactions/setRegularKey' - /** * SetRegularKey Transaction Verification Testing. * @@ -24,26 +22,26 @@ describe('SetRegularKey', function () { }) it(`verifies valid SetRegularKey`, function () { - assert.doesNotThrow(() => verifySetRegularKey(account)) - assert.doesNotThrow(() => verify(account)) + assert.doesNotThrow(() => validateSetRegularKey(account)) + assert.doesNotThrow(() => validate(account)) }) it(`verifies w/o SetRegularKey`, function () { account.RegularKey = undefined - assert.doesNotThrow(() => verifySetRegularKey(account)) - assert.doesNotThrow(() => verify(account)) + assert.doesNotThrow(() => validateSetRegularKey(account)) + assert.doesNotThrow(() => validate(account)) }) it(`throws w/ invalid RegularKey`, function () { account.RegularKey = 12369846963 assert.throws( - () => verifySetRegularKey(account), + () => validateSetRegularKey(account), ValidationError, 'SetRegularKey: RegularKey must be a string', ) assert.throws( - () => verify(account), + () => validate(account), ValidationError, 'SetRegularKey: RegularKey must be a string', ) diff --git a/test/models/signerListSet.ts b/test/models/signerListSet.ts index 7c318507..3a75b79d 100644 --- a/test/models/signerListSet.ts +++ b/test/models/signerListSet.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validate, validateSignerListSet } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifySignerListSet } from '../../src/models/transactions/signerListSet' - /** * SignerListSet Transaction Verification Testing. * @@ -44,20 +42,20 @@ describe('SignerListSet', function () { }) it(`verifies valid SignerListSet`, function () { - assert.doesNotThrow(() => verifySignerListSet(signerListSetTx)) - assert.doesNotThrow(() => verify(signerListSetTx)) + assert.doesNotThrow(() => validateSignerListSet(signerListSetTx)) + assert.doesNotThrow(() => validate(signerListSetTx)) }) it(`throws w/ missing SignerQuorum`, function () { signerListSetTx.SignerQuorum = undefined assert.throws( - () => verifySignerListSet(signerListSetTx), + () => validateSignerListSet(signerListSetTx), ValidationError, 'SignerListSet: missing field SignerQuorum', ) assert.throws( - () => verify(signerListSetTx), + () => validate(signerListSetTx), ValidationError, 'SignerListSet: missing field SignerQuorum', ) @@ -67,12 +65,12 @@ describe('SignerListSet', function () { signerListSetTx.SignerEntries = [] assert.throws( - () => verifySignerListSet(signerListSetTx), + () => validateSignerListSet(signerListSetTx), ValidationError, 'SignerListSet: need atleast 1 member in SignerEntries', ) assert.throws( - () => verify(signerListSetTx), + () => validate(signerListSetTx), ValidationError, 'SignerListSet: need atleast 1 member in SignerEntries', ) @@ -82,12 +80,12 @@ describe('SignerListSet', function () { signerListSetTx.SignerEntries = 'khgfgyhujk' assert.throws( - () => verifySignerListSet(signerListSetTx), + () => validateSignerListSet(signerListSetTx), ValidationError, 'SignerListSet: invalid SignerEntries', ) assert.throws( - () => verify(signerListSetTx), + () => validate(signerListSetTx), ValidationError, 'SignerListSet: invalid SignerEntries', ) diff --git a/test/models/ticketCreate.ts b/test/models/ticketCreate.ts index 88e8ad4f..049c21f8 100644 --- a/test/models/ticketCreate.ts +++ b/test/models/ticketCreate.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateTicketCreate, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyTicketCreate } from '../../src/models/transactions/ticketCreate' - /** * TicketCreate Transaction Verification Testing. * @@ -22,19 +20,19 @@ describe('TicketCreate', function () { }) it('verifies valid TicketCreate', function () { - assert.doesNotThrow(() => verifyTicketCreate(ticketCreate)) - assert.doesNotThrow(() => verify(ticketCreate)) + assert.doesNotThrow(() => validateTicketCreate(ticketCreate)) + assert.doesNotThrow(() => validate(ticketCreate)) }) it('throws when TicketCount is missing', function () { delete ticketCreate.TicketCount assert.throws( - () => verifyTicketCreate(ticketCreate), + () => validateTicketCreate(ticketCreate), ValidationError, 'TicketCreate: missing field TicketCount', ) assert.throws( - () => verify(ticketCreate), + () => validate(ticketCreate), ValidationError, 'TicketCreate: missing field TicketCount', ) @@ -43,12 +41,12 @@ describe('TicketCreate', function () { it('throws when TicketCount is not a number', function () { ticketCreate.TicketCount = '150' assert.throws( - () => verifyTicketCreate(ticketCreate), + () => validateTicketCreate(ticketCreate), ValidationError, 'TicketCreate: TicketCount must be a number', ) assert.throws( - () => verify(ticketCreate), + () => validate(ticketCreate), ValidationError, 'TicketCreate: TicketCount must be a number', ) @@ -57,12 +55,12 @@ describe('TicketCreate', function () { it('throws when TicketCount is not an integer', function () { ticketCreate.TicketCount = 12.5 assert.throws( - () => verifyTicketCreate(ticketCreate), + () => validateTicketCreate(ticketCreate), ValidationError, 'TicketCreate: TicketCount must be an integer from 1 to 250', ) assert.throws( - () => verify(ticketCreate), + () => validate(ticketCreate), ValidationError, 'TicketCreate: TicketCount must be an integer from 1 to 250', ) @@ -71,12 +69,12 @@ describe('TicketCreate', function () { it('throws when TicketCount is < 1', function () { ticketCreate.TicketCount = 0 assert.throws( - () => verifyTicketCreate(ticketCreate), + () => validateTicketCreate(ticketCreate), ValidationError, 'TicketCreate: TicketCount must be an integer from 1 to 250', ) assert.throws( - () => verify(ticketCreate), + () => validate(ticketCreate), ValidationError, 'TicketCreate: TicketCount must be an integer from 1 to 250', ) @@ -85,12 +83,12 @@ describe('TicketCreate', function () { it('throws when TicketCount is > 250', function () { ticketCreate.TicketCount = 251 assert.throws( - () => verifyTicketCreate(ticketCreate), + () => validateTicketCreate(ticketCreate), ValidationError, 'TicketCreate: TicketCount must be an integer from 1 to 250', ) assert.throws( - () => verify(ticketCreate), + () => validate(ticketCreate), ValidationError, 'TicketCreate: TicketCount must be an integer from 1 to 250', ) diff --git a/test/models/trustSet.ts b/test/models/trustSet.ts index bf3c2396..a84bd3b0 100644 --- a/test/models/trustSet.ts +++ b/test/models/trustSet.ts @@ -1,10 +1,8 @@ import { assert } from 'chai' +import { validateTrustSet, validate } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { verify } from '../../src/models/transactions' -import { verifyTrustSet } from '../../src/models/transactions/trustSet' - /** * TrustSet Transaction Verification Testing. * @@ -28,19 +26,19 @@ describe('TrustSet', function () { }) it('verifies valid TrustSet', function () { - assert.doesNotThrow(() => verifyTrustSet(trustSet)) - assert.doesNotThrow(() => verify(trustSet)) + assert.doesNotThrow(() => validateTrustSet(trustSet)) + assert.doesNotThrow(() => validate(trustSet)) }) it('throws when LimitAmount is missing', function () { delete trustSet.LimitAmount assert.throws( - () => verifyTrustSet(trustSet), + () => validateTrustSet(trustSet), ValidationError, 'TrustSet: missing field LimitAmount', ) assert.throws( - () => verify(trustSet), + () => validate(trustSet), ValidationError, 'TrustSet: missing field LimitAmount', ) @@ -49,12 +47,12 @@ describe('TrustSet', function () { it('throws when LimitAmount is invalid', function () { trustSet.LimitAmount = 1234 assert.throws( - () => verifyTrustSet(trustSet), + () => validateTrustSet(trustSet), ValidationError, 'TrustSet: invalid LimitAmount', ) assert.throws( - () => verify(trustSet), + () => validate(trustSet), ValidationError, 'TrustSet: invalid LimitAmount', ) @@ -63,12 +61,12 @@ describe('TrustSet', function () { it('throws when QualityIn is not a number', function () { trustSet.QualityIn = '1234' assert.throws( - () => verifyTrustSet(trustSet), + () => validateTrustSet(trustSet), ValidationError, 'TrustSet: QualityIn must be a number', ) assert.throws( - () => verify(trustSet), + () => validate(trustSet), ValidationError, 'TrustSet: QualityIn must be a number', ) @@ -77,12 +75,12 @@ describe('TrustSet', function () { it('throws when QualityOut is not a number', function () { trustSet.QualityOut = '4321' assert.throws( - () => verifyTrustSet(trustSet), + () => validateTrustSet(trustSet), ValidationError, 'TrustSet: QualityOut must be a number', ) assert.throws( - () => verify(trustSet), + () => validate(trustSet), ValidationError, 'TrustSet: QualityOut must be a number', ) diff --git a/test/models/utils.ts b/test/models/utils.ts index 23a9642e..4006343a 100644 --- a/test/models/utils.ts +++ b/test/models/utils.ts @@ -11,7 +11,8 @@ import { PaymentTransactionFlags, TrustSet, TrustSetTransactionFlags, -} from '../../src/models/transactions' +} from 'xrpl-local' + import { isFlagEnabled, setTransactionFlagsToNumber, diff --git a/test/utils/hashes.ts b/test/utils/hashes.ts index c5c83bae..09ec89ed 100644 --- a/test/utils/hashes.ts +++ b/test/utils/hashes.ts @@ -4,9 +4,9 @@ import path from 'path' import { assert } from 'chai' import { encode } from 'ripple-binary-codec' +import { OfferCreate, Transaction } from 'xrpl-local' import { ValidationError } from 'xrpl-local/common/errors' -import { OfferCreate, Transaction } from '../../src/models/transactions' import { computeStateTreeHash, computeTransactionTreeHash, diff --git a/test/wallet/index.ts b/test/wallet/index.ts index 760f53a3..3b21d52d 100644 --- a/test/wallet/index.ts +++ b/test/wallet/index.ts @@ -1,7 +1,8 @@ import { assert } from 'chai' +import { Payment } from 'xrpl-local' + import ECDSA from '../../src/common/ecdsa' -import { Payment } from '../../src/models/transactions' import Wallet from '../../src/wallet' /** diff --git a/test/wallet/signer.ts b/test/wallet/signer.ts index f9e29dd5..6a7f7dc8 100644 --- a/test/wallet/signer.ts +++ b/test/wallet/signer.ts @@ -2,8 +2,9 @@ import { assert } from 'chai' import { decode, encode } from 'ripple-binary-codec/dist' import { JsonObject } from 'ripple-binary-codec/dist/types/serialized-type' +import { Transaction } from 'xrpl-local' + import { ValidationError } from '../../src/common/errors' -import { Transaction } from '../../src/models/transactions' import Wallet from '../../src/wallet' import { sign,