mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-04-29 15:37:50 +00:00
add negative FeeVal check
This commit is contained in:
@@ -51,9 +51,9 @@ export function validateAMMVote(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMVote: FeeVal must be a number')
|
||||
}
|
||||
|
||||
if (tx.FeeVal > AMM_MAX_TRADING_FEE) {
|
||||
if (tx.FeeVal < 0 || tx.FeeVal > AMM_MAX_TRADING_FEE) {
|
||||
throw new ValidationError(
|
||||
`AMMVote: FeeVal must not be greater than ${AMM_MAX_TRADING_FEE}`,
|
||||
`AMMVote: FeeVal must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,12 +59,21 @@ describe('AMMVote', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ FeeVal must not be greater than 65000`, function () {
|
||||
it(`throws when FeeVal is greater than AMM_MAX_TRADING_FEE`, function () {
|
||||
vote.FeeVal = 65001
|
||||
assert.throws(
|
||||
() => validate(vote),
|
||||
ValidationError,
|
||||
'AMMVote: FeeVal must not be greater than 65000',
|
||||
'AMMVote: FeeVal must be between 0 and 65000',
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws when FeeVal is a negative number`, function () {
|
||||
vote.FeeVal = -1
|
||||
assert.throws(
|
||||
() => validate(vote),
|
||||
ValidationError,
|
||||
'AMMVote: FeeVal must be between 0 and 65000',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user