Files
xahau.js/packages/xrpl/test/models/XChainAddAccountCreateAttestation.test.ts
Mayukha Vadari 91e7369f1b 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
2023-09-26 10:01:21 -04:00

382 lines
11 KiB
TypeScript

import { assert } from 'chai'
import { validate, ValidationError } from '../../src'
import { validateXChainAddAccountCreateAttestation } from '../../src/models/transactions/XChainAddAccountCreateAttestation'
/**
* XChainAddAccountCreateAttestation Transaction Verification Testing.
*
* Providing runtime verification testing for each specific transaction type.
*/
describe('XChainAddAccountCreateAttestation', function () {
let tx
beforeEach(function () {
tx = {
Account: 'r9cYxdjQsoXAEz3qQJc961SNLaXRkWXCvT',
Amount: '10000000',
AttestationRewardAccount: 'r9cYxdjQsoXAEz3qQJc961SNLaXRkWXCvT',
AttestationSignerAccount: 'r9cYxdjQsoXAEz3qQJc961SNLaXRkWXCvT',
Destination: 'rJdTJRJZ6GXCCRaamHJgEqVzB7Zy4557Pi',
Fee: '20',
LastLedgerSequence: 13,
OtherChainSource: 'raFcdz1g8LWJDJWJE2ZKLRGdmUmsTyxaym',
PublicKey:
'ED1F4A024ACFEBDB6C7AA88DEDE3364E060487EA31B14CC9E0D610D152B31AADC2',
Sequence: 5,
Signature:
'EEFCFA3DC2AB4AB7C4D2EBBC168CB621A11B82BABD86534DFC8EFA72439A496' +
'62D744073CD848E7A587A95B35162CDF9A69BB237E72C9537A987F5B8C394F30D',
SignatureReward: '100',
TransactionType: 'XChainAddAccountCreateAttestation',
WasLockingChainSend: 1,
XChainAccountCreateCount: '0000000000000006',
XChainBridge: {
IssuingChainDoor: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
IssuingChainIssue: {
currency: 'XRP',
},
LockingChainDoor: 'rDJVtEuDKr4rj1B3qtW7R5TVWdXV2DY7Qg',
LockingChainIssue: {
currency: 'XRP',
},
},
} as any
})
it('verifies valid XChainAddAccountCreateAttestation', function () {
assert.doesNotThrow(() => validateXChainAddAccountCreateAttestation(tx))
assert.doesNotThrow(() => validate(tx))
})
it('throws w/ missing Amount', function () {
delete tx.Amount
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field Amount',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field Amount',
)
})
it('throws w/ invalid Amount', function () {
tx.Amount = { currency: 'ETH' }
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field Amount',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field Amount',
)
})
it('throws w/ missing AttestationRewardAccount', function () {
delete tx.AttestationRewardAccount
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field AttestationRewardAccount',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field AttestationRewardAccount',
)
})
it('throws w/ invalid AttestationRewardAccount', function () {
tx.AttestationRewardAccount = 123
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field AttestationRewardAccount',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field AttestationRewardAccount',
)
})
it('throws w/ missing AttestationSignerAccount', function () {
delete tx.AttestationSignerAccount
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field AttestationSignerAccount',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field AttestationSignerAccount',
)
})
it('throws w/ invalid AttestationSignerAccount', function () {
tx.AttestationSignerAccount = 123
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field AttestationSignerAccount',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field AttestationSignerAccount',
)
})
it('throws w/ missing Destination', function () {
delete tx.Destination
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field Destination',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field Destination',
)
})
it('throws w/ invalid Destination', function () {
tx.Destination = 123
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field Destination',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field Destination',
)
})
it('throws w/ missing OtherChainSource', function () {
delete tx.OtherChainSource
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field OtherChainSource',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field OtherChainSource',
)
})
it('throws w/ invalid OtherChainSource', function () {
tx.OtherChainSource = 123
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field OtherChainSource',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field OtherChainSource',
)
})
it('throws w/ missing PublicKey', function () {
delete tx.PublicKey
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field PublicKey',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field PublicKey',
)
})
it('throws w/ invalid PublicKey', function () {
tx.PublicKey = 123
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field PublicKey',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field PublicKey',
)
})
it('throws w/ missing Signature', function () {
delete tx.Signature
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field Signature',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field Signature',
)
})
it('throws w/ invalid Signature', function () {
tx.Signature = 123
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field Signature',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field Signature',
)
})
it('throws w/ missing SignatureReward', function () {
delete tx.SignatureReward
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field SignatureReward',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field SignatureReward',
)
})
it('throws w/ invalid SignatureReward', function () {
tx.SignatureReward = { currency: 'ETH' }
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field SignatureReward',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field SignatureReward',
)
})
it('throws w/ missing WasLockingChainSend', function () {
delete tx.WasLockingChainSend
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field WasLockingChainSend',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field WasLockingChainSend',
)
})
it('throws w/ invalid WasLockingChainSend', function () {
tx.WasLockingChainSend = 2
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field WasLockingChainSend',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field WasLockingChainSend',
)
})
it('throws w/ missing XChainAccountCreateCount', function () {
delete tx.XChainAccountCreateCount
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field XChainAccountCreateCount',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field XChainAccountCreateCount',
)
})
it('throws w/ invalid XChainAccountCreateCount', function () {
tx.XChainAccountCreateCount = { currency: 'ETH' }
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field XChainAccountCreateCount',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field XChainAccountCreateCount',
)
})
it('throws w/ missing XChainBridge', function () {
delete tx.XChainBridge
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field XChainBridge',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: missing field XChainBridge',
)
})
it('throws w/ invalid XChainBridge', function () {
tx.XChainBridge = { XChainDoor: 'test' }
assert.throws(
() => validateXChainAddAccountCreateAttestation(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field XChainBridge',
)
assert.throws(
() => validate(tx),
ValidationError,
'XChainAddAccountCreateAttestation: invalid field XChainBridge',
)
})
})