fix: renames verify... methods to validate... (#1624)

* rename verify -> validate

* fix imports

* run eslint --fix on test/
This commit is contained in:
Mayukha Vadari
2021-09-16 21:14:22 -04:00
parent eb0445817e
commit 13c52859eb
51 changed files with 423 additions and 461 deletions

View File

@@ -9,7 +9,7 @@ export * from './common/types/objects/ledger'
export * from './models/methods' export * from './models/methods'
export * from './models/methods' export * from './models/transactions'
export * from './utils' export * from './utils'

View File

@@ -1,6 +1,6 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface AccountDelete extends BaseTransaction { export interface AccountDelete extends BaseTransaction {
TransactionType: 'AccountDelete' TransactionType: 'AccountDelete'
@@ -14,8 +14,8 @@ export interface AccountDelete extends BaseTransaction {
* @param tx - An AccountDelete Transaction. * @param tx - An AccountDelete Transaction.
* @throws When the AccountDelete is Malformed. * @throws When the AccountDelete is Malformed.
*/ */
export function verifyAccountDelete(tx: Record<string, unknown>): void { export function validateAccountDelete(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Destination === undefined) { if (tx.Destination === undefined) {
throw new ValidationError('AccountDelete: missing field Destination') throw new ValidationError('AccountDelete: missing field Destination')

View File

@@ -1,7 +1,7 @@
/* eslint-disable complexity -- Necessary for verifyAccountSet */ /* eslint-disable complexity -- Necessary for validateAccountSet */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export enum AccountSetFlags { export enum AccountSetFlags {
asfRequireDest = 1, asfRequireDest = 1,
@@ -54,8 +54,8 @@ const MAX_TICK_SIZE = 15
* @param tx - An AccountSet Transaction. * @param tx - An AccountSet Transaction.
* @throws When the AccountSet is Malformed. * @throws When the AccountSet is Malformed.
*/ */
export function verifyAccountSet(tx: Record<string, unknown>): void { export function validateAccountSet(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.ClearFlag !== undefined) { if (tx.ClearFlag !== undefined) {
if (typeof tx.ClearFlag !== 'number') { if (typeof tx.ClearFlag !== 'number') {

View File

@@ -1,6 +1,6 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface CheckCancel extends BaseTransaction { export interface CheckCancel extends BaseTransaction {
TransactionType: 'CheckCancel' TransactionType: 'CheckCancel'
@@ -13,8 +13,8 @@ export interface CheckCancel extends BaseTransaction {
* @param tx - An CheckCancel Transaction. * @param tx - An CheckCancel Transaction.
* @throws When the CheckCancel is Malformed. * @throws When the CheckCancel is Malformed.
*/ */
export function verifyCheckCancel(tx: Record<string, unknown>): void { export function validateCheckCancel(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.CheckID !== undefined && typeof tx.CheckID !== 'string') { if (tx.CheckID !== undefined && typeof tx.CheckID !== 'string') {
throw new ValidationError('CheckCancel: invalid CheckID') throw new ValidationError('CheckCancel: invalid CheckID')

View File

@@ -1,8 +1,8 @@
/* eslint-disable complexity -- Necessary for verifyCheckCash */ /* eslint-disable complexity -- Necessary for validateCheckCash */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { Amount } from '../common' import { Amount } from '../common'
import { BaseTransaction, verifyBaseTransaction, isAmount } from './common' import { BaseTransaction, validateBaseTransaction, isAmount } from './common'
export interface CheckCash extends BaseTransaction { export interface CheckCash extends BaseTransaction {
TransactionType: 'CheckCash' TransactionType: 'CheckCash'
@@ -17,8 +17,8 @@ export interface CheckCash extends BaseTransaction {
* @param tx - An CheckCash Transaction. * @param tx - An CheckCash Transaction.
* @throws When the CheckCash is Malformed. * @throws When the CheckCash is Malformed.
*/ */
export function verifyCheckCash(tx: Record<string, unknown>): void { export function validateCheckCash(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Amount == null && tx.DeliverMin == null) { if (tx.Amount == null && tx.DeliverMin == null) {
throw new ValidationError( throw new ValidationError(

View File

@@ -1,10 +1,10 @@
/* eslint-disable complexity -- Necessary for verifyCheckCreate */ /* eslint-disable complexity -- Necessary for validateCheckCreate */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { Amount } from '../common' import { Amount } from '../common'
import { import {
BaseTransaction, BaseTransaction,
verifyBaseTransaction, validateBaseTransaction,
isIssuedCurrency, isIssuedCurrency,
} from './common' } from './common'
@@ -23,8 +23,8 @@ export interface CheckCreate extends BaseTransaction {
* @param tx - An CheckCreate Transaction. * @param tx - An CheckCreate Transaction.
* @throws When the CheckCreate is Malformed. * @throws When the CheckCreate is Malformed.
*/ */
export function verifyCheckCreate(tx: Record<string, unknown>): void { export function validateCheckCreate(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.SendMax === undefined) { if (tx.SendMax === undefined) {
throw new ValidationError('CheckCreate: missing field SendMax') throw new ValidationError('CheckCreate: missing field SendMax')

View File

@@ -1,6 +1,6 @@
/* eslint-disable max-lines-per-function -- Necessary for verifyBaseTransaction */ /* eslint-disable max-lines-per-function -- Necessary for validateBaseTransaction */
/* eslint-disable complexity -- Necessary for verifyBaseTransaction */ /* eslint-disable complexity -- Necessary for validateBaseTransaction */
/* eslint-disable max-statements -- Necessary for verifyBaseTransaction */ /* eslint-disable max-statements -- Necessary for validateBaseTransaction */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { Memo, Signer } from '../common' import { Memo, Signer } from '../common'
import { onlyHasFields } from '../utils' 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 * optional, and will check transaction form at runtime. This should be called
* any time a transaction will be verified. * any time a transaction will be verified.
* *
* @param common - An interface w/ common transaction fields. * @param common - An interface w/ common transaction fields.
* @throws When the common param is malformed. * @throws When the common param is malformed.
*/ */
export function verifyBaseTransaction(common: Record<string, unknown>): void { export function validateBaseTransaction(common: Record<string, unknown>): void {
if (common.Account === undefined) { if (common.Account === undefined) {
throw new ValidationError('BaseTransaction: missing field Account') throw new ValidationError('BaseTransaction: missing field Account')
} }

View File

@@ -1,7 +1,7 @@
/* eslint-disable complexity -- Necessary for verifyDepositPreauth */ /* eslint-disable complexity -- Necessary for validateDepositPreauth */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface DepositPreauth extends BaseTransaction { export interface DepositPreauth extends BaseTransaction {
TransactionType: 'DepositPreauth' TransactionType: 'DepositPreauth'
@@ -15,8 +15,8 @@ export interface DepositPreauth extends BaseTransaction {
* @param tx - A DepositPreauth Transaction. * @param tx - A DepositPreauth Transaction.
* @throws When the DepositPreauth is malformed. * @throws When the DepositPreauth is malformed.
*/ */
export function verifyDepositPreauth(tx: Record<string, unknown>): void { export function validateDepositPreauth(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Authorize !== undefined && tx.Unauthorize !== undefined) { if (tx.Authorize !== undefined && tx.Unauthorize !== undefined) {
throw new ValidationError( throw new ValidationError(

View File

@@ -1,6 +1,6 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface EscrowCancel extends BaseTransaction { export interface EscrowCancel extends BaseTransaction {
TransactionType: 'EscrowCancel' TransactionType: 'EscrowCancel'
@@ -14,8 +14,8 @@ export interface EscrowCancel extends BaseTransaction {
* @param tx - An EscrowCancel Transaction. * @param tx - An EscrowCancel Transaction.
* @throws When the EscrowCancel is Malformed. * @throws When the EscrowCancel is Malformed.
*/ */
export function verifyEscrowCancel(tx: Record<string, unknown>): void { export function validateEscrowCancel(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Owner === undefined) { if (tx.Owner === undefined) {
throw new ValidationError('EscrowCancel: missing Owner') throw new ValidationError('EscrowCancel: missing Owner')

View File

@@ -1,7 +1,7 @@
/* eslint-disable complexity -- Necessary for verifyEscrowCreate */ /* eslint-disable complexity -- Necessary for validateEscrowCreate */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface EscrowCreate extends BaseTransaction { export interface EscrowCreate extends BaseTransaction {
TransactionType: 'EscrowCreate' TransactionType: 'EscrowCreate'
@@ -19,8 +19,8 @@ export interface EscrowCreate extends BaseTransaction {
* @param tx - An EscrowCreate Transaction. * @param tx - An EscrowCreate Transaction.
* @throws When the EscrowCreate is Malformed. * @throws When the EscrowCreate is Malformed.
*/ */
export function verifyEscrowCreate(tx: Record<string, unknown>): void { export function validateEscrowCreate(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Amount === undefined) { if (tx.Amount === undefined) {
throw new ValidationError('EscrowCreate: missing field Amount') throw new ValidationError('EscrowCreate: missing field Amount')

View File

@@ -1,6 +1,6 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface EscrowFinish extends BaseTransaction { export interface EscrowFinish extends BaseTransaction {
TransactionType: 'EscrowFinish' TransactionType: 'EscrowFinish'
@@ -16,8 +16,8 @@ export interface EscrowFinish extends BaseTransaction {
* @param tx - An EscrowFinish Transaction. * @param tx - An EscrowFinish Transaction.
* @throws When the EscrowFinish is Malformed. * @throws When the EscrowFinish is Malformed.
*/ */
export function verifyEscrowFinish(tx: Record<string, unknown>): void { export function validateEscrowFinish(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Owner === undefined) { if (tx.Owner === undefined) {
throw new ValidationError('EscrowFinish: missing field Owner') throw new ValidationError('EscrowFinish: missing field Owner')

View File

@@ -1,11 +1,11 @@
/* eslint-disable import/no-unused-modules -- 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 + verify methods */ /* eslint-disable import/max-dependencies -- Needs to export all types + validate methods */
// TODO: replace * imports with direct imports // TODO: replace * imports with direct imports
export * from './transaction' export * from './transaction'
export { export {
AccountSetFlagsInterface, AccountSetFlagsInterface,
AccountSet, AccountSet,
verifyAccountSet, validateAccountSet,
} from './accountSet' } from './accountSet'
export * from './accountDelete' export * from './accountDelete'
export * from './checkCancel' export * from './checkCancel'
@@ -19,17 +19,17 @@ export * from './offerCancel'
export { export {
OfferCreateFlagsInterface, OfferCreateFlagsInterface,
OfferCreate, OfferCreate,
verifyOfferCreate, validateOfferCreate,
} from './offerCreate' } from './offerCreate'
export { PaymentFlagsInterface, Payment, verifyPayment } from './payment' export { PaymentFlagsInterface, Payment, validatePayment } from './payment'
export { export {
PaymentChannelClaimFlagsInterface, PaymentChannelClaimFlagsInterface,
PaymentChannelClaim, PaymentChannelClaim,
verifyPaymentChannelClaim, validatePaymentChannelClaim,
} from './paymentChannelClaim' } from './paymentChannelClaim'
export * from './paymentChannelCreate' export * from './paymentChannelCreate'
export * from './paymentChannelFund' export * from './paymentChannelFund'
export * from './setRegularKey' export * from './setRegularKey'
export * from './signerListSet' export * from './signerListSet'
export * from './ticketCreate' export * from './ticketCreate'
export { TrustSetFlagsInterface, TrustSet, verifyTrustSet } from './trustSet' export { TrustSetFlagsInterface, TrustSet, validateTrustSet } from './trustSet'

View File

@@ -1,6 +1,6 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface OfferCancel extends BaseTransaction { export interface OfferCancel extends BaseTransaction {
TransactionType: 'OfferCancel' TransactionType: 'OfferCancel'
@@ -13,8 +13,8 @@ export interface OfferCancel extends BaseTransaction {
* @param tx - An OfferCancel Transaction. * @param tx - An OfferCancel Transaction.
* @throws When the OfferCancel is Malformed. * @throws When the OfferCancel is Malformed.
*/ */
export function verifyOfferCancel(tx: Record<string, unknown>): void { export function validateOfferCancel(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.OfferSequence === undefined) { if (tx.OfferSequence === undefined) {
throw new ValidationError('OfferCancel: missing field OfferSequence') throw new ValidationError('OfferCancel: missing field OfferSequence')

View File

@@ -1,11 +1,11 @@
/* eslint-disable complexity -- Necessary for verifyOfferCreate */ /* eslint-disable complexity -- Necessary for validateOfferCreate */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { Amount } from '../common' import { Amount } from '../common'
import { import {
BaseTransaction, BaseTransaction,
GlobalFlags, GlobalFlags,
verifyBaseTransaction, validateBaseTransaction,
isAmount, isAmount,
} from './common' } from './common'
@@ -39,8 +39,8 @@ export interface OfferCreate extends BaseTransaction {
* @param tx - An OfferCreate Transaction. * @param tx - An OfferCreate Transaction.
* @throws When the OfferCreate is Malformed. * @throws When the OfferCreate is Malformed.
*/ */
export function verifyOfferCreate(tx: Record<string, unknown>): void { export function validateOfferCreate(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.TakerGets === undefined) { if (tx.TakerGets === undefined) {
throw new ValidationError('OfferCreate: missing field TakerGets') throw new ValidationError('OfferCreate: missing field TakerGets')

View File

@@ -1,5 +1,5 @@
/* eslint-disable max-statements -- Necessary for verifyPayment */ /* eslint-disable max-statements -- Necessary for validatePayment */
/* eslint-disable complexity -- Necessary for verifyPayment */ /* eslint-disable complexity -- Necessary for validatePayment */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { Amount, Path } from '../common' import { Amount, Path } from '../common'
import { isFlagEnabled } from '../utils' import { isFlagEnabled } from '../utils'
@@ -8,7 +8,7 @@ import {
BaseTransaction, BaseTransaction,
isAmount, isAmount,
GlobalFlags, GlobalFlags,
verifyBaseTransaction, validateBaseTransaction,
} from './common' } from './common'
export enum PaymentTransactionFlags { export enum PaymentTransactionFlags {
@@ -40,8 +40,8 @@ export interface Payment extends BaseTransaction {
* @param tx - A Payment Transaction. * @param tx - A Payment Transaction.
* @throws When the Payment is malformed. * @throws When the Payment is malformed.
*/ */
export function verifyPayment(tx: Record<string, unknown>): void { export function validatePayment(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Amount === undefined) { if (tx.Amount === undefined) {
throw new ValidationError('PaymentTransaction: missing field Amount') throw new ValidationError('PaymentTransaction: missing field Amount')

View File

@@ -1,7 +1,7 @@
/* eslint-disable complexity -- Necessary for verifyPaymentChannelClaim */ /* eslint-disable complexity -- Necessary for validatePaymentChannelClaim */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, GlobalFlags, verifyBaseTransaction } from './common' import { BaseTransaction, GlobalFlags, validateBaseTransaction } from './common'
export enum PaymentChannelClaimTransactionFlags { export enum PaymentChannelClaimTransactionFlags {
tfRenew = 0x00010000, tfRenew = 0x00010000,
@@ -29,8 +29,8 @@ export interface PaymentChannelClaim extends BaseTransaction {
* @param tx - An PaymentChannelClaim Transaction. * @param tx - An PaymentChannelClaim Transaction.
* @throws When the PaymentChannelClaim is Malformed. * @throws When the PaymentChannelClaim is Malformed.
*/ */
export function verifyPaymentChannelClaim(tx: Record<string, unknown>): void { export function validatePaymentChannelClaim(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Channel === undefined) { if (tx.Channel === undefined) {
throw new ValidationError('PaymentChannelClaim: missing Channel') throw new ValidationError('PaymentChannelClaim: missing Channel')

View File

@@ -1,7 +1,7 @@
/* eslint-disable complexity -- Necessary for verifyPaymentChannelCreate */ /* eslint-disable complexity -- Necessary for validatePaymentChannelCreate */
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface PaymentChannelCreate extends BaseTransaction { export interface PaymentChannelCreate extends BaseTransaction {
TransactionType: 'PaymentChannelCreate' TransactionType: 'PaymentChannelCreate'
@@ -19,8 +19,10 @@ export interface PaymentChannelCreate extends BaseTransaction {
* @param tx - An PaymentChannelCreate Transaction. * @param tx - An PaymentChannelCreate Transaction.
* @throws When the PaymentChannelCreate is Malformed. * @throws When the PaymentChannelCreate is Malformed.
*/ */
export function verifyPaymentChannelCreate(tx: Record<string, unknown>): void { export function validatePaymentChannelCreate(
verifyBaseTransaction(tx) tx: Record<string, unknown>,
): void {
validateBaseTransaction(tx)
if (tx.Amount === undefined) { if (tx.Amount === undefined) {
throw new ValidationError('PaymentChannelCreate: missing Amount') throw new ValidationError('PaymentChannelCreate: missing Amount')

View File

@@ -1,6 +1,6 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface PaymentChannelFund extends BaseTransaction { export interface PaymentChannelFund extends BaseTransaction {
TransactionType: 'PaymentChannelFund' TransactionType: 'PaymentChannelFund'
@@ -15,8 +15,8 @@ export interface PaymentChannelFund extends BaseTransaction {
* @param tx - An PaymentChannelFund Transaction. * @param tx - An PaymentChannelFund Transaction.
* @throws When the PaymentChannelFund is Malformed. * @throws When the PaymentChannelFund is Malformed.
*/ */
export function verifyPaymentChannelFund(tx: Record<string, unknown>): void { export function validatePaymentChannelFund(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.Channel === undefined) { if (tx.Channel === undefined) {
throw new ValidationError('PaymentChannelFund: missing Channel') throw new ValidationError('PaymentChannelFund: missing Channel')

View File

@@ -1,6 +1,6 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface SetRegularKey extends BaseTransaction { export interface SetRegularKey extends BaseTransaction {
TransactionType: 'SetRegularKey' TransactionType: 'SetRegularKey'
@@ -13,8 +13,8 @@ export interface SetRegularKey extends BaseTransaction {
* @param tx - A SetRegularKey Transaction. * @param tx - A SetRegularKey Transaction.
* @throws When the SetRegularKey is malformed. * @throws When the SetRegularKey is malformed.
*/ */
export function verifySetRegularKey(tx: Record<string, unknown>): void { export function validateSetRegularKey(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.RegularKey !== undefined && typeof tx.RegularKey !== 'string') { if (tx.RegularKey !== undefined && typeof tx.RegularKey !== 'string') {
throw new ValidationError('SetRegularKey: RegularKey must be a string') throw new ValidationError('SetRegularKey: RegularKey must be a string')

View File

@@ -1,7 +1,7 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { SignerEntry } from '../common' import { SignerEntry } from '../common'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface SignerListSet extends BaseTransaction { export interface SignerListSet extends BaseTransaction {
TransactionType: 'SignerListSet' TransactionType: 'SignerListSet'
@@ -17,8 +17,8 @@ const MAX_SIGNERS = 8
* @param tx - An SignerListSet Transaction. * @param tx - An SignerListSet Transaction.
* @throws When the SignerListSet is Malformed. * @throws When the SignerListSet is Malformed.
*/ */
export function verifySignerListSet(tx: Record<string, unknown>): void { export function validateSignerListSet(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
if (tx.SignerQuorum === undefined) { if (tx.SignerQuorum === undefined) {
throw new ValidationError('SignerListSet: missing field SignerQuorum') throw new ValidationError('SignerListSet: missing field SignerQuorum')

View File

@@ -1,6 +1,6 @@
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { BaseTransaction, verifyBaseTransaction } from './common' import { BaseTransaction, validateBaseTransaction } from './common'
export interface TicketCreate extends BaseTransaction { export interface TicketCreate extends BaseTransaction {
TransactionType: 'TicketCreate' TransactionType: 'TicketCreate'
@@ -15,8 +15,8 @@ const MAX_TICKETS = 250
* @param tx - A TicketCreate Transaction. * @param tx - A TicketCreate Transaction.
* @throws When the TicketCreate is malformed. * @throws When the TicketCreate is malformed.
*/ */
export function verifyTicketCreate(tx: Record<string, unknown>): void { export function validateTicketCreate(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
const { TicketCount } = tx const { TicketCount } = tx
if (TicketCount === undefined) { if (TicketCount === undefined) {

View File

@@ -7,45 +7,49 @@ import { encode, decode } from 'ripple-binary-codec'
import { ValidationError } from '../../common/errors' import { ValidationError } from '../../common/errors'
import { setTransactionFlagsToNumber } from '../utils' import { setTransactionFlagsToNumber } from '../utils'
import { AccountDelete, verifyAccountDelete } from './accountDelete' import { AccountDelete, validateAccountDelete } from './accountDelete'
import { import {
AccountSet, AccountSet,
verifyAccountSet, validateAccountSet,
AccountSetFlags, AccountSetFlags,
AccountSetTransactionFlags, AccountSetTransactionFlags,
} from './accountSet' } from './accountSet'
import { CheckCancel, verifyCheckCancel } from './checkCancel' import { CheckCancel, validateCheckCancel } from './checkCancel'
import { CheckCash, verifyCheckCash } from './checkCash' import { CheckCash, validateCheckCash } from './checkCash'
import { CheckCreate, verifyCheckCreate } from './checkCreate' import { CheckCreate, validateCheckCreate } from './checkCreate'
import { DepositPreauth, verifyDepositPreauth } from './depositPreauth' import { DepositPreauth, validateDepositPreauth } from './depositPreauth'
import { EscrowCancel, verifyEscrowCancel } from './escrowCancel' import { EscrowCancel, validateEscrowCancel } from './escrowCancel'
import { EscrowCreate, verifyEscrowCreate } from './escrowCreate' import { EscrowCreate, validateEscrowCreate } from './escrowCreate'
import { EscrowFinish, verifyEscrowFinish } from './escrowFinish' import { EscrowFinish, validateEscrowFinish } from './escrowFinish'
import TransactionMetadata from './metadata' import TransactionMetadata from './metadata'
import { OfferCancel, verifyOfferCancel } from './offerCancel' import { OfferCancel, validateOfferCancel } from './offerCancel'
import { import {
OfferCreate, OfferCreate,
verifyOfferCreate, validateOfferCreate,
OfferCreateTransactionFlags, OfferCreateTransactionFlags,
} from './offerCreate' } from './offerCreate'
import { Payment, verifyPayment, PaymentTransactionFlags } from './payment' import { Payment, validatePayment, PaymentTransactionFlags } from './payment'
import { import {
PaymentChannelClaim, PaymentChannelClaim,
verifyPaymentChannelClaim, validatePaymentChannelClaim,
PaymentChannelClaimTransactionFlags, PaymentChannelClaimTransactionFlags,
} from './paymentChannelClaim' } from './paymentChannelClaim'
import { import {
PaymentChannelCreate, PaymentChannelCreate,
verifyPaymentChannelCreate, validatePaymentChannelCreate,
} from './paymentChannelCreate' } from './paymentChannelCreate'
import { import {
PaymentChannelFund, PaymentChannelFund,
verifyPaymentChannelFund, validatePaymentChannelFund,
} from './paymentChannelFund' } from './paymentChannelFund'
import { SetRegularKey, verifySetRegularKey } from './setRegularKey' import { SetRegularKey, validateSetRegularKey } from './setRegularKey'
import { SignerListSet, verifySignerListSet } from './signerListSet' import { SignerListSet, validateSignerListSet } from './signerListSet'
import { TicketCreate, verifyTicketCreate } from './ticketCreate' import { TicketCreate, validateTicketCreate } from './ticketCreate'
import { TrustSet, verifyTrustSet, TrustSetTransactionFlags } from './trustSet' import {
TrustSet,
validateTrustSet,
TrustSetTransactionFlags,
} from './trustSet'
export type Transaction = export type Transaction =
| AccountDelete | AccountDelete
@@ -80,84 +84,84 @@ export interface TransactionAndMetadata {
* @param transaction - A Transaction. * @param transaction - A Transaction.
* @throws ValidationError When the Transaction is malformed. * @throws ValidationError When the Transaction is malformed.
*/ */
export function verify(transaction: Record<string, unknown>): void { export function validate(transaction: Record<string, unknown>): void {
const tx = { ...transaction } const tx = { ...transaction }
setTransactionFlagsToNumber(tx as unknown as Transaction) setTransactionFlagsToNumber(tx as unknown as Transaction)
switch (tx.TransactionType) { switch (tx.TransactionType) {
case 'AccountDelete': case 'AccountDelete':
verifyAccountDelete(tx) validateAccountDelete(tx)
break break
case 'AccountSet': case 'AccountSet':
verifyAccountSet(tx) validateAccountSet(tx)
break break
case 'CheckCancel': case 'CheckCancel':
verifyCheckCancel(tx) validateCheckCancel(tx)
break break
case 'CheckCash': case 'CheckCash':
verifyCheckCash(tx) validateCheckCash(tx)
break break
case 'CheckCreate': case 'CheckCreate':
verifyCheckCreate(tx) validateCheckCreate(tx)
break break
case 'DepositPreauth': case 'DepositPreauth':
verifyDepositPreauth(tx) validateDepositPreauth(tx)
break break
case 'EscrowCancel': case 'EscrowCancel':
verifyEscrowCancel(tx) validateEscrowCancel(tx)
break break
case 'EscrowCreate': case 'EscrowCreate':
verifyEscrowCreate(tx) validateEscrowCreate(tx)
break break
case 'EscrowFinish': case 'EscrowFinish':
verifyEscrowFinish(tx) validateEscrowFinish(tx)
break break
case 'OfferCancel': case 'OfferCancel':
verifyOfferCancel(tx) validateOfferCancel(tx)
break break
case 'OfferCreate': case 'OfferCreate':
verifyOfferCreate(tx) validateOfferCreate(tx)
break break
case 'Payment': case 'Payment':
verifyPayment(tx) validatePayment(tx)
break break
case 'PaymentChannelClaim': case 'PaymentChannelClaim':
verifyPaymentChannelClaim(tx) validatePaymentChannelClaim(tx)
break break
case 'PaymentChannelCreate': case 'PaymentChannelCreate':
verifyPaymentChannelCreate(tx) validatePaymentChannelCreate(tx)
break break
case 'PaymentChannelFund': case 'PaymentChannelFund':
verifyPaymentChannelFund(tx) validatePaymentChannelFund(tx)
break break
case 'SetRegularKey': case 'SetRegularKey':
verifySetRegularKey(tx) validateSetRegularKey(tx)
break break
case 'SignerListSet': case 'SignerListSet':
verifySignerListSet(tx) validateSignerListSet(tx)
break break
case 'TicketCreate': case 'TicketCreate':
verifyTicketCreate(tx) validateTicketCreate(tx)
break break
case 'TrustSet': case 'TrustSet':
verifyTrustSet(tx) validateTrustSet(tx)
break break
default: default:

View File

@@ -5,7 +5,7 @@ import {
BaseTransaction, BaseTransaction,
GlobalFlags, GlobalFlags,
isAmount, isAmount,
verifyBaseTransaction, validateBaseTransaction,
} from './common' } from './common'
export enum TrustSetTransactionFlags { export enum TrustSetTransactionFlags {
@@ -38,8 +38,8 @@ export interface TrustSet extends BaseTransaction {
* @param tx - A TrustSet Transaction. * @param tx - A TrustSet Transaction.
* @throws When the TrustSet is malformed. * @throws When the TrustSet is malformed.
*/ */
export function verifyTrustSet(tx: Record<string, unknown>): void { export function validateTrustSet(tx: Record<string, unknown>): void {
verifyBaseTransaction(tx) validateBaseTransaction(tx)
const { LimitAmount, QualityIn, QualityOut } = tx const { LimitAmount, QualityIn, QualityOut } = tx
if (LimitAmount === undefined) { if (LimitAmount === undefined) {

View File

@@ -12,7 +12,7 @@ import { sign as signWithKeypair, verify } from 'ripple-keypairs'
import { ValidationError } from '../common/errors' import { ValidationError } from '../common/errors'
import { Signer } from '../models/common' import { Signer } from '../models/common'
import { Transaction } from '../models/transactions' import { Transaction } from '../models/transactions'
import { verifyBaseTransaction } from '../models/transactions/common' import { validateBaseTransaction } from '../models/transactions/common'
import Wallet from '.' import Wallet from '.'
@@ -52,10 +52,10 @@ function multisign(transactions: Array<Transaction | string>): string {
const tx: Transaction = getDecodedTransaction(txOrBlob) const tx: Transaction = getDecodedTransaction(txOrBlob)
// This will throw a more clear error for JS users if any of the supplied transactions has incorrect formatting // 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) // TODO: Replace this with validate() (The general validation function for all Transactions)
// , also make verify accept '| Transaction' to avoid type casting here. // also make validate accept '| Transaction' to avoid type casting here.
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- verify does not accept Transaction type // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- validate does not accept Transaction type
verifyBaseTransaction(tx as unknown as Record<string, unknown>) validateBaseTransaction(tx as unknown as Record<string, unknown>)
if (tx.Signers == null || tx.Signers.length === 0) { if (tx.Signers == null || tx.Signers.length === 0) {
throw new ValidationError( 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.", "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.",

View File

@@ -1,11 +1,7 @@
import { assert } from 'chai' import { assert } from 'chai'
import { import { AccountDelete, EscrowFinish, Payment, Transaction } from 'xrpl-local'
AccountDelete,
EscrowFinish,
Payment,
Transaction,
} from '../../src/models/transactions'
import rippled from '../fixtures/rippled' import rippled from '../fixtures/rippled'
import { setupClient, teardownClient } from '../setupClient' import { setupClient, teardownClient } from '../setupClient'

View File

@@ -3,13 +3,11 @@ import assert from 'assert'
import _ from 'lodash' import _ from 'lodash'
import { decode } from 'ripple-binary-codec' 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 { AccountSet, SignerListSet } from 'xrpl-local/models/transactions'
import { convertStringToHex } from 'xrpl-local/utils' import { convertStringToHex } from 'xrpl-local/utils'
import { sign, multisign } from 'xrpl-local/wallet/signer' import { sign, multisign } from 'xrpl-local/wallet/signer'
import { Transaction } from '../../src/models/transactions'
import serverUrl from './serverUrl' import serverUrl from './serverUrl'
import { setupClient, suiteClientSetup, teardownClient } from './setup' import { setupClient, suiteClientSetup, teardownClient } from './setup'
import { import {

View File

@@ -5,7 +5,7 @@ import { decode } from 'ripple-binary-codec'
import { Client, SubmitResponse, Wallet } from 'xrpl-local' import { Client, SubmitResponse, Wallet } from 'xrpl-local'
import { import {
verifyPayment, validatePayment,
Payment, Payment,
Transaction, Transaction,
} from 'xrpl-local/models/transactions' } from 'xrpl-local/models/transactions'
@@ -46,7 +46,7 @@ export async function fundAccount(
Amount: '400000000', Amount: '400000000',
} }
const paymentTx = await client.autofill(payment) const paymentTx = await client.autofill(payment)
verifyPayment(paymentTx) validatePayment(paymentTx)
const response = await submitTransaction(client, masterSecret, paymentTx) const response = await submitTransaction(client, masterSecret, paymentTx)
if (response.result.engine_result !== 'tesSUCCESS') { if (response.result.engine_result !== 'tesSUCCESS') {

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateAccountDelete, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyAccountDelete } from '../../src/models/transactions/accountDelete'
/** /**
* AccountDelete Transaction Verification Testing. * AccountDelete Transaction Verification Testing.
* *
@@ -22,7 +20,7 @@ describe('AccountDelete', function () {
Flags: 2147483648, Flags: 2147483648,
} as any } as any
assert.doesNotThrow(() => verifyAccountDelete(validAccountDelete)) assert.doesNotThrow(() => validateAccountDelete(validAccountDelete))
}) })
it(`throws w/ missing Destination`, function () { it(`throws w/ missing Destination`, function () {
@@ -35,13 +33,13 @@ describe('AccountDelete', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyAccountDelete(invalidDestination), () => validateAccountDelete(invalidDestination),
ValidationError, ValidationError,
'AccountDelete: missing field Destination', 'AccountDelete: missing field Destination',
) )
assert.throws( assert.throws(
() => verify(invalidDestination), () => validate(invalidDestination),
ValidationError, ValidationError,
'AccountDelete: missing field Destination', 'AccountDelete: missing field Destination',
) )
@@ -58,12 +56,12 @@ describe('AccountDelete', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyAccountDelete(invalidDestination), () => validateAccountDelete(invalidDestination),
ValidationError, ValidationError,
'AccountDelete: invalid Destination', 'AccountDelete: invalid Destination',
) )
assert.throws( assert.throws(
() => verify(invalidDestination), () => validate(invalidDestination),
ValidationError, ValidationError,
'AccountDelete: invalid Destination', 'AccountDelete: invalid Destination',
) )
@@ -81,13 +79,13 @@ describe('AccountDelete', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyAccountDelete(invalidDestinationTag), () => validateAccountDelete(invalidDestinationTag),
ValidationError, ValidationError,
'AccountDelete: invalid DestinationTag', 'AccountDelete: invalid DestinationTag',
) )
assert.throws( assert.throws(
() => verify(invalidDestinationTag), () => validate(invalidDestinationTag),
ValidationError, ValidationError,
'AccountDelete: invalid DestinationTag', 'AccountDelete: invalid DestinationTag',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateAccountSet, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyAccountSet } from '../../src/models/transactions/accountSet'
/** /**
* AccountSet Transaction Verification Testing. * AccountSet Transaction Verification Testing.
* *
@@ -27,20 +25,20 @@ describe('AccountSet', function () {
}) })
it(`verifies valid AccountSet`, function () { it(`verifies valid AccountSet`, function () {
assert.doesNotThrow(() => verifyAccountSet(account)) assert.doesNotThrow(() => validateAccountSet(account))
assert.doesNotThrow(() => verify(account)) assert.doesNotThrow(() => validate(account))
}) })
it(`throws w/ invalid SetFlag (out of range)`, function () { it(`throws w/ invalid SetFlag (out of range)`, function () {
account.SetFlag = 12 account.SetFlag = 12
assert.throws( assert.throws(
() => verifyAccountSet(account), () => validateAccountSet(account),
ValidationError, ValidationError,
'AccountSet: invalid SetFlag', 'AccountSet: invalid SetFlag',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'AccountSet: invalid SetFlag', 'AccountSet: invalid SetFlag',
) )
@@ -50,12 +48,12 @@ describe('AccountSet', function () {
account.SetFlag = 'abc' account.SetFlag = 'abc'
assert.throws( assert.throws(
() => verifyAccountSet(account), () => validateAccountSet(account),
ValidationError, ValidationError,
'AccountSet: invalid SetFlag', 'AccountSet: invalid SetFlag',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'AccountSet: invalid SetFlag', 'AccountSet: invalid SetFlag',
) )
@@ -65,12 +63,12 @@ describe('AccountSet', function () {
account.ClearFlag = 12 account.ClearFlag = 12
assert.throws( assert.throws(
() => verifyAccountSet(account), () => validateAccountSet(account),
ValidationError, ValidationError,
'AccountSet: invalid ClearFlag', 'AccountSet: invalid ClearFlag',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'AccountSet: invalid ClearFlag', 'AccountSet: invalid ClearFlag',
) )
@@ -80,12 +78,12 @@ describe('AccountSet', function () {
account.Domain = 6578616 account.Domain = 6578616
assert.throws( assert.throws(
() => verifyAccountSet(account), () => validateAccountSet(account),
ValidationError, ValidationError,
'AccountSet: invalid Domain', 'AccountSet: invalid Domain',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'AccountSet: invalid Domain', 'AccountSet: invalid Domain',
) )
@@ -95,12 +93,12 @@ describe('AccountSet', function () {
account.EmailHash = 6578656789876543 account.EmailHash = 6578656789876543
assert.throws( assert.throws(
() => verifyAccountSet(account), () => validateAccountSet(account),
ValidationError, ValidationError,
'AccountSet: invalid EmailHash', 'AccountSet: invalid EmailHash',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'AccountSet: invalid EmailHash', 'AccountSet: invalid EmailHash',
) )
@@ -110,12 +108,12 @@ describe('AccountSet', function () {
account.MessageKey = 6578656789876543 account.MessageKey = 6578656789876543
assert.throws( assert.throws(
() => verifyAccountSet(account), () => validateAccountSet(account),
ValidationError, ValidationError,
'AccountSet: invalid MessageKey', 'AccountSet: invalid MessageKey',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'AccountSet: invalid MessageKey', 'AccountSet: invalid MessageKey',
) )
@@ -125,12 +123,12 @@ describe('AccountSet', function () {
account.TransferRate = '1000000001' account.TransferRate = '1000000001'
assert.throws( assert.throws(
() => verifyAccountSet(account), () => validateAccountSet(account),
ValidationError, ValidationError,
'AccountSet: invalid TransferRate', 'AccountSet: invalid TransferRate',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'AccountSet: invalid TransferRate', 'AccountSet: invalid TransferRate',
) )
@@ -140,12 +138,12 @@ describe('AccountSet', function () {
account.TickSize = 20 account.TickSize = 20
assert.throws( assert.throws(
() => verifyAccountSet(account), () => validateAccountSet(account),
ValidationError, ValidationError,
'AccountSet: invalid TickSize', 'AccountSet: invalid TickSize',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'AccountSet: invalid TickSize', 'AccountSet: invalid TickSize',
) )

View File

@@ -1,8 +1,7 @@
import { assert } from 'chai' import { assert } from 'chai'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { validateBaseTransaction } from 'xrpl-local/models/transactions/common'
import { verifyBaseTransaction } from '../../src/models/transactions/common'
/** /**
* Transaction Verification Testing. * Transaction Verification Testing.
@@ -57,7 +56,7 @@ describe('BaseTransaction', function () {
'3045022100C6708538AE5A697895937C758E99A595B57A16393F370F11B8D4C032E80B532002207776A8E85BB9FAF460A92113B9C60F170CD964196B1F084E0DAB65BAEC368B66', '3045022100C6708538AE5A697895937C758E99A595B57A16393F370F11B8D4C032E80B532002207776A8E85BB9FAF460A92113B9C60F170CD964196B1F084E0DAB65BAEC368B66',
} }
assert.doesNotThrow(() => verifyBaseTransaction(txJson)) assert.doesNotThrow(() => validateBaseTransaction(txJson))
}) })
it(`Verifies only required BaseTransaction`, function () { it(`Verifies only required BaseTransaction`, function () {
@@ -66,7 +65,7 @@ describe('BaseTransaction', function () {
TransactionType: 'Payment', TransactionType: 'Payment',
} }
assert.doesNotThrow(() => verifyBaseTransaction(txJson)) assert.doesNotThrow(() => validateBaseTransaction(txJson))
}) })
it(`Handles invalid Fee`, function () { it(`Handles invalid Fee`, function () {
@@ -77,7 +76,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidFee), () => validateBaseTransaction(invalidFee),
ValidationError, ValidationError,
'BaseTransaction: invalid Fee', 'BaseTransaction: invalid Fee',
) )
@@ -91,7 +90,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidSeq), () => validateBaseTransaction(invalidSeq),
ValidationError, ValidationError,
'BaseTransaction: invalid Sequence', 'BaseTransaction: invalid Sequence',
) )
@@ -105,7 +104,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidID), () => validateBaseTransaction(invalidID),
ValidationError, ValidationError,
'BaseTransaction: invalid AccountTxnID', 'BaseTransaction: invalid AccountTxnID',
) )
@@ -119,7 +118,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidLastLedgerSequence), () => validateBaseTransaction(invalidLastLedgerSequence),
ValidationError, ValidationError,
'BaseTransaction: invalid LastLedgerSequence', 'BaseTransaction: invalid LastLedgerSequence',
) )
@@ -133,7 +132,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidSourceTag), () => validateBaseTransaction(invalidSourceTag),
ValidationError, ValidationError,
'BaseTransaction: invalid SourceTag', 'BaseTransaction: invalid SourceTag',
) )
@@ -147,7 +146,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidSigningPubKey), () => validateBaseTransaction(invalidSigningPubKey),
ValidationError, ValidationError,
'BaseTransaction: invalid SigningPubKey', 'BaseTransaction: invalid SigningPubKey',
) )
@@ -161,7 +160,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidTicketSequence), () => validateBaseTransaction(invalidTicketSequence),
ValidationError, ValidationError,
'BaseTransaction: invalid TicketSequence', 'BaseTransaction: invalid TicketSequence',
) )
@@ -175,7 +174,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidTxnSignature), () => validateBaseTransaction(invalidTxnSignature),
ValidationError, ValidationError,
'BaseTransaction: invalid TxnSignature', 'BaseTransaction: invalid TxnSignature',
) )
@@ -189,7 +188,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidSigners), () => validateBaseTransaction(invalidSigners),
ValidationError, ValidationError,
'BaseTransaction: invalid Signers', 'BaseTransaction: invalid Signers',
) )
@@ -207,7 +206,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidSigners2), () => validateBaseTransaction(invalidSigners2),
ValidationError, ValidationError,
'BaseTransaction: invalid Signers', 'BaseTransaction: invalid Signers',
) )
@@ -228,7 +227,7 @@ describe('BaseTransaction', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyBaseTransaction(invalidMemo), () => validateBaseTransaction(invalidMemo),
ValidationError, ValidationError,
'BaseTransaction: invalid Memos', 'BaseTransaction: invalid Memos',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateCheckCancel, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyCheckCancel } from '../../src/models/transactions/checkCancel'
/** /**
* CheckCancel Transaction Verification Testing. * CheckCancel Transaction Verification Testing.
* *
@@ -19,8 +17,8 @@ describe('CheckCancel', function () {
'49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0', '49647F0D748DC3FE26BDACBC57F251AADEFFF391403EC9BF87C97F67E9977FB0',
} as any } as any
assert.doesNotThrow(() => verifyCheckCancel(validCheckCancel)) assert.doesNotThrow(() => validateCheckCancel(validCheckCancel))
assert.doesNotThrow(() => verify(validCheckCancel)) assert.doesNotThrow(() => validate(validCheckCancel))
}) })
it(`throws w/ invalid CheckCancel`, function () { it(`throws w/ invalid CheckCancel`, function () {
@@ -31,12 +29,12 @@ describe('CheckCancel', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCancel(invalidCheckID), () => validateCheckCancel(invalidCheckID),
ValidationError, ValidationError,
'CheckCancel: invalid CheckID', 'CheckCancel: invalid CheckID',
) )
assert.throws( assert.throws(
() => verify(invalidCheckID), () => validate(invalidCheckID),
ValidationError, ValidationError,
'CheckCancel: invalid CheckID', 'CheckCancel: invalid CheckID',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateCheckCash, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyCheckCash } from '../../src/models/transactions/checkCash'
/** /**
* CheckCash Transaction Verification Testing. * CheckCash Transaction Verification Testing.
* *
@@ -21,8 +19,8 @@ describe('CheckCash', function () {
Fee: '12', Fee: '12',
} as any } as any
assert.doesNotThrow(() => verifyCheckCash(validCheckCash)) assert.doesNotThrow(() => validateCheckCash(validCheckCash))
assert.doesNotThrow(() => verify(validCheckCash)) assert.doesNotThrow(() => validate(validCheckCash))
}) })
it(`throws w/ invalid CheckID`, function () { it(`throws w/ invalid CheckID`, function () {
@@ -34,12 +32,12 @@ describe('CheckCash', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCash(invalidCheckID), () => validateCheckCash(invalidCheckID),
ValidationError, ValidationError,
'CheckCash: invalid CheckID', 'CheckCash: invalid CheckID',
) )
assert.throws( assert.throws(
() => verify(invalidCheckID), () => validate(invalidCheckID),
ValidationError, ValidationError,
'CheckCash: invalid CheckID', 'CheckCash: invalid CheckID',
) )
@@ -55,12 +53,12 @@ describe('CheckCash', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCash(invalidAmount), () => validateCheckCash(invalidAmount),
ValidationError, ValidationError,
'CheckCash: invalid Amount', 'CheckCash: invalid Amount',
) )
assert.throws( assert.throws(
() => verify(invalidAmount), () => validate(invalidAmount),
ValidationError, ValidationError,
'CheckCash: invalid Amount', 'CheckCash: invalid Amount',
) )
@@ -77,12 +75,12 @@ describe('CheckCash', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCash(invalidDeliverMin), () => validateCheckCash(invalidDeliverMin),
ValidationError, ValidationError,
'CheckCash: cannot have both Amount and DeliverMin', 'CheckCash: cannot have both Amount and DeliverMin',
) )
assert.throws( assert.throws(
() => verify(invalidDeliverMin), () => validate(invalidDeliverMin),
ValidationError, ValidationError,
'CheckCash: cannot have both Amount and DeliverMin', 'CheckCash: cannot have both Amount and DeliverMin',
) )
@@ -98,12 +96,12 @@ describe('CheckCash', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCash(invalidDeliverMin), () => validateCheckCash(invalidDeliverMin),
ValidationError, ValidationError,
'CheckCash: invalid DeliverMin', 'CheckCash: invalid DeliverMin',
) )
assert.throws( assert.throws(
() => verify(invalidDeliverMin), () => validate(invalidDeliverMin),
ValidationError, ValidationError,
'CheckCash: invalid DeliverMin', 'CheckCash: invalid DeliverMin',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateCheckCreate, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyCheckCreate } from '../../src/models/transactions/checkCreate'
/** /**
* CheckCreate Transaction Verification Testing. * CheckCreate Transaction Verification Testing.
* *
@@ -24,8 +22,8 @@ describe('CheckCreate', function () {
Fee: '12', Fee: '12',
} as any } as any
assert.doesNotThrow(() => verifyCheckCreate(validCheck)) assert.doesNotThrow(() => validateCheckCreate(validCheck))
assert.doesNotThrow(() => verify(validCheck)) assert.doesNotThrow(() => validate(validCheck))
}) })
it(`throws w/ invalid Destination`, function () { it(`throws w/ invalid Destination`, function () {
@@ -42,12 +40,12 @@ describe('CheckCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCreate(invalidDestination), () => validateCheckCreate(invalidDestination),
ValidationError, ValidationError,
'CheckCreate: invalid Destination', 'CheckCreate: invalid Destination',
) )
assert.throws( assert.throws(
() => verify(invalidDestination), () => validate(invalidDestination),
ValidationError, ValidationError,
'CheckCreate: invalid Destination', 'CheckCreate: invalid Destination',
) )
@@ -67,12 +65,12 @@ describe('CheckCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCreate(invalidSendMax), () => validateCheckCreate(invalidSendMax),
ValidationError, ValidationError,
'CheckCreate: invalid SendMax', 'CheckCreate: invalid SendMax',
) )
assert.throws( assert.throws(
() => verify(invalidSendMax), () => validate(invalidSendMax),
ValidationError, ValidationError,
'CheckCreate: invalid SendMax', 'CheckCreate: invalid SendMax',
) )
@@ -92,12 +90,12 @@ describe('CheckCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCreate(invalidDestinationTag), () => validateCheckCreate(invalidDestinationTag),
ValidationError, ValidationError,
'CheckCreate: invalid DestinationTag', 'CheckCreate: invalid DestinationTag',
) )
assert.throws( assert.throws(
() => verify(invalidDestinationTag), () => validate(invalidDestinationTag),
ValidationError, ValidationError,
'CheckCreate: invalid DestinationTag', 'CheckCreate: invalid DestinationTag',
) )
@@ -117,12 +115,12 @@ describe('CheckCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCreate(invalidExpiration), () => validateCheckCreate(invalidExpiration),
ValidationError, ValidationError,
'CheckCreate: invalid Expiration', 'CheckCreate: invalid Expiration',
) )
assert.throws( assert.throws(
() => verify(invalidExpiration), () => validate(invalidExpiration),
ValidationError, ValidationError,
'CheckCreate: invalid Expiration', 'CheckCreate: invalid Expiration',
) )
@@ -141,12 +139,12 @@ describe('CheckCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyCheckCreate(invalidInvoiceID), () => validateCheckCreate(invalidInvoiceID),
ValidationError, ValidationError,
'CheckCreate: invalid InvoiceID', 'CheckCreate: invalid InvoiceID',
) )
assert.throws( assert.throws(
() => verify(invalidInvoiceID), () => validate(invalidInvoiceID),
ValidationError, ValidationError,
'CheckCreate: invalid InvoiceID', 'CheckCreate: invalid InvoiceID',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateDepositPreauth, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyDepositPreauth } from '../../src/models/transactions/depositPreauth'
/** /**
* DepositPreauth Transaction Verification Testing. * DepositPreauth Transaction Verification Testing.
* *
@@ -22,26 +20,26 @@ describe('DepositPreauth', function () {
it('verifies valid DepositPreauth when only Authorize is provided', function () { it('verifies valid DepositPreauth when only Authorize is provided', function () {
depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW' depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW'
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth)) assert.doesNotThrow(() => validateDepositPreauth(depositPreauth))
assert.doesNotThrow(() => verify(depositPreauth)) assert.doesNotThrow(() => validate(depositPreauth))
}) })
it('verifies valid DepositPreauth when only Unauthorize is provided', function () { it('verifies valid DepositPreauth when only Unauthorize is provided', function () {
depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n' depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n'
assert.doesNotThrow(() => verifyDepositPreauth(depositPreauth)) assert.doesNotThrow(() => validateDepositPreauth(depositPreauth))
assert.doesNotThrow(() => verify(depositPreauth)) assert.doesNotThrow(() => validate(depositPreauth))
}) })
it('throws when both Authorize and Unauthorize are provided', function () { it('throws when both Authorize and Unauthorize are provided', function () {
depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW' depositPreauth.Authorize = 'rsA2LpzuawewSBQXkiju3YQTMzW13pAAdW'
depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n' depositPreauth.Unauthorize = 'raKEEVSGnKSD9Zyvxu4z6Pqpm4ABH8FS6n'
assert.throws( assert.throws(
() => verifyDepositPreauth(depositPreauth), () => validateDepositPreauth(depositPreauth),
ValidationError, ValidationError,
"DepositPreauth: can't provide both Authorize and Unauthorize fields", "DepositPreauth: can't provide both Authorize and Unauthorize fields",
) )
assert.throws( assert.throws(
() => verify(depositPreauth), () => validate(depositPreauth),
ValidationError, ValidationError,
"DepositPreauth: can't provide both Authorize and Unauthorize fields", "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 () { it('throws when neither Authorize nor Unauthorize are provided', function () {
assert.throws( assert.throws(
() => verifyDepositPreauth(depositPreauth), () => validateDepositPreauth(depositPreauth),
ValidationError, ValidationError,
'DepositPreauth: must provide either Authorize or Unauthorize field', 'DepositPreauth: must provide either Authorize or Unauthorize field',
) )
assert.throws( assert.throws(
() => verify(depositPreauth), () => validate(depositPreauth),
ValidationError, ValidationError,
'DepositPreauth: must provide either Authorize or Unauthorize field', 'DepositPreauth: must provide either Authorize or Unauthorize field',
) )
@@ -63,12 +61,12 @@ describe('DepositPreauth', function () {
it('throws when Authorize is not a string', function () { it('throws when Authorize is not a string', function () {
depositPreauth.Authorize = 1234 depositPreauth.Authorize = 1234
assert.throws( assert.throws(
() => verifyDepositPreauth(depositPreauth), () => validateDepositPreauth(depositPreauth),
ValidationError, ValidationError,
'DepositPreauth: Authorize must be a string', 'DepositPreauth: Authorize must be a string',
) )
assert.throws( assert.throws(
() => verify(depositPreauth), () => validate(depositPreauth),
ValidationError, ValidationError,
'DepositPreauth: Authorize must be a string', '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 () { it('throws when an Account attempts to preauthorize its own address', function () {
depositPreauth.Authorize = depositPreauth.Account depositPreauth.Authorize = depositPreauth.Account
assert.throws( assert.throws(
() => verifyDepositPreauth(depositPreauth), () => validateDepositPreauth(depositPreauth),
ValidationError, ValidationError,
"DepositPreauth: Account can't preauthorize its own address", "DepositPreauth: Account can't preauthorize its own address",
) )
@@ -86,12 +84,12 @@ describe('DepositPreauth', function () {
it('throws when Unauthorize is not a string', function () { it('throws when Unauthorize is not a string', function () {
depositPreauth.Unauthorize = 1234 depositPreauth.Unauthorize = 1234
assert.throws( assert.throws(
() => verifyDepositPreauth(depositPreauth), () => validateDepositPreauth(depositPreauth),
ValidationError, ValidationError,
'DepositPreauth: Unauthorize must be a string', 'DepositPreauth: Unauthorize must be a string',
) )
assert.throws( assert.throws(
() => verify(depositPreauth), () => validate(depositPreauth),
ValidationError, ValidationError,
'DepositPreauth: Unauthorize must be a string', '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 () { it('throws when an Account attempts to unauthorize its own address', function () {
depositPreauth.Unauthorize = depositPreauth.Account depositPreauth.Unauthorize = depositPreauth.Account
assert.throws( assert.throws(
() => verifyDepositPreauth(depositPreauth), () => validateDepositPreauth(depositPreauth),
ValidationError, ValidationError,
"DepositPreauth: Account can't unauthorize its own address", "DepositPreauth: Account can't unauthorize its own address",
) )
assert.throws( assert.throws(
() => verify(depositPreauth), () => validate(depositPreauth),
ValidationError, ValidationError,
"DepositPreauth: Account can't unauthorize its own address", "DepositPreauth: Account can't unauthorize its own address",
) )

View File

@@ -1,8 +1,7 @@
import { assert } from 'chai' import { assert } from 'chai'
import { ValidationError } from '../../src/common/errors' import { validateEscrowCancel, validate } from 'xrpl-local'
import { verify } from '../../src/models/transactions' import { ValidationError } from 'xrpl-local/common/errors'
import { verifyEscrowCancel } from '../../src/models/transactions/escrowCancel'
/** /**
* Transaction Verification Testing. * Transaction Verification Testing.
@@ -22,20 +21,20 @@ describe('EscrowCancel', function () {
}) })
it(`Valid EscrowCancel`, function () { it(`Valid EscrowCancel`, function () {
assert.doesNotThrow(() => verifyEscrowCancel(cancel)) assert.doesNotThrow(() => validateEscrowCancel(cancel))
assert.doesNotThrow(() => verify(cancel)) assert.doesNotThrow(() => validate(cancel))
}) })
it(`Invalid EscrowCancel missing owner`, function () { it(`Invalid EscrowCancel missing owner`, function () {
delete cancel.Owner delete cancel.Owner
assert.throws( assert.throws(
() => verifyEscrowCancel(cancel), () => validateEscrowCancel(cancel),
ValidationError, ValidationError,
'EscrowCancel: missing Owner', 'EscrowCancel: missing Owner',
) )
assert.throws( assert.throws(
() => verify(cancel), () => validate(cancel),
ValidationError, ValidationError,
'EscrowCancel: missing Owner', 'EscrowCancel: missing Owner',
) )
@@ -45,12 +44,12 @@ describe('EscrowCancel', function () {
delete cancel.OfferSequence delete cancel.OfferSequence
assert.throws( assert.throws(
() => verifyEscrowCancel(cancel), () => validateEscrowCancel(cancel),
ValidationError, ValidationError,
'EscrowCancel: missing OfferSequence', 'EscrowCancel: missing OfferSequence',
) )
assert.throws( assert.throws(
() => verify(cancel), () => validate(cancel),
ValidationError, ValidationError,
'EscrowCancel: missing OfferSequence', 'EscrowCancel: missing OfferSequence',
) )
@@ -60,12 +59,12 @@ describe('EscrowCancel', function () {
cancel.Owner = 10 cancel.Owner = 10
assert.throws( assert.throws(
() => verifyEscrowCancel(cancel), () => validateEscrowCancel(cancel),
ValidationError, ValidationError,
'EscrowCancel: Owner must be a string', 'EscrowCancel: Owner must be a string',
) )
assert.throws( assert.throws(
() => verify(cancel), () => validate(cancel),
ValidationError, ValidationError,
'EscrowCancel: Owner must be a string', 'EscrowCancel: Owner must be a string',
) )
@@ -75,12 +74,12 @@ describe('EscrowCancel', function () {
cancel.OfferSequence = '10' cancel.OfferSequence = '10'
assert.throws( assert.throws(
() => verifyEscrowCancel(cancel), () => validateEscrowCancel(cancel),
ValidationError, ValidationError,
'EscrowCancel: OfferSequence must be a number', 'EscrowCancel: OfferSequence must be a number',
) )
assert.throws( assert.throws(
() => verify(cancel), () => validate(cancel),
ValidationError, ValidationError,
'EscrowCancel: OfferSequence must be a number', 'EscrowCancel: OfferSequence must be a number',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateEscrowCreate, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyEscrowCreate } from '../../src/models/transactions/escrowCreate'
/** /**
* EscrowCreate Transaction Verification Testing. * EscrowCreate Transaction Verification Testing.
* *
@@ -29,20 +27,20 @@ describe('EscrowCreate', function () {
}) })
it(`verifies valid EscrowCreate`, function () { it(`verifies valid EscrowCreate`, function () {
assert.doesNotThrow(() => verifyEscrowCreate(escrow)) assert.doesNotThrow(() => validateEscrowCreate(escrow))
assert.doesNotThrow(() => verify(escrow)) assert.doesNotThrow(() => validate(escrow))
}) })
it(`Missing amount`, function () { it(`Missing amount`, function () {
delete escrow.Amount delete escrow.Amount
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: missing field Amount', 'EscrowCreate: missing field Amount',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: missing field Amount', 'EscrowCreate: missing field Amount',
) )
@@ -52,12 +50,12 @@ describe('EscrowCreate', function () {
delete escrow.Destination delete escrow.Destination
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: missing field Destination', 'EscrowCreate: missing field Destination',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: missing field Destination', 'EscrowCreate: missing field Destination',
) )
@@ -67,12 +65,12 @@ describe('EscrowCreate', function () {
escrow.Destination = 10 escrow.Destination = 10
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Destination must be a string', 'EscrowCreate: Destination must be a string',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Destination must be a string', 'EscrowCreate: Destination must be a string',
) )
@@ -82,12 +80,12 @@ describe('EscrowCreate', function () {
escrow.Amount = 1000 escrow.Amount = 1000
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Amount must be a string', 'EscrowCreate: Amount must be a string',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Amount must be a string', 'EscrowCreate: Amount must be a string',
) )
@@ -97,12 +95,12 @@ describe('EscrowCreate', function () {
escrow.CancelAfter = '100' escrow.CancelAfter = '100'
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: CancelAfter must be a number', 'EscrowCreate: CancelAfter must be a number',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: CancelAfter must be a number', 'EscrowCreate: CancelAfter must be a number',
) )
@@ -112,7 +110,7 @@ describe('EscrowCreate', function () {
escrow.FinishAfter = '1000' escrow.FinishAfter = '1000'
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: FinishAfter must be a number', 'EscrowCreate: FinishAfter must be a number',
) )
@@ -122,12 +120,12 @@ describe('EscrowCreate', function () {
escrow.Condition = 0x141243 escrow.Condition = 0x141243
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Condition must be a string', 'EscrowCreate: Condition must be a string',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Condition must be a string', 'EscrowCreate: Condition must be a string',
) )
@@ -137,12 +135,12 @@ describe('EscrowCreate', function () {
escrow.DestinationTag = '100' escrow.DestinationTag = '100'
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: DestinationTag must be a number', 'EscrowCreate: DestinationTag must be a number',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: DestinationTag must be a number', 'EscrowCreate: DestinationTag must be a number',
) )
@@ -153,12 +151,12 @@ describe('EscrowCreate', function () {
delete escrow.FinishAfter delete escrow.FinishAfter
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Either CancelAfter or FinishAfter must be specified', 'EscrowCreate: Either CancelAfter or FinishAfter must be specified',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Either CancelAfter or FinishAfter must be specified', 'EscrowCreate: Either CancelAfter or FinishAfter must be specified',
) )
@@ -169,12 +167,12 @@ describe('EscrowCreate', function () {
delete escrow.FinishAfter delete escrow.FinishAfter
assert.throws( assert.throws(
() => verifyEscrowCreate(escrow), () => validateEscrowCreate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Either Condition or FinishAfter must be specified', 'EscrowCreate: Either Condition or FinishAfter must be specified',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowCreate: Either Condition or FinishAfter must be specified', 'EscrowCreate: Either Condition or FinishAfter must be specified',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateEscrowFinish, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyEscrowFinish } from '../../src/models/transactions/escrowFinish'
/** /**
* EscrowFinish Transaction Verification Testing. * EscrowFinish Transaction Verification Testing.
* *
@@ -25,28 +23,28 @@ describe('EscrowFinish', function () {
} }
}) })
it(`verifies valid EscrowFinish`, function () { it(`verifies valid EscrowFinish`, function () {
assert.doesNotThrow(() => verifyEscrowFinish(escrow)) assert.doesNotThrow(() => validateEscrowFinish(escrow))
assert.doesNotThrow(() => verify(escrow)) assert.doesNotThrow(() => validate(escrow))
}) })
it(`verifies valid EscrowFinish w/o optional`, function () { it(`verifies valid EscrowFinish w/o optional`, function () {
delete escrow.Condition delete escrow.Condition
delete escrow.Fulfillment delete escrow.Fulfillment
assert.doesNotThrow(() => verifyEscrowFinish(escrow)) assert.doesNotThrow(() => validateEscrowFinish(escrow))
assert.doesNotThrow(() => verify(escrow)) assert.doesNotThrow(() => validate(escrow))
}) })
it(`throws w/ invalid Owner`, function () { it(`throws w/ invalid Owner`, function () {
escrow.Owner = 0x15415253 escrow.Owner = 0x15415253
assert.throws( assert.throws(
() => verifyEscrowFinish(escrow), () => validateEscrowFinish(escrow),
ValidationError, ValidationError,
'EscrowFinish: Owner must be a string', 'EscrowFinish: Owner must be a string',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowFinish: Owner must be a string', 'EscrowFinish: Owner must be a string',
) )
@@ -56,12 +54,12 @@ describe('EscrowFinish', function () {
escrow.OfferSequence = '10' escrow.OfferSequence = '10'
assert.throws( assert.throws(
() => verifyEscrowFinish(escrow), () => validateEscrowFinish(escrow),
ValidationError, ValidationError,
'EscrowFinish: OfferSequence must be a number', 'EscrowFinish: OfferSequence must be a number',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowFinish: OfferSequence must be a number', 'EscrowFinish: OfferSequence must be a number',
) )
@@ -71,12 +69,12 @@ describe('EscrowFinish', function () {
escrow.Condition = 10 escrow.Condition = 10
assert.throws( assert.throws(
() => verifyEscrowFinish(escrow), () => validateEscrowFinish(escrow),
ValidationError, ValidationError,
'EscrowFinish: Condition must be a string', 'EscrowFinish: Condition must be a string',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowFinish: Condition must be a string', 'EscrowFinish: Condition must be a string',
) )
@@ -86,12 +84,12 @@ describe('EscrowFinish', function () {
escrow.Fulfillment = 0x142341 escrow.Fulfillment = 0x142341
assert.throws( assert.throws(
() => verifyEscrowFinish(escrow), () => validateEscrowFinish(escrow),
ValidationError, ValidationError,
'EscrowFinish: Fulfillment must be a string', 'EscrowFinish: Fulfillment must be a string',
) )
assert.throws( assert.throws(
() => verify(escrow), () => validate(escrow),
ValidationError, ValidationError,
'EscrowFinish: Fulfillment must be a string', 'EscrowFinish: Fulfillment must be a string',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateOfferCancel, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyOfferCancel } from '../../src/models/transactions/offerCancel'
/** /**
* OfferCancel Transaction Verification Testing. * OfferCancel Transaction Verification Testing.
* *
@@ -30,25 +28,25 @@ describe('OfferCancel', function () {
}) })
it(`verifies valid OfferCancel`, function () { it(`verifies valid OfferCancel`, function () {
assert.doesNotThrow(() => verifyOfferCancel(offer)) assert.doesNotThrow(() => validateOfferCancel(offer))
assert.doesNotThrow(() => verify(offer)) assert.doesNotThrow(() => validate(offer))
}) })
it(`verifies valid OfferCancel with flags`, function () { it(`verifies valid OfferCancel with flags`, function () {
offer.Flags = 2147483648 offer.Flags = 2147483648
assert.doesNotThrow(() => verifyOfferCancel(offer)) assert.doesNotThrow(() => validateOfferCancel(offer))
assert.doesNotThrow(() => verify(offer)) assert.doesNotThrow(() => validate(offer))
}) })
it(`throws w/ OfferSequence must be a number`, function () { it(`throws w/ OfferSequence must be a number`, function () {
offer.OfferSequence = '99' offer.OfferSequence = '99'
assert.throws( assert.throws(
() => verifyOfferCancel(offer), () => validateOfferCancel(offer),
ValidationError, ValidationError,
'OfferCancel: OfferSequence must be a number', 'OfferCancel: OfferSequence must be a number',
) )
assert.throws( assert.throws(
() => verify(offer), () => validate(offer),
ValidationError, ValidationError,
'OfferCancel: OfferSequence must be a number', 'OfferCancel: OfferSequence must be a number',
) )
@@ -57,12 +55,12 @@ describe('OfferCancel', function () {
it(`throws w/ missing OfferSequence`, function () { it(`throws w/ missing OfferSequence`, function () {
delete offer.OfferSequence delete offer.OfferSequence
assert.throws( assert.throws(
() => verifyOfferCancel(offer), () => validateOfferCancel(offer),
ValidationError, ValidationError,
'OfferCancel: missing field OfferSequence', 'OfferCancel: missing field OfferSequence',
) )
assert.throws( assert.throws(
() => verify(offer), () => validate(offer),
ValidationError, ValidationError,
'OfferCancel: missing field OfferSequence', 'OfferCancel: missing field OfferSequence',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateOfferCreate, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyOfferCreate } from '../../src/models/transactions/offerCreate'
/** /**
* OfferCreate Transaction Verification Testing. * OfferCreate Transaction Verification Testing.
* *
@@ -33,8 +31,8 @@ describe('OfferCreate', function () {
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91', '3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any } as any
assert.doesNotThrow(() => verifyOfferCreate(offer)) assert.doesNotThrow(() => validateOfferCreate(offer))
assert.doesNotThrow(() => verify(offer)) assert.doesNotThrow(() => validate(offer))
const offer2 = { const offer2 = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W', Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
@@ -55,8 +53,8 @@ describe('OfferCreate', function () {
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91', '3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any } as any
assert.doesNotThrow(() => verifyOfferCreate(offer2)) assert.doesNotThrow(() => validateOfferCreate(offer2))
assert.doesNotThrow(() => verify(offer2)) assert.doesNotThrow(() => validate(offer2))
const offer3 = { const offer3 = {
Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W', Account: 'r3rhWeE31Jt5sWmi4QiGLMZnY3ENgqw96W',
@@ -81,8 +79,8 @@ describe('OfferCreate', function () {
'3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91', '3045022100D874CDDD6BB24ED66E83B1D3574D3ECAC753A78F26DB7EBA89EAB8E7D72B95F802207C8CCD6CEA64E4AE2014E59EE9654E02CA8F03FE7FCE0539E958EAE182234D91',
} as any } as any
assert.doesNotThrow(() => verifyOfferCreate(offer3)) assert.doesNotThrow(() => validateOfferCreate(offer3))
assert.doesNotThrow(() => verify(offer3)) assert.doesNotThrow(() => validate(offer3))
}) })
it(`throws w/ invalid Expiration`, function () { it(`throws w/ invalid Expiration`, function () {
@@ -107,12 +105,12 @@ describe('OfferCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyOfferCreate(offer), () => validateOfferCreate(offer),
ValidationError, ValidationError,
'OfferCreate: invalid Expiration', 'OfferCreate: invalid Expiration',
) )
assert.throws( assert.throws(
() => verify(offer), () => validate(offer),
ValidationError, ValidationError,
'OfferCreate: invalid Expiration', 'OfferCreate: invalid Expiration',
) )
@@ -140,12 +138,12 @@ describe('OfferCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyOfferCreate(offer), () => validateOfferCreate(offer),
ValidationError, ValidationError,
'OfferCreate: invalid OfferSequence', 'OfferCreate: invalid OfferSequence',
) )
assert.throws( assert.throws(
() => verify(offer), () => validate(offer),
ValidationError, ValidationError,
'OfferCreate: invalid OfferSequence', 'OfferCreate: invalid OfferSequence',
) )
@@ -169,12 +167,12 @@ describe('OfferCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyOfferCreate(offer), () => validateOfferCreate(offer),
ValidationError, ValidationError,
'OfferCreate: invalid TakerPays', 'OfferCreate: invalid TakerPays',
) )
assert.throws( assert.throws(
() => verify(offer), () => validate(offer),
ValidationError, ValidationError,
'OfferCreate: invalid TakerPays', 'OfferCreate: invalid TakerPays',
) )
@@ -202,12 +200,12 @@ describe('OfferCreate', function () {
} as any } as any
assert.throws( assert.throws(
() => verifyOfferCreate(offer), () => validateOfferCreate(offer),
ValidationError, ValidationError,
'OfferCreate: invalid TakerGets', 'OfferCreate: invalid TakerGets',
) )
assert.throws( assert.throws(
() => verify(offer), () => validate(offer),
ValidationError, ValidationError,
'OfferCreate: invalid TakerGets', 'OfferCreate: invalid TakerGets',
) )

View File

@@ -1,13 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validatePayment, validate, PaymentTransactionFlags } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import {
verifyPayment,
verify,
PaymentTransactionFlags,
} from '../../src/models/transactions'
/** /**
* PaymentTransaction Verification Testing. * PaymentTransaction Verification Testing.
* *
@@ -41,19 +36,19 @@ describe('Payment', function () {
}) })
it(`verifies valid PaymentTransaction`, function () { it(`verifies valid PaymentTransaction`, function () {
assert.doesNotThrow(() => verifyPayment(paymentTransaction)) assert.doesNotThrow(() => validatePayment(paymentTransaction))
assert.doesNotThrow(() => verify(paymentTransaction)) assert.doesNotThrow(() => validate(paymentTransaction))
}) })
it(`throws when Amount is missing`, function () { it(`throws when Amount is missing`, function () {
delete paymentTransaction.Amount delete paymentTransaction.Amount
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: missing field Amount', 'PaymentTransaction: missing field Amount',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: missing field Amount', 'PaymentTransaction: missing field Amount',
) )
@@ -62,12 +57,12 @@ describe('Payment', function () {
it(`throws when Amount is invalid`, function () { it(`throws when Amount is invalid`, function () {
paymentTransaction.Amount = 1234 paymentTransaction.Amount = 1234
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid Amount', 'PaymentTransaction: invalid Amount',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid Amount', 'PaymentTransaction: invalid Amount',
) )
@@ -76,12 +71,12 @@ describe('Payment', function () {
it(`throws when Destination is missing`, function () { it(`throws when Destination is missing`, function () {
delete paymentTransaction.Destination delete paymentTransaction.Destination
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: missing field Destination', 'PaymentTransaction: missing field Destination',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: missing field Destination', 'PaymentTransaction: missing field Destination',
) )
@@ -90,12 +85,12 @@ describe('Payment', function () {
it(`throws when Destination is invalid`, function () { it(`throws when Destination is invalid`, function () {
paymentTransaction.Destination = 7896214 paymentTransaction.Destination = 7896214
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid Destination', 'PaymentTransaction: invalid Destination',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid Destination', 'PaymentTransaction: invalid Destination',
) )
@@ -104,12 +99,12 @@ describe('Payment', function () {
it(`throws when DestinationTag is not a number`, function () { it(`throws when DestinationTag is not a number`, function () {
paymentTransaction.DestinationTag = '1' paymentTransaction.DestinationTag = '1'
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: DestinationTag must be a number', 'PaymentTransaction: DestinationTag must be a number',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: DestinationTag must be a number', 'PaymentTransaction: DestinationTag must be a number',
) )
@@ -118,12 +113,12 @@ describe('Payment', function () {
it(`throws when InvoiceID is not a string`, function () { it(`throws when InvoiceID is not a string`, function () {
paymentTransaction.InvoiceID = 19832 paymentTransaction.InvoiceID = 19832
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: InvoiceID must be a string', 'PaymentTransaction: InvoiceID must be a string',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: InvoiceID must be a string', 'PaymentTransaction: InvoiceID must be a string',
) )
@@ -132,12 +127,12 @@ describe('Payment', function () {
it(`throws when Paths is invalid`, function () { it(`throws when Paths is invalid`, function () {
paymentTransaction.Paths = [[{ account: 123 }]] paymentTransaction.Paths = [[{ account: 123 }]]
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid Paths', 'PaymentTransaction: invalid Paths',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid Paths', 'PaymentTransaction: invalid Paths',
) )
@@ -146,12 +141,12 @@ describe('Payment', function () {
it(`throws when SendMax is invalid`, function () { it(`throws when SendMax is invalid`, function () {
paymentTransaction.SendMax = 100000000 paymentTransaction.SendMax = 100000000
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid SendMax', 'PaymentTransaction: invalid SendMax',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid SendMax', 'PaymentTransaction: invalid SendMax',
) )
@@ -160,27 +155,27 @@ describe('Payment', function () {
it(`verifies valid DeliverMin with tfPartialPayment flag set as a number`, function () { it(`verifies valid DeliverMin with tfPartialPayment flag set as a number`, function () {
paymentTransaction.DeliverMin = '10000' paymentTransaction.DeliverMin = '10000'
paymentTransaction.Flags = PaymentTransactionFlags.tfPartialPayment paymentTransaction.Flags = PaymentTransactionFlags.tfPartialPayment
assert.doesNotThrow(() => verifyPayment(paymentTransaction)) assert.doesNotThrow(() => validatePayment(paymentTransaction))
assert.doesNotThrow(() => verify(paymentTransaction)) assert.doesNotThrow(() => validate(paymentTransaction))
}) })
it(`verifies valid DeliverMin with tfPartialPayment flag set as a boolean`, function () { it(`verifies valid DeliverMin with tfPartialPayment flag set as a boolean`, function () {
paymentTransaction.DeliverMin = '10000' paymentTransaction.DeliverMin = '10000'
paymentTransaction.Flags = { tfPartialPayment: true } paymentTransaction.Flags = { tfPartialPayment: true }
assert.doesNotThrow(() => verifyPayment(paymentTransaction)) assert.doesNotThrow(() => validatePayment(paymentTransaction))
assert.doesNotThrow(() => verify(paymentTransaction)) assert.doesNotThrow(() => validate(paymentTransaction))
}) })
it(`throws when DeliverMin is invalid`, function () { it(`throws when DeliverMin is invalid`, function () {
paymentTransaction.DeliverMin = 10000 paymentTransaction.DeliverMin = 10000
paymentTransaction.Flags = { tfPartialPayment: true } paymentTransaction.Flags = { tfPartialPayment: true }
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid DeliverMin', 'PaymentTransaction: invalid DeliverMin',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: invalid DeliverMin', 'PaymentTransaction: invalid DeliverMin',
) )
@@ -189,12 +184,12 @@ describe('Payment', function () {
it(`throws when tfPartialPayment flag is missing with valid DeliverMin`, function () { it(`throws when tfPartialPayment flag is missing with valid DeliverMin`, function () {
paymentTransaction.DeliverMin = '10000' paymentTransaction.DeliverMin = '10000'
assert.throws( assert.throws(
() => verifyPayment(paymentTransaction), () => validatePayment(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: tfPartialPayment flag required with DeliverMin', 'PaymentTransaction: tfPartialPayment flag required with DeliverMin',
) )
assert.throws( assert.throws(
() => verify(paymentTransaction), () => validate(paymentTransaction),
ValidationError, ValidationError,
'PaymentTransaction: tfPartialPayment flag required with DeliverMin', 'PaymentTransaction: tfPartialPayment flag required with DeliverMin',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validatePaymentChannelClaim, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyPaymentChannelClaim } from '../../src/models/transactions/paymentChannelClaim'
/** /**
* PaymentChannelClaim Transaction Verification Testing. * PaymentChannelClaim Transaction Verification Testing.
* *
@@ -29,8 +27,8 @@ describe('PaymentChannelClaim', function () {
}) })
it(`verifies valid PaymentChannelClaim`, function () { it(`verifies valid PaymentChannelClaim`, function () {
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel)) assert.doesNotThrow(() => validatePaymentChannelClaim(channel))
assert.doesNotThrow(() => verify(channel)) assert.doesNotThrow(() => validate(channel))
}) })
it(`verifies valid PaymentChannelClaim w/o optional`, function () { it(`verifies valid PaymentChannelClaim w/o optional`, function () {
@@ -39,20 +37,20 @@ describe('PaymentChannelClaim', function () {
delete channel.Signature delete channel.Signature
delete channel.PublicKey delete channel.PublicKey
assert.doesNotThrow(() => verifyPaymentChannelClaim(channel)) assert.doesNotThrow(() => validatePaymentChannelClaim(channel))
assert.doesNotThrow(() => verify(channel)) assert.doesNotThrow(() => validate(channel))
}) })
it(`throws w/ missing Channel`, function () { it(`throws w/ missing Channel`, function () {
delete channel.Channel delete channel.Channel
assert.throws( assert.throws(
() => verifyPaymentChannelClaim(channel), () => validatePaymentChannelClaim(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: missing Channel', 'PaymentChannelClaim: missing Channel',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: missing Channel', 'PaymentChannelClaim: missing Channel',
) )
@@ -62,12 +60,12 @@ describe('PaymentChannelClaim', function () {
channel.Channel = 100 channel.Channel = 100
assert.throws( assert.throws(
() => verifyPaymentChannelClaim(channel), () => validatePaymentChannelClaim(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: Channel must be a string', 'PaymentChannelClaim: Channel must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: Channel must be a string', 'PaymentChannelClaim: Channel must be a string',
) )
@@ -77,12 +75,12 @@ describe('PaymentChannelClaim', function () {
channel.Balance = 100 channel.Balance = 100
assert.throws( assert.throws(
() => verifyPaymentChannelClaim(channel), () => validatePaymentChannelClaim(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: Balance must be a string', 'PaymentChannelClaim: Balance must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: Balance must be a string', 'PaymentChannelClaim: Balance must be a string',
) )
@@ -92,12 +90,12 @@ describe('PaymentChannelClaim', function () {
channel.Amount = 1000 channel.Amount = 1000
assert.throws( assert.throws(
() => verifyPaymentChannelClaim(channel), () => validatePaymentChannelClaim(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: Amount must be a string', 'PaymentChannelClaim: Amount must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: Amount must be a string', 'PaymentChannelClaim: Amount must be a string',
) )
@@ -107,12 +105,12 @@ describe('PaymentChannelClaim', function () {
channel.Signature = 1000 channel.Signature = 1000
assert.throws( assert.throws(
() => verifyPaymentChannelClaim(channel), () => validatePaymentChannelClaim(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: Signature must be a string', 'PaymentChannelClaim: Signature must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: Signature must be a string', 'PaymentChannelClaim: Signature must be a string',
) )
@@ -122,12 +120,12 @@ describe('PaymentChannelClaim', function () {
channel.PublicKey = ['100000'] channel.PublicKey = ['100000']
assert.throws( assert.throws(
() => verifyPaymentChannelClaim(channel), () => validatePaymentChannelClaim(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: PublicKey must be a string', 'PaymentChannelClaim: PublicKey must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelClaim: PublicKey must be a string', 'PaymentChannelClaim: PublicKey must be a string',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validatePaymentChannelCreate, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyPaymentChannelCreate } from '../../src/models/transactions/paymentChannelCreate'
/** /**
* PaymentChannelCreate Transaction Verification Testing. * PaymentChannelCreate Transaction Verification Testing.
* *
@@ -29,8 +27,8 @@ describe('PaymentChannelCreate', function () {
}) })
it(`verifies valid PaymentChannelCreate`, function () { it(`verifies valid PaymentChannelCreate`, function () {
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel)) assert.doesNotThrow(() => validatePaymentChannelCreate(channel))
assert.doesNotThrow(() => verify(channel)) assert.doesNotThrow(() => validate(channel))
}) })
it(`verifies valid PaymentChannelCreate w/o optional`, function () { it(`verifies valid PaymentChannelCreate w/o optional`, function () {
@@ -38,20 +36,20 @@ describe('PaymentChannelCreate', function () {
delete channel.DestinationTag delete channel.DestinationTag
delete channel.SourceTag delete channel.SourceTag
assert.doesNotThrow(() => verifyPaymentChannelCreate(channel)) assert.doesNotThrow(() => validatePaymentChannelCreate(channel))
assert.doesNotThrow(() => verify(channel)) assert.doesNotThrow(() => validate(channel))
}) })
it(`missing Amount`, function () { it(`missing Amount`, function () {
delete channel.Amount delete channel.Amount
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: missing Amount', 'PaymentChannelCreate: missing Amount',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: missing Amount', 'PaymentChannelCreate: missing Amount',
) )
@@ -61,12 +59,12 @@ describe('PaymentChannelCreate', function () {
delete channel.Destination delete channel.Destination
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: missing Destination', 'PaymentChannelCreate: missing Destination',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: missing Destination', 'PaymentChannelCreate: missing Destination',
) )
@@ -76,12 +74,12 @@ describe('PaymentChannelCreate', function () {
delete channel.SettleDelay delete channel.SettleDelay
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: missing SettleDelay', 'PaymentChannelCreate: missing SettleDelay',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: missing SettleDelay', 'PaymentChannelCreate: missing SettleDelay',
) )
@@ -91,12 +89,12 @@ describe('PaymentChannelCreate', function () {
delete channel.PublicKey delete channel.PublicKey
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: missing PublicKey', 'PaymentChannelCreate: missing PublicKey',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: missing PublicKey', 'PaymentChannelCreate: missing PublicKey',
) )
@@ -106,12 +104,12 @@ describe('PaymentChannelCreate', function () {
channel.Amount = 1000 channel.Amount = 1000
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: Amount must be a string', 'PaymentChannelCreate: Amount must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: Amount must be a string', 'PaymentChannelCreate: Amount must be a string',
) )
@@ -121,12 +119,12 @@ describe('PaymentChannelCreate', function () {
channel.Destination = 10 channel.Destination = 10
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: Destination must be a string', 'PaymentChannelCreate: Destination must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: Destination must be a string', 'PaymentChannelCreate: Destination must be a string',
) )
@@ -136,12 +134,12 @@ describe('PaymentChannelCreate', function () {
channel.SettleDelay = '10' channel.SettleDelay = '10'
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: SettleDelay must be a number', 'PaymentChannelCreate: SettleDelay must be a number',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: SettleDelay must be a number', 'PaymentChannelCreate: SettleDelay must be a number',
) )
@@ -151,12 +149,12 @@ describe('PaymentChannelCreate', function () {
channel.PublicKey = 10 channel.PublicKey = 10
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: PublicKey must be a string', 'PaymentChannelCreate: PublicKey must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: PublicKey must be a string', 'PaymentChannelCreate: PublicKey must be a string',
) )
@@ -166,12 +164,12 @@ describe('PaymentChannelCreate', function () {
channel.DestinationTag = '10' channel.DestinationTag = '10'
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: DestinationTag must be a number', 'PaymentChannelCreate: DestinationTag must be a number',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: DestinationTag must be a number', 'PaymentChannelCreate: DestinationTag must be a number',
) )
@@ -181,12 +179,12 @@ describe('PaymentChannelCreate', function () {
channel.CancelAfter = '100' channel.CancelAfter = '100'
assert.throws( assert.throws(
() => verifyPaymentChannelCreate(channel), () => validatePaymentChannelCreate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: CancelAfter must be a number', 'PaymentChannelCreate: CancelAfter must be a number',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelCreate: CancelAfter must be a number', 'PaymentChannelCreate: CancelAfter must be a number',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validatePaymentChannelFund, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyPaymentChannelFund } from '../../src/models/transactions/paymentChannelFund'
/** /**
* PaymentChannelFund Transaction Verification Testing. * PaymentChannelFund Transaction Verification Testing.
* *
@@ -25,27 +23,27 @@ describe('PaymentChannelFund', function () {
}) })
it(`verifies valid PaymentChannelFund`, function () { it(`verifies valid PaymentChannelFund`, function () {
assert.doesNotThrow(() => verifyPaymentChannelFund(channel)) assert.doesNotThrow(() => validatePaymentChannelFund(channel))
assert.doesNotThrow(() => verify(channel)) assert.doesNotThrow(() => validate(channel))
}) })
it(`verifies valid PaymentChannelFund w/o optional`, function () { it(`verifies valid PaymentChannelFund w/o optional`, function () {
delete channel.Expiration delete channel.Expiration
assert.doesNotThrow(() => verifyPaymentChannelFund(channel)) assert.doesNotThrow(() => validatePaymentChannelFund(channel))
assert.doesNotThrow(() => verify(channel)) assert.doesNotThrow(() => validate(channel))
}) })
it(`throws w/ missing Amount`, function () { it(`throws w/ missing Amount`, function () {
delete channel.Amount delete channel.Amount
assert.throws( assert.throws(
() => verifyPaymentChannelFund(channel), () => validatePaymentChannelFund(channel),
ValidationError, ValidationError,
'PaymentChannelFund: missing Amount', 'PaymentChannelFund: missing Amount',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelFund: missing Amount', 'PaymentChannelFund: missing Amount',
) )
@@ -55,12 +53,12 @@ describe('PaymentChannelFund', function () {
delete channel.Channel delete channel.Channel
assert.throws( assert.throws(
() => verifyPaymentChannelFund(channel), () => validatePaymentChannelFund(channel),
ValidationError, ValidationError,
'PaymentChannelFund: missing Channel', 'PaymentChannelFund: missing Channel',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelFund: missing Channel', 'PaymentChannelFund: missing Channel',
) )
@@ -70,12 +68,12 @@ describe('PaymentChannelFund', function () {
channel.Amount = 100 channel.Amount = 100
assert.throws( assert.throws(
() => verifyPaymentChannelFund(channel), () => validatePaymentChannelFund(channel),
ValidationError, ValidationError,
'PaymentChannelFund: Amount must be a string', 'PaymentChannelFund: Amount must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelFund: Amount must be a string', 'PaymentChannelFund: Amount must be a string',
) )
@@ -85,12 +83,12 @@ describe('PaymentChannelFund', function () {
channel.Channel = 1000 channel.Channel = 1000
assert.throws( assert.throws(
() => verifyPaymentChannelFund(channel), () => validatePaymentChannelFund(channel),
ValidationError, ValidationError,
'PaymentChannelFund: Channel must be a string', 'PaymentChannelFund: Channel must be a string',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelFund: Channel must be a string', 'PaymentChannelFund: Channel must be a string',
) )
@@ -100,12 +98,12 @@ describe('PaymentChannelFund', function () {
channel.Expiration = '1000' channel.Expiration = '1000'
assert.throws( assert.throws(
() => verifyPaymentChannelFund(channel), () => validatePaymentChannelFund(channel),
ValidationError, ValidationError,
'PaymentChannelFund: Expiration must be a number', 'PaymentChannelFund: Expiration must be a number',
) )
assert.throws( assert.throws(
() => verify(channel), () => validate(channel),
ValidationError, ValidationError,
'PaymentChannelFund: Expiration must be a number', 'PaymentChannelFund: Expiration must be a number',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validate, validateSetRegularKey } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifySetRegularKey } from '../../src/models/transactions/setRegularKey'
/** /**
* SetRegularKey Transaction Verification Testing. * SetRegularKey Transaction Verification Testing.
* *
@@ -24,26 +22,26 @@ describe('SetRegularKey', function () {
}) })
it(`verifies valid SetRegularKey`, function () { it(`verifies valid SetRegularKey`, function () {
assert.doesNotThrow(() => verifySetRegularKey(account)) assert.doesNotThrow(() => validateSetRegularKey(account))
assert.doesNotThrow(() => verify(account)) assert.doesNotThrow(() => validate(account))
}) })
it(`verifies w/o SetRegularKey`, function () { it(`verifies w/o SetRegularKey`, function () {
account.RegularKey = undefined account.RegularKey = undefined
assert.doesNotThrow(() => verifySetRegularKey(account)) assert.doesNotThrow(() => validateSetRegularKey(account))
assert.doesNotThrow(() => verify(account)) assert.doesNotThrow(() => validate(account))
}) })
it(`throws w/ invalid RegularKey`, function () { it(`throws w/ invalid RegularKey`, function () {
account.RegularKey = 12369846963 account.RegularKey = 12369846963
assert.throws( assert.throws(
() => verifySetRegularKey(account), () => validateSetRegularKey(account),
ValidationError, ValidationError,
'SetRegularKey: RegularKey must be a string', 'SetRegularKey: RegularKey must be a string',
) )
assert.throws( assert.throws(
() => verify(account), () => validate(account),
ValidationError, ValidationError,
'SetRegularKey: RegularKey must be a string', 'SetRegularKey: RegularKey must be a string',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validate, validateSignerListSet } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifySignerListSet } from '../../src/models/transactions/signerListSet'
/** /**
* SignerListSet Transaction Verification Testing. * SignerListSet Transaction Verification Testing.
* *
@@ -44,20 +42,20 @@ describe('SignerListSet', function () {
}) })
it(`verifies valid SignerListSet`, function () { it(`verifies valid SignerListSet`, function () {
assert.doesNotThrow(() => verifySignerListSet(signerListSetTx)) assert.doesNotThrow(() => validateSignerListSet(signerListSetTx))
assert.doesNotThrow(() => verify(signerListSetTx)) assert.doesNotThrow(() => validate(signerListSetTx))
}) })
it(`throws w/ missing SignerQuorum`, function () { it(`throws w/ missing SignerQuorum`, function () {
signerListSetTx.SignerQuorum = undefined signerListSetTx.SignerQuorum = undefined
assert.throws( assert.throws(
() => verifySignerListSet(signerListSetTx), () => validateSignerListSet(signerListSetTx),
ValidationError, ValidationError,
'SignerListSet: missing field SignerQuorum', 'SignerListSet: missing field SignerQuorum',
) )
assert.throws( assert.throws(
() => verify(signerListSetTx), () => validate(signerListSetTx),
ValidationError, ValidationError,
'SignerListSet: missing field SignerQuorum', 'SignerListSet: missing field SignerQuorum',
) )
@@ -67,12 +65,12 @@ describe('SignerListSet', function () {
signerListSetTx.SignerEntries = [] signerListSetTx.SignerEntries = []
assert.throws( assert.throws(
() => verifySignerListSet(signerListSetTx), () => validateSignerListSet(signerListSetTx),
ValidationError, ValidationError,
'SignerListSet: need atleast 1 member in SignerEntries', 'SignerListSet: need atleast 1 member in SignerEntries',
) )
assert.throws( assert.throws(
() => verify(signerListSetTx), () => validate(signerListSetTx),
ValidationError, ValidationError,
'SignerListSet: need atleast 1 member in SignerEntries', 'SignerListSet: need atleast 1 member in SignerEntries',
) )
@@ -82,12 +80,12 @@ describe('SignerListSet', function () {
signerListSetTx.SignerEntries = 'khgfgyhujk' signerListSetTx.SignerEntries = 'khgfgyhujk'
assert.throws( assert.throws(
() => verifySignerListSet(signerListSetTx), () => validateSignerListSet(signerListSetTx),
ValidationError, ValidationError,
'SignerListSet: invalid SignerEntries', 'SignerListSet: invalid SignerEntries',
) )
assert.throws( assert.throws(
() => verify(signerListSetTx), () => validate(signerListSetTx),
ValidationError, ValidationError,
'SignerListSet: invalid SignerEntries', 'SignerListSet: invalid SignerEntries',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateTicketCreate, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyTicketCreate } from '../../src/models/transactions/ticketCreate'
/** /**
* TicketCreate Transaction Verification Testing. * TicketCreate Transaction Verification Testing.
* *
@@ -22,19 +20,19 @@ describe('TicketCreate', function () {
}) })
it('verifies valid TicketCreate', function () { it('verifies valid TicketCreate', function () {
assert.doesNotThrow(() => verifyTicketCreate(ticketCreate)) assert.doesNotThrow(() => validateTicketCreate(ticketCreate))
assert.doesNotThrow(() => verify(ticketCreate)) assert.doesNotThrow(() => validate(ticketCreate))
}) })
it('throws when TicketCount is missing', function () { it('throws when TicketCount is missing', function () {
delete ticketCreate.TicketCount delete ticketCreate.TicketCount
assert.throws( assert.throws(
() => verifyTicketCreate(ticketCreate), () => validateTicketCreate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: missing field TicketCount', 'TicketCreate: missing field TicketCount',
) )
assert.throws( assert.throws(
() => verify(ticketCreate), () => validate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: missing field TicketCount', 'TicketCreate: missing field TicketCount',
) )
@@ -43,12 +41,12 @@ describe('TicketCreate', function () {
it('throws when TicketCount is not a number', function () { it('throws when TicketCount is not a number', function () {
ticketCreate.TicketCount = '150' ticketCreate.TicketCount = '150'
assert.throws( assert.throws(
() => verifyTicketCreate(ticketCreate), () => validateTicketCreate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: TicketCount must be a number', 'TicketCreate: TicketCount must be a number',
) )
assert.throws( assert.throws(
() => verify(ticketCreate), () => validate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: TicketCount must be a number', 'TicketCreate: TicketCount must be a number',
) )
@@ -57,12 +55,12 @@ describe('TicketCreate', function () {
it('throws when TicketCount is not an integer', function () { it('throws when TicketCount is not an integer', function () {
ticketCreate.TicketCount = 12.5 ticketCreate.TicketCount = 12.5
assert.throws( assert.throws(
() => verifyTicketCreate(ticketCreate), () => validateTicketCreate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250', 'TicketCreate: TicketCount must be an integer from 1 to 250',
) )
assert.throws( assert.throws(
() => verify(ticketCreate), () => validate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250', 'TicketCreate: TicketCount must be an integer from 1 to 250',
) )
@@ -71,12 +69,12 @@ describe('TicketCreate', function () {
it('throws when TicketCount is < 1', function () { it('throws when TicketCount is < 1', function () {
ticketCreate.TicketCount = 0 ticketCreate.TicketCount = 0
assert.throws( assert.throws(
() => verifyTicketCreate(ticketCreate), () => validateTicketCreate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250', 'TicketCreate: TicketCount must be an integer from 1 to 250',
) )
assert.throws( assert.throws(
() => verify(ticketCreate), () => validate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250', 'TicketCreate: TicketCount must be an integer from 1 to 250',
) )
@@ -85,12 +83,12 @@ describe('TicketCreate', function () {
it('throws when TicketCount is > 250', function () { it('throws when TicketCount is > 250', function () {
ticketCreate.TicketCount = 251 ticketCreate.TicketCount = 251
assert.throws( assert.throws(
() => verifyTicketCreate(ticketCreate), () => validateTicketCreate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250', 'TicketCreate: TicketCount must be an integer from 1 to 250',
) )
assert.throws( assert.throws(
() => verify(ticketCreate), () => validate(ticketCreate),
ValidationError, ValidationError,
'TicketCreate: TicketCount must be an integer from 1 to 250', 'TicketCreate: TicketCount must be an integer from 1 to 250',
) )

View File

@@ -1,10 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { validateTrustSet, validate } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { verify } from '../../src/models/transactions'
import { verifyTrustSet } from '../../src/models/transactions/trustSet'
/** /**
* TrustSet Transaction Verification Testing. * TrustSet Transaction Verification Testing.
* *
@@ -28,19 +26,19 @@ describe('TrustSet', function () {
}) })
it('verifies valid TrustSet', function () { it('verifies valid TrustSet', function () {
assert.doesNotThrow(() => verifyTrustSet(trustSet)) assert.doesNotThrow(() => validateTrustSet(trustSet))
assert.doesNotThrow(() => verify(trustSet)) assert.doesNotThrow(() => validate(trustSet))
}) })
it('throws when LimitAmount is missing', function () { it('throws when LimitAmount is missing', function () {
delete trustSet.LimitAmount delete trustSet.LimitAmount
assert.throws( assert.throws(
() => verifyTrustSet(trustSet), () => validateTrustSet(trustSet),
ValidationError, ValidationError,
'TrustSet: missing field LimitAmount', 'TrustSet: missing field LimitAmount',
) )
assert.throws( assert.throws(
() => verify(trustSet), () => validate(trustSet),
ValidationError, ValidationError,
'TrustSet: missing field LimitAmount', 'TrustSet: missing field LimitAmount',
) )
@@ -49,12 +47,12 @@ describe('TrustSet', function () {
it('throws when LimitAmount is invalid', function () { it('throws when LimitAmount is invalid', function () {
trustSet.LimitAmount = 1234 trustSet.LimitAmount = 1234
assert.throws( assert.throws(
() => verifyTrustSet(trustSet), () => validateTrustSet(trustSet),
ValidationError, ValidationError,
'TrustSet: invalid LimitAmount', 'TrustSet: invalid LimitAmount',
) )
assert.throws( assert.throws(
() => verify(trustSet), () => validate(trustSet),
ValidationError, ValidationError,
'TrustSet: invalid LimitAmount', 'TrustSet: invalid LimitAmount',
) )
@@ -63,12 +61,12 @@ describe('TrustSet', function () {
it('throws when QualityIn is not a number', function () { it('throws when QualityIn is not a number', function () {
trustSet.QualityIn = '1234' trustSet.QualityIn = '1234'
assert.throws( assert.throws(
() => verifyTrustSet(trustSet), () => validateTrustSet(trustSet),
ValidationError, ValidationError,
'TrustSet: QualityIn must be a number', 'TrustSet: QualityIn must be a number',
) )
assert.throws( assert.throws(
() => verify(trustSet), () => validate(trustSet),
ValidationError, ValidationError,
'TrustSet: QualityIn must be a number', 'TrustSet: QualityIn must be a number',
) )
@@ -77,12 +75,12 @@ describe('TrustSet', function () {
it('throws when QualityOut is not a number', function () { it('throws when QualityOut is not a number', function () {
trustSet.QualityOut = '4321' trustSet.QualityOut = '4321'
assert.throws( assert.throws(
() => verifyTrustSet(trustSet), () => validateTrustSet(trustSet),
ValidationError, ValidationError,
'TrustSet: QualityOut must be a number', 'TrustSet: QualityOut must be a number',
) )
assert.throws( assert.throws(
() => verify(trustSet), () => validate(trustSet),
ValidationError, ValidationError,
'TrustSet: QualityOut must be a number', 'TrustSet: QualityOut must be a number',
) )

View File

@@ -11,7 +11,8 @@ import {
PaymentTransactionFlags, PaymentTransactionFlags,
TrustSet, TrustSet,
TrustSetTransactionFlags, TrustSetTransactionFlags,
} from '../../src/models/transactions' } from 'xrpl-local'
import { import {
isFlagEnabled, isFlagEnabled,
setTransactionFlagsToNumber, setTransactionFlagsToNumber,

View File

@@ -4,9 +4,9 @@ import path from 'path'
import { assert } from 'chai' import { assert } from 'chai'
import { encode } from 'ripple-binary-codec' import { encode } from 'ripple-binary-codec'
import { OfferCreate, Transaction } from 'xrpl-local'
import { ValidationError } from 'xrpl-local/common/errors' import { ValidationError } from 'xrpl-local/common/errors'
import { OfferCreate, Transaction } from '../../src/models/transactions'
import { import {
computeStateTreeHash, computeStateTreeHash,
computeTransactionTreeHash, computeTransactionTreeHash,

View File

@@ -1,7 +1,8 @@
import { assert } from 'chai' import { assert } from 'chai'
import { Payment } from 'xrpl-local'
import ECDSA from '../../src/common/ecdsa' import ECDSA from '../../src/common/ecdsa'
import { Payment } from '../../src/models/transactions'
import Wallet from '../../src/wallet' import Wallet from '../../src/wallet'
/** /**

View File

@@ -2,8 +2,9 @@ import { assert } from 'chai'
import { decode, encode } from 'ripple-binary-codec/dist' import { decode, encode } from 'ripple-binary-codec/dist'
import { JsonObject } from 'ripple-binary-codec/dist/types/serialized-type' import { JsonObject } from 'ripple-binary-codec/dist/types/serialized-type'
import { Transaction } from 'xrpl-local'
import { ValidationError } from '../../src/common/errors' import { ValidationError } from '../../src/common/errors'
import { Transaction } from '../../src/models/transactions'
import Wallet from '../../src/wallet' import Wallet from '../../src/wallet'
import { import {
sign, sign,