mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
* rename RippleAPI -> XrplClient * more renames * move API stuff to client folder * rename all api -> client * fix tests * make tests run * fix integ tests * fix urls * fix merge issues * XrplClient -> Client * fix merge issues * rename xrpl-client npm symlink to xrpl-local
84 lines
2.7 KiB
TypeScript
84 lines
2.7 KiB
TypeScript
import { ValidationError } from 'xrpl-local/common/errors'
|
|
import { verifyCheckCash } from './../../src/models/transactions/checkCash'
|
|
import { assert } from 'chai'
|
|
|
|
/**
|
|
* CheckCash Transaction Verification Testing
|
|
*
|
|
* Providing runtime verification testing for each specific transaction type
|
|
*/
|
|
describe('CheckCash Transaction Verification', function () {
|
|
|
|
it (`verifies valid CheckCash`, () => {
|
|
const validCheckCash = {
|
|
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
|
|
TransactionType : "CheckCash",
|
|
Amount : "100000000",
|
|
CheckID : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334",
|
|
Fee : "12"
|
|
} as any
|
|
|
|
assert.doesNotThrow(() => verifyCheckCash(validCheckCash))
|
|
})
|
|
|
|
it (`throws w/ invalid CheckID`, () => {
|
|
const invalidCheckID = {
|
|
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
|
|
TransactionType : "CheckCash",
|
|
Amount : "100000000",
|
|
CheckID : 83876645678909854567890
|
|
} as any
|
|
|
|
assert.throws(
|
|
() => verifyCheckCash(invalidCheckID),
|
|
ValidationError,
|
|
"CheckCash: invalid CheckID"
|
|
)
|
|
})
|
|
|
|
it (`throws w/ invalid Amount`, () => {
|
|
const invalidAmount = {
|
|
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
|
|
TransactionType : "CheckCash",
|
|
Amount : 100000000,
|
|
CheckID : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
|
|
} as any
|
|
|
|
assert.throws(
|
|
() => verifyCheckCash(invalidAmount),
|
|
ValidationError,
|
|
"CheckCash: invalid Amount"
|
|
)
|
|
})
|
|
|
|
it (`throws w/ having both Amount and DeliverMin`, () => {
|
|
const invalidDeliverMin = {
|
|
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
|
|
TransactionType : "CheckCash",
|
|
Amount : "100000000",
|
|
DeliverMin: 852156963,
|
|
CheckID : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
|
|
} as any
|
|
|
|
assert.throws(
|
|
() => verifyCheckCash(invalidDeliverMin),
|
|
ValidationError,
|
|
"CheckCash: cannot have both Amount and DeliverMin"
|
|
)
|
|
})
|
|
|
|
it (`throws w/ invalid DeliverMin`, () => {
|
|
const invalidDeliverMin = {
|
|
Account : "rfkE1aSy9G8Upk4JssnwBxhEv5p4mn2KTy",
|
|
TransactionType : "CheckCash",
|
|
DeliverMin: 852156963,
|
|
CheckID : "838766BA2B995C00744175F69A1B11E32C3DBC40E64801A4056FCBD657F57334"
|
|
} as any
|
|
|
|
assert.throws(
|
|
() => verifyCheckCash(invalidDeliverMin),
|
|
ValidationError,
|
|
"CheckCash: invalid DeliverMin"
|
|
)
|
|
})
|
|
}) |