-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 * fix tests * add XChainModifyBridge tests * fix tests * fix more tests * fix linting errors * update to most recent version of code * remove XChainAddAttestationBatch tests * fix rebase issues * fix linter issues * add more validation tests * fix linter errors * fix tests * switch createValidateTests to JS
- Loading branch information
Showing
9 changed files
with
1,729 additions
and
0 deletions.
There are no files selected for viewing
161 changes: 161 additions & 0 deletions
161
packages/xrpl/test/models/XChainAccountCreateCommit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
import { assert } from 'chai' | ||
|
||
import { validate, ValidationError } from '../../src' | ||
import { validateXChainAccountCreateCommit } from '../../src/models/transactions/XChainAccountCreateCommit' | ||
|
||
/** | ||
* XChainAccountCreateCommit Transaction Verification Testing. | ||
* | ||
* Providing runtime verification testing for each specific transaction type. | ||
*/ | ||
describe('XChainAccountCreateCommit', function () { | ||
let tx | ||
|
||
beforeEach(function () { | ||
tx = { | ||
Account: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', | ||
XChainBridge: { | ||
LockingChainDoor: 'rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL', | ||
LockingChainIssue: { | ||
currency: 'XRP', | ||
}, | ||
IssuingChainDoor: 'r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV', | ||
IssuingChainIssue: { | ||
currency: 'XRP', | ||
}, | ||
}, | ||
Amount: '1000000', | ||
Fee: '10', | ||
Flags: 2147483648, | ||
Destination: 'rGzx83BVoqTYbGn7tiVAnFw7cbxjin13jL', | ||
Sequence: 1, | ||
SignatureReward: '10000', | ||
TransactionType: 'XChainAccountCreateCommit', | ||
} as any | ||
}) | ||
|
||
it('verifies valid XChainAccountCreateCommit', function () { | ||
assert.doesNotThrow(() => validateXChainAccountCreateCommit(tx)) | ||
assert.doesNotThrow(() => validate(tx)) | ||
}) | ||
|
||
it('throws w/ missing XChainBridge', function () { | ||
delete tx.XChainBridge | ||
|
||
assert.throws( | ||
() => validateXChainAccountCreateCommit(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: missing field XChainBridge', | ||
) | ||
assert.throws( | ||
() => validate(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: missing field XChainBridge', | ||
) | ||
}) | ||
|
||
it('throws w/ invalid XChainBridge', function () { | ||
tx.XChainBridge = { XChainDoor: 'test' } | ||
|
||
assert.throws( | ||
() => validateXChainAccountCreateCommit(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: invalid field XChainBridge', | ||
) | ||
assert.throws( | ||
() => validate(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: invalid field XChainBridge', | ||
) | ||
}) | ||
|
||
it('throws w/ missing SignatureReward', function () { | ||
delete tx.SignatureReward | ||
|
||
assert.throws( | ||
() => validateXChainAccountCreateCommit(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: missing field SignatureReward', | ||
) | ||
assert.throws( | ||
() => validate(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: missing field SignatureReward', | ||
) | ||
}) | ||
|
||
it('throws w/ invalid SignatureReward', function () { | ||
tx.SignatureReward = { currency: 'ETH' } | ||
|
||
assert.throws( | ||
() => validateXChainAccountCreateCommit(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: invalid field SignatureReward', | ||
) | ||
assert.throws( | ||
() => validate(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: invalid field SignatureReward', | ||
) | ||
}) | ||
|
||
it('throws w/ missing Destination', function () { | ||
delete tx.Destination | ||
|
||
assert.throws( | ||
() => validateXChainAccountCreateCommit(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: missing field Destination', | ||
) | ||
assert.throws( | ||
() => validate(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: missing field Destination', | ||
) | ||
}) | ||
|
||
it('throws w/ invalid Destination', function () { | ||
tx.Destination = 123 | ||
|
||
assert.throws( | ||
() => validateXChainAccountCreateCommit(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: invalid field Destination', | ||
) | ||
assert.throws( | ||
() => validate(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: invalid field Destination', | ||
) | ||
}) | ||
|
||
it('throws w/ missing Amount', function () { | ||
delete tx.Amount | ||
|
||
assert.throws( | ||
() => validateXChainAccountCreateCommit(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: missing field Amount', | ||
) | ||
assert.throws( | ||
() => validate(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: missing field Amount', | ||
) | ||
}) | ||
|
||
it('throws w/ invalid Amount', function () { | ||
tx.Amount = { currency: 'ETH' } | ||
|
||
assert.throws( | ||
() => validateXChainAccountCreateCommit(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: invalid field Amount', | ||
) | ||
assert.throws( | ||
() => validate(tx), | ||
ValidationError, | ||
'XChainAccountCreateCommit: invalid field Amount', | ||
) | ||
}) | ||
}) |
Oops, something went wrong.