Files
xahau.js/packages/xrpl/test/models/NFTokenMint.test.ts
Alexey Novikov 97ff2aa104 Issue 2212. Improve NFToken.URI handling for empty and undefined values (#2218)
* Handle undefined and null values in transactions better.
2023-03-09 13:34:28 -08:00

111 lines
2.9 KiB
TypeScript

import { assert } from 'chai'
import {
convertStringToHex,
validate,
ValidationError,
NFTokenMintFlags,
} from '../../src'
/**
* NFTokenMint Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe('NFTokenMint', function () {
it(`verifies valid NFTokenMint`, function () {
const validNFTokenMint = {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
NFTokenTaxon: 0,
Issuer: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
TransferFee: 1,
URI: convertStringToHex('http://xrpl.org'),
} as any
assert.doesNotThrow(() => validate(validNFTokenMint))
})
it(`throws w/ missing NFTokenTaxon`, function () {
const invalid = {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
Issuer: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
TransferFee: 1,
URI: convertStringToHex('http://xrpl.org'),
} as any
assert.throws(
() => validate(invalid),
ValidationError,
'NFTokenMint: missing field NFTokenTaxon',
)
})
it(`throws w/ Account === Issuer`, function () {
const invalid = {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
Issuer: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
TransferFee: 1,
NFTokenTaxon: 0,
URI: convertStringToHex('http://xrpl.org'),
} as any
assert.throws(
() => validate(invalid),
ValidationError,
'NFTokenMint: Issuer must not be equal to Account',
)
})
it(`throws w/ URI being an empty string`, function () {
const invalid = {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
NFTokenTaxon: 0,
Issuer: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
TransferFee: 1,
URI: '',
} as any
assert.throws(
() => validate(invalid),
ValidationError,
'NFTokenMint: URI must not be empty string',
)
})
it(`throws w/ URI not in hex format`, function () {
const invalid = {
TransactionType: 'NFTokenMint',
Account: 'rWYkbWkCeg8dP6rXALnjgZSjjLyih5NXm',
Fee: '5000000',
Sequence: 2470665,
Flags: NFTokenMintFlags.tfTransferable,
NFTokenTaxon: 0,
Issuer: 'r9LqNeG6qHxjeUocjvVki2XR35weJ9mZgQ',
TransferFee: 1,
URI: 'http://xrpl.org',
} as any
assert.throws(
() => validate(invalid),
ValidationError,
'NFTokenMint: URI must be in hex format',
)
})
})