mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-18 11:15:48 +00:00
* create credentials obj, modify depositpreauth * structrure of transaction models * initial validation methods and modify transactions affected by deposit auth * cleanup and add new transactions to list * binarycodec and add amendments to config * methods account for credentials * binary codec update * add amendments to config * error validation for credentials actions * core logic of error validation completed * type checking in error validation * init test files and field type validations * basic tests for crud transactions * cred delete tests * cred accept unit tests * cred create and accept unit tests * cred delete unit tests * depositPreauth unit tests * generic checks for payment, paymentchannelclaim, escrowfinish credential list * ledger entry update * lint errors * cleanup and use helper methods * fix lint bug * init integration tests for new transactions * fix build error, integration test docker update * unit test fixes -- all pass now * integration test layout complete * integration command * integration tests run * cicd command edit * lint and cleanup * modified history markdown * deposit preauth integration update * update docs with new docker command * fix validation for string id credential arrays * exports * add flag * lint * fix typo in contributing doc * docstring typos * readable string * fix test' * review comment fixes * txn duplicate fix * Apply suggestions from code review Co-authored-by: Omar Khan <khancodegt@gmail.com> Co-authored-by: Mayukha Vadari <mvadari@ripple.com> * Apply suggestions from code review Co-authored-by: Omar Khan <khancodegt@gmail.com> * Apply suggestions from code review Co-authored-by: Omar Khan <khancodegt@gmail.com> Co-authored-by: Mayukha Vadari <mvadari@ripple.com> * typo in auto suggest * rebase * readd definitions after rebase * cleanup list val * unit tests fixed and running * lint * refactor authcred check to work * Update packages/xrpl/src/models/transactions/payment.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * typo * Update .ci-config/rippled.cfg Co-authored-by: Omar Khan <khancodegt@gmail.com> * update rippled version * optional field nits * add to response depositauthorize * Update packages/xrpl/src/models/transactions/CredentialCreate.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * Update packages/xrpl/src/models/transactions/CredentialDelete.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * Update packages/xrpl/src/models/transactions/accountDelete.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * Apply suggestions from code review Co-authored-by: Omar Khan <khancodegt@gmail.com> * cleanups * unit test fix * more escrowfinish tests * clearer error message * re add statement * undo autodeleted mandates * remove extraneous integration tests for now * lint * Update .ci-config/rippled.cfg Co-authored-by: Omar Khan <khancodegt@gmail.com> * Update packages/xrpl/src/models/transactions/common.ts Co-authored-by: Omar Khan <khancodegt@gmail.com> * added tests * typo --------- Co-authored-by: Omar Khan <khancodegt@gmail.com> Co-authored-by: Mayukha Vadari <mvadari@ripple.com>
193 lines
5.6 KiB
TypeScript
193 lines
5.6 KiB
TypeScript
import { assert } from 'chai'
|
|
|
|
import { validate, ValidationError } from '../../src'
|
|
import { validateEscrowFinish } from '../../src/models/transactions/escrowFinish'
|
|
|
|
/**
|
|
* EscrowFinish Transaction Verification Testing.
|
|
*
|
|
* Providing runtime verification testing for each specific transaction type.
|
|
*/
|
|
describe('EscrowFinish', function () {
|
|
let escrow
|
|
|
|
beforeEach(function () {
|
|
escrow = {
|
|
Account: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
|
|
TransactionType: 'EscrowFinish',
|
|
Owner: 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn',
|
|
OfferSequence: 7,
|
|
Condition:
|
|
'A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100',
|
|
Fulfillment: 'A0028000',
|
|
CredentialIDs: [
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F66A',
|
|
],
|
|
}
|
|
})
|
|
it(`verifies valid EscrowFinish`, function () {
|
|
assert.doesNotThrow(() => validateEscrowFinish(escrow))
|
|
assert.doesNotThrow(() => validate(escrow))
|
|
})
|
|
|
|
it(`verifies valid EscrowFinish w/o optional`, function () {
|
|
escrow.Condition = undefined
|
|
escrow.Fulfillment = undefined
|
|
escrow.CredentialIDs = undefined
|
|
|
|
assert.doesNotThrow(() => validateEscrowFinish(escrow))
|
|
assert.doesNotThrow(() => validate(escrow))
|
|
})
|
|
|
|
it(`verifies valid EscrowFinish w/string OfferSequence`, function () {
|
|
escrow.OfferSequence = '7'
|
|
|
|
assert.doesNotThrow(() => validateEscrowFinish(escrow))
|
|
assert.doesNotThrow(() => validate(escrow))
|
|
})
|
|
|
|
it(`throws w/ invalid Owner`, function () {
|
|
escrow.Owner = 0x15415253
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
'EscrowFinish: invalid field Owner',
|
|
)
|
|
assert.throws(
|
|
() => validate(escrow),
|
|
ValidationError,
|
|
'EscrowFinish: invalid field Owner',
|
|
)
|
|
})
|
|
|
|
it(`throws w/ invalid OfferSequence`, function () {
|
|
escrow.OfferSequence = 'random'
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
'EscrowFinish: OfferSequence must be a number',
|
|
)
|
|
assert.throws(
|
|
() => validate(escrow),
|
|
ValidationError,
|
|
'EscrowFinish: OfferSequence must be a number',
|
|
)
|
|
})
|
|
|
|
it(`throws w/ invalid Condition`, function () {
|
|
escrow.Condition = 10
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
'EscrowFinish: Condition must be a string',
|
|
)
|
|
assert.throws(
|
|
() => validate(escrow),
|
|
ValidationError,
|
|
'EscrowFinish: Condition must be a string',
|
|
)
|
|
})
|
|
|
|
it(`throws w/ invalid Fulfillment`, function () {
|
|
escrow.Fulfillment = 0x142341
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
'EscrowFinish: Fulfillment must be a string',
|
|
)
|
|
assert.throws(
|
|
() => validate(escrow),
|
|
ValidationError,
|
|
'EscrowFinish: Fulfillment must be a string',
|
|
)
|
|
})
|
|
|
|
it(`throws w/ non-array CredentialIDs`, function () {
|
|
escrow.CredentialIDs =
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F66A'
|
|
|
|
const errorMessage = 'EscrowFinish: Credentials must be an array'
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
errorMessage,
|
|
)
|
|
assert.throws(() => validate(escrow), ValidationError, errorMessage)
|
|
})
|
|
|
|
it(`throws CredentialIDs length exceeds max length`, function () {
|
|
escrow.CredentialIDs = [
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F66A',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F66B',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F66C',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F66D',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F66E',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F66F',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F660',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F661',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F662',
|
|
]
|
|
|
|
const errorMessage =
|
|
'EscrowFinish: Credentials length cannot exceed 8 elements'
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
errorMessage,
|
|
)
|
|
assert.throws(() => validate(escrow), ValidationError, errorMessage)
|
|
})
|
|
|
|
it(`throws w/ empty CredentialIDs`, function () {
|
|
escrow.CredentialIDs = []
|
|
|
|
const errorMessage = 'EscrowFinish: Credentials cannot be an empty array'
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
errorMessage,
|
|
)
|
|
assert.throws(() => validate(escrow), ValidationError, errorMessage)
|
|
})
|
|
|
|
it(`throws w/ non-string CredentialIDs`, function () {
|
|
escrow.CredentialIDs = [
|
|
123123,
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F662',
|
|
]
|
|
|
|
const errorMessage = 'EscrowFinish: Invalid Credentials ID list format'
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
errorMessage,
|
|
)
|
|
assert.throws(() => validate(escrow), ValidationError, errorMessage)
|
|
})
|
|
|
|
it(`throws w/ duplicate CredentialIDs`, function () {
|
|
escrow.CredentialIDs = [
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F662',
|
|
'EA85602C1B41F6F1F5E83C0E6B87142FB8957BD209469E4CC347BA2D0C26F662',
|
|
]
|
|
|
|
const errorMessage =
|
|
'EscrowFinish: Credentials cannot contain duplicate elements'
|
|
|
|
assert.throws(
|
|
() => validateEscrowFinish(escrow),
|
|
ValidationError,
|
|
errorMessage,
|
|
)
|
|
assert.throws(() => validate(escrow), ValidationError, errorMessage)
|
|
})
|
|
})
|