aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-08-01 08:22:26 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-08-01 08:22:26 +0800
commita78d35f84ee896e70385476fcc8ee2c9db9931bd (patch)
tree1335a1ff3c8908589bdb02190fdfee9987c9f755
parent63e869f6d01663a22773d244920362921dbcdcdc (diff)
downloaddexon-sol-tools-a78d35f84ee896e70385476fcc8ee2c9db9931bd.tar
dexon-sol-tools-a78d35f84ee896e70385476fcc8ee2c9db9931bd.tar.gz
dexon-sol-tools-a78d35f84ee896e70385476fcc8ee2c9db9931bd.tar.bz2
dexon-sol-tools-a78d35f84ee896e70385476fcc8ee2c9db9931bd.tar.lz
dexon-sol-tools-a78d35f84ee896e70385476fcc8ee2c9db9931bd.tar.xz
dexon-sol-tools-a78d35f84ee896e70385476fcc8ee2c9db9931bd.tar.zst
dexon-sol-tools-a78d35f84ee896e70385476fcc8ee2c9db9931bd.zip
Add test for relayerApiOrderSchema
-rw-r--r--packages/json-schemas/schemas/orders_schema.ts2
-rw-r--r--packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts2
-rw-r--r--packages/json-schemas/schemas/signed_orders_schema.ts2
-rw-r--r--packages/json-schemas/test/schema_test.ts17
4 files changed, 20 insertions, 3 deletions
diff --git a/packages/json-schemas/schemas/orders_schema.ts b/packages/json-schemas/schemas/orders_schema.ts
index 3ba3291a2..73816a57e 100644
--- a/packages/json-schemas/schemas/orders_schema.ts
+++ b/packages/json-schemas/schemas/orders_schema.ts
@@ -1,5 +1,5 @@
export const ordersSchema = {
- id: '/ordersSchema',
+ id: '/OrdersSchema',
type: 'array',
items: { $ref: '/Order' },
};
diff --git a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts
index 38306391b..31f5ab389 100644
--- a/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts
+++ b/packages/json-schemas/schemas/relayer_api_orders_channel_update_response_schema.ts
@@ -7,5 +7,5 @@ export const relayerApiOrdersChannelUpdateSchema = {
requestId: { type: 'string' },
payload: { $ref: '/RelayerApiOrders' },
},
- required: ['type', 'channel', 'requestId', 'payload'],
+ required: ['type', 'channel', 'requestId'],
};
diff --git a/packages/json-schemas/schemas/signed_orders_schema.ts b/packages/json-schemas/schemas/signed_orders_schema.ts
index 34d956836..164201f76 100644
--- a/packages/json-schemas/schemas/signed_orders_schema.ts
+++ b/packages/json-schemas/schemas/signed_orders_schema.ts
@@ -1,5 +1,5 @@
export const signedOrdersSchema = {
- id: '/signedOrdersSchema',
+ id: '/SignedOrdersSchema',
type: 'array',
items: { $ref: '/SignedOrder' },
};
diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts
index 03c0e950b..e8ccd4ec6 100644
--- a/packages/json-schemas/test/schema_test.ts
+++ b/packages/json-schemas/test/schema_test.ts
@@ -5,6 +5,8 @@ import forEach = require('lodash.foreach');
import 'mocha';
import { schemas, SchemaValidator } from '../src/index';
+import { validate } from 'jsonschema';
+import { relayerApiOrderSchema } from '../schemas/relayer_api_order_schema';
chai.config.includeStack = true;
chai.use(dirtyChai);
@@ -211,6 +213,10 @@ describe('Schema', () => {
exchangeAddress: NULL_ADDRESS,
expirationTimeSeconds: '42',
};
+ const relayerApiOrder = {
+ order,
+ remainingFillableAmount: '50000000000000',
+ };
describe('#orderSchema', () => {
it('should validate valid order', () => {
const testCases = [order];
@@ -232,6 +238,17 @@ describe('Schema', () => {
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', () => {
const signedOrder = {
...order,