mirror of
https://github.com/Xahau/xahau.js.git
synced 2026-08-23 16:40:52 +00:00
add negative TradingFee check
This commit is contained in:
@@ -68,9 +68,9 @@ export function validateAMMInstanceCreate(tx: Record<string, unknown>): void {
|
||||
throw new ValidationError('AMMInstanceCreate: TradingFee must be a number')
|
||||
}
|
||||
|
||||
if (tx.TradingFee > AMM_MAX_TRADING_FEE) {
|
||||
if (tx.TradingFee < 0 || tx.TradingFee > AMM_MAX_TRADING_FEE) {
|
||||
throw new ValidationError(
|
||||
`AMMInstanceCreate: TradingFee must not be greater than ${AMM_MAX_TRADING_FEE}`,
|
||||
`AMMInstanceCreate: TradingFee must be between 0 and ${AMM_MAX_TRADING_FEE}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,12 +82,21 @@ describe('AMMInstanceCreate', function () {
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws w/ TradingFee must not be greater than 65000`, function () {
|
||||
it(`throws when TradingFee is greater than 65000`, function () {
|
||||
instanceCreate.TradingFee = 65001
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
`AMMInstanceCreate: TradingFee must not be greater than 65000`,
|
||||
`AMMInstanceCreate: TradingFee must be between 0 and 65000`,
|
||||
)
|
||||
})
|
||||
|
||||
it(`throws when TradingFee is a negative number`, function () {
|
||||
instanceCreate.TradingFee = -1
|
||||
assert.throws(
|
||||
() => validate(instanceCreate),
|
||||
ValidationError,
|
||||
`AMMInstanceCreate: TradingFee must be between 0 and 65000`,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user