Add test for relayerApiOrderSchema
This commit is contained in:
parent
63e869f6d0
commit
a78d35f84e
@ -1,5 +1,5 @@
|
|||||||
export const ordersSchema = {
|
export const ordersSchema = {
|
||||||
id: '/ordersSchema',
|
id: '/OrdersSchema',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: { $ref: '/Order' },
|
items: { $ref: '/Order' },
|
||||||
};
|
};
|
||||||
|
@ -7,5 +7,5 @@ export const relayerApiOrdersChannelUpdateSchema = {
|
|||||||
requestId: { type: 'string' },
|
requestId: { type: 'string' },
|
||||||
payload: { $ref: '/RelayerApiOrders' },
|
payload: { $ref: '/RelayerApiOrders' },
|
||||||
},
|
},
|
||||||
required: ['type', 'channel', 'requestId', 'payload'],
|
required: ['type', 'channel', 'requestId'],
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export const signedOrdersSchema = {
|
export const signedOrdersSchema = {
|
||||||
id: '/signedOrdersSchema',
|
id: '/SignedOrdersSchema',
|
||||||
type: 'array',
|
type: 'array',
|
||||||
items: { $ref: '/SignedOrder' },
|
items: { $ref: '/SignedOrder' },
|
||||||
};
|
};
|
||||||
|
@ -5,6 +5,8 @@ import forEach = require('lodash.foreach');
|
|||||||
import 'mocha';
|
import 'mocha';
|
||||||
|
|
||||||
import { schemas, SchemaValidator } from '../src/index';
|
import { schemas, SchemaValidator } from '../src/index';
|
||||||
|
import { validate } from 'jsonschema';
|
||||||
|
import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema';
|
||||||
|
|
||||||
chai.config.includeStack = true;
|
chai.config.includeStack = true;
|
||||||
chai.use(dirtyChai);
|
chai.use(dirtyChai);
|
||||||
@ -211,6 +213,10 @@ describe('Schema', () => {
|
|||||||
exchangeAddress: NULL_ADDRESS,
|
exchangeAddress: NULL_ADDRESS,
|
||||||
expirationTimeSeconds: '42',
|
expirationTimeSeconds: '42',
|
||||||
};
|
};
|
||||||
|
const relayerApiOrder = {
|
||||||
|
order,
|
||||||
|
remainingFillableAmount: '50000000000000',
|
||||||
|
};
|
||||||
describe('#orderSchema', () => {
|
describe('#orderSchema', () => {
|
||||||
it('should validate valid order', () => {
|
it('should validate valid order', () => {
|
||||||
const testCases = [order];
|
const testCases = [order];
|
||||||
@ -232,6 +238,17 @@ describe('Schema', () => {
|
|||||||
validateAgainstSchema(testCases, orderSchema, shouldFail);
|
validateAgainstSchema(testCases, orderSchema, shouldFail);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('relayerApiOrderSchema', () => {
|
||||||
|
it('should validate valid relayer api order', () => {
|
||||||
|
const testCases = [relayerApiOrder];
|
||||||
|
validateAgainstSchema(testCases, relayerApiOrderSchema);
|
||||||
|
});
|
||||||
|
it('should fail for invalid relayer api orders', () => {
|
||||||
|
const testCases = [{}, order, { order }, { order, remainingFillableAmount: 5 }];
|
||||||
|
const shouldFail = true;
|
||||||
|
validateAgainstSchema(testCases, shouldFail);
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('signed order including schemas', () => {
|
describe('signed order including schemas', () => {
|
||||||
const signedOrder = {
|
const signedOrder = {
|
||||||
...order,
|
...order,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user