mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-04-29 15:37:50 +00:00
update EPrice validation error message and add missing tests
This commit is contained in:
@@ -94,6 +94,6 @@ export function validateAMMDeposit(tx: Record<string, unknown>): void {
|
||||
}
|
||||
|
||||
if (tx.EPrice != null && typeof tx.EPrice !== 'string') {
|
||||
throw new ValidationError('AMMDeposit: EPrice must be a string')
|
||||
throw new ValidationError('AMMDeposit: EPrice must be an Amount')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,6 @@ export function validateAMMWithdraw(tx: Record<string, unknown>): void {
|
||||
}
|
||||
|
||||
if (tx.EPrice != null && typeof tx.EPrice !== 'string') {
|
||||
throw new ValidationError('AMMWithdraw: EPrice must be a string')
|
||||
throw new ValidationError('AMMWithdraw: EPrice must be an Amount')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,4 +88,42 @@ describe('AMMDeposit', function () {
|
||||
'AMMDeposit: must set Asset1In with EPrice',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ LPToken must be an IssuedCurrencyAmount`, function () {
|
||||
deposit.LPToken = 1234
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: LPToken must be an IssuedCurrencyAmount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset1In must be an Amount`, function () {
|
||||
deposit.Asset1In = 1234
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: Asset1In must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset2In must be an Amount`, function () {
|
||||
deposit.Asset1In = '1000'
|
||||
deposit.Asset2In = 1234
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: Asset2In must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ EPrice must be an Amount`, function () {
|
||||
deposit.Asset1In = '1000'
|
||||
deposit.EPrice = 1234
|
||||
assert.throws(
|
||||
() => validate(deposit),
|
||||
ValidationError,
|
||||
'AMMDeposit: EPrice must be an Amount',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -88,4 +88,42 @@ describe('AMMWithdraw', function () {
|
||||
'AMMWithdraw: must set Asset1Out with EPrice',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ LPToken must be an IssuedCurrencyAmount`, function () {
|
||||
withdraw.LPToken = 1234
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: LPToken must be an IssuedCurrencyAmount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset1Out must be an Amount`, function () {
|
||||
withdraw.Asset1Out = 1234
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: Asset1Out must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ Asset2Out must be an Amount`, function () {
|
||||
withdraw.Asset1Out = '1000'
|
||||
withdraw.Asset2Out = 1234
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: Asset2Out must be an Amount',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ EPrice must be an Amount`, function () {
|
||||
withdraw.Asset1Out = '1000'
|
||||
withdraw.EPrice = 1234
|
||||
assert.throws(
|
||||
() => validate(withdraw),
|
||||
ValidationError,
|
||||
'AMMWithdraw: EPrice must be an Amount',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user