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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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