mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 01:08:02 +00:00
feat: add support for current sidechain design (#2039)
* Update definitions.json * add new st types * add tests * add XChainClaim tx * add XChainCommit tx * add XChainCreateBridge tx * add XChainCreateClaimID tx * update definitions.json * rename Bridge -> XChainBridge in binary codec, fix tests * rename Bridge -> XChainBridge in models * add codec support for XChainAddAttestation * add XChainAddAttestation model * undo debugging change * fix linting issues * update definitions.json for new rippled code, add new tests/update old tests * add/update models * update history * update binary-codec * add XChainModifyBridge model * update RPCs * update to latest rippled * more fixes * fix definitions.json * fix spacing * update definitions.json to avoid conflict with amm * update definitions.json to resolve amm conflicts * audit code * more updates * update rpcs * switch to beta version * add destination tag to XChainClaim * rename IssuedCurrency -> Issue to match rippled * update Issue form * fix account object filters * fix issue from typing * fix LedgerEntry types * fix attestation destination type * Update definitions.json * rename XChainAddAttestation -> XChainAddAttestationBatch * add XChainAddClaimAttestation * add XChainAddAccountCreateAttestation * remove XChainAddAttestationBatch * update definitions * fix attestation txns * fix attestation object * add validate for new txs * add Bridge ledger object * add XChainOwnedClaimID ledger object * add XChainOwnedCreateAccountClaimID ledger object * update account_objects * update models to latest rippled * fix minor issues * fix bridge ledger_entry * add XChainModifyBridge flag * Update definitions.json * add rbc tests for the new txs * update validateXChainModifyBridge * add validate methods to other xchain txs * fix isXChainBridge * fix isIssue typing * fix model types * update changelog * switch prepare to prepublishOnly * add docs * fix AccountObjectsType filter * export common types * fix account_objects filter * update LedgerEntry * add sidechain faucet info * add snippet * improve snippet * fix spacing issues * update ledger_entry * remove AMMDelete tests for now * Update definitions.json * fix unit tests * convert createValidate script to JS * remove unneeded linter ignores * respond to comments * more snippet fixes * make validate functions more readable * add getXChainClaimID method to parse metadata * re-add linter rules * clean up common * fix getXChainClaimID test * return undefined for failed tx * test: add model tests for new sidechain transactions (#2059) * add XChainAddAttestation tests, fix model * add XChainClaim model tests * add XChainCommit model tests, fix typo * add XChainCreateBridge model tests * add XChainCreateClaimID model tests * add XChainModifyBridge tests * update to most recent version of code * remove XChainAddAttestationBatch tests * add more validation tests * switch createValidateTests to JS
This commit is contained in:
130
packages/xrpl/test/models/XChainCreateClaimID.test.ts
Normal file
130
packages/xrpl/test/models/XChainCreateClaimID.test.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { validate, ValidationError } from '../../src'
|
||||
import { validateXChainCreateClaimID } from '../../src/models/transactions/XChainCreateClaimID'
|
||||
|
||||
/**
|
||||
* XChainCreateClaimID Transaction Verification Testing.
|
||||
*
|
||||
* Providing runtime verification testing for each specific transaction type.
|
||||
*/
|
||||
describe('XChainCreateClaimID', function () {
|
||||
let tx
|
||||
|
||||
beforeEach(function () {
|
||||
tx = {
|
||||
Account: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
|
||||
XChainBridge: {
|
||||
LockingChainDoor: 'rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL',
|
||||
LockingChainIssue: {
|
||||
currency: 'XRP',
|
||||
},
|
||||
IssuingChainDoor: 'r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV',
|
||||
IssuingChainIssue: {
|
||||
currency: 'XRP',
|
||||
},
|
||||
},
|
||||
Fee: '10',
|
||||
Flags: 2147483648,
|
||||
OtherChainSource: 'rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL',
|
||||
Sequence: 1,
|
||||
SignatureReward: '10000',
|
||||
TransactionType: 'XChainCreateClaimID',
|
||||
} as any
|
||||
})
|
||||
|
||||
it('verifies valid XChainCreateClaimID', function () {
|
||||
assert.doesNotThrow(() => validateXChainCreateClaimID(tx))
|
||||
assert.doesNotThrow(() => validate(tx))
|
||||
})
|
||||
|
||||
it('throws w/ missing XChainBridge', function () {
|
||||
delete tx.XChainBridge
|
||||
|
||||
assert.throws(
|
||||
() => validateXChainCreateClaimID(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: missing field XChainBridge',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: missing field XChainBridge',
|
||||
)
|
||||
})
|
||||
|
||||
it('throws w/ invalid XChainBridge', function () {
|
||||
tx.XChainBridge = { XChainDoor: 'test' }
|
||||
|
||||
assert.throws(
|
||||
() => validateXChainCreateClaimID(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: invalid field XChainBridge',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: invalid field XChainBridge',
|
||||
)
|
||||
})
|
||||
|
||||
it('throws w/ missing SignatureReward', function () {
|
||||
delete tx.SignatureReward
|
||||
|
||||
assert.throws(
|
||||
() => validateXChainCreateClaimID(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: missing field SignatureReward',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: missing field SignatureReward',
|
||||
)
|
||||
})
|
||||
|
||||
it('throws w/ invalid SignatureReward', function () {
|
||||
tx.SignatureReward = { currency: 'ETH' }
|
||||
|
||||
assert.throws(
|
||||
() => validateXChainCreateClaimID(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: invalid field SignatureReward',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: invalid field SignatureReward',
|
||||
)
|
||||
})
|
||||
|
||||
it('throws w/ missing OtherChainSource', function () {
|
||||
delete tx.OtherChainSource
|
||||
|
||||
assert.throws(
|
||||
() => validateXChainCreateClaimID(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: missing field OtherChainSource',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: missing field OtherChainSource',
|
||||
)
|
||||
})
|
||||
|
||||
it('throws w/ invalid OtherChainSource', function () {
|
||||
tx.OtherChainSource = 123
|
||||
|
||||
assert.throws(
|
||||
() => validateXChainCreateClaimID(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: invalid field OtherChainSource',
|
||||
)
|
||||
assert.throws(
|
||||
() => validate(tx),
|
||||
ValidationError,
|
||||
'XChainCreateClaimID: invalid field OtherChainSource',
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user