aboutsummaryrefslogtreecommitdiffstats
path: root/packages/json-schemas/test
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-05-24 07:52:41 +0800
committerFabio Berger <me@fabioberger.com>2018-05-24 07:52:41 +0800
commit9c850d152cd024c8852200c237790e8bee82b3a9 (patch)
tree3a7005193851d5ef788a65496b2054b27aed791f /packages/json-schemas/test
parent9d11028fce50748d69db5c3b867b1ea063bf2b52 (diff)
downloaddexon-sol-tools-9c850d152cd024c8852200c237790e8bee82b3a9.tar
dexon-sol-tools-9c850d152cd024c8852200c237790e8bee82b3a9.tar.gz
dexon-sol-tools-9c850d152cd024c8852200c237790e8bee82b3a9.tar.bz2
dexon-sol-tools-9c850d152cd024c8852200c237790e8bee82b3a9.tar.lz
dexon-sol-tools-9c850d152cd024c8852200c237790e8bee82b3a9.tar.xz
dexon-sol-tools-9c850d152cd024c8852200c237790e8bee82b3a9.tar.zst
dexon-sol-tools-9c850d152cd024c8852200c237790e8bee82b3a9.zip
Updated Order, SignedOrder schemas, removed ECSignature schema types and added Hex basic type
Diffstat (limited to 'packages/json-schemas/test')
-rw-r--r--packages/json-schemas/test/schema_test.ts74
1 files changed, 18 insertions, 56 deletions
diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts
index b9574a0c9..d8479ef4f 100644
--- a/packages/json-schemas/test/schema_test.ts
+++ b/packages/json-schemas/test/schema_test.ts
@@ -14,8 +14,6 @@ const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
const {
numberSchema,
addressSchema,
- ecSignatureSchema,
- ecSignatureParameterSchema,
orderCancellationRequestsSchema,
orderFillOrKillRequestsSchema,
orderFillRequestsSchema,
@@ -85,47 +83,15 @@ describe('Schema', () => {
validateAgainstSchema(testCases, addressSchema, shouldFail);
});
});
- describe('#ecSignatureParameterSchema', () => {
- it('should validate valid parameters', () => {
- const testCases = [
- '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- '0X40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
- ];
- validateAgainstSchema(testCases, ecSignatureParameterSchema);
- });
- it('should fail for invalid parameters', () => {
- const testCases = [
- '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3', // shorter
- '0xzzzz9190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // invalid characters
- '40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // no 0x
- ];
- const shouldFail = true;
- validateAgainstSchema(testCases, ecSignatureParameterSchema, shouldFail);
- });
- });
- describe('#ecSignatureSchema', () => {
- it('should validate valid signature', () => {
- const signature = {
- v: 27,
- r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
- };
- const testCases = [
- signature,
- {
- ...signature,
- v: 28,
- },
- ];
- validateAgainstSchema(testCases, ecSignatureSchema);
+ describe('#hexSchema', () => {
+ it('should validate valid hex string', () => {
+ const testCases = ['0x8b0292b11a196601ed2ce54b665cafeca0347d42', NULL_ADDRESS];
+ validateAgainstSchema(testCases, addressSchema);
});
- it('should fail for invalid signature', () => {
- const v = 27;
- const r = '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33';
- const s = '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254';
- const testCases = [{}, { v }, { r, s, v: 31 }];
+ it('should fail for invalid hex string', () => {
+ const testCases = ['0x', '0', '0x00', '0xzzzzzzB11a196601eD2ce54B665CaFEca0347D42'];
const shouldFail = true;
- validateAgainstSchema(testCases, ecSignatureSchema, shouldFail);
+ validateAgainstSchema(testCases, addressSchema, shouldFail);
});
});
describe('#orderHashSchema', () => {
@@ -202,18 +168,17 @@ describe('Schema', () => {
});
describe('order including schemas', () => {
const order = {
- maker: NULL_ADDRESS,
- taker: NULL_ADDRESS,
+ makerAddress: NULL_ADDRESS,
+ takerAddress: NULL_ADDRESS,
makerFee: '1',
takerFee: '2',
- makerTokenAmount: '1',
- takerTokenAmount: '2',
- makerTokenAddress: NULL_ADDRESS,
- takerTokenAddress: NULL_ADDRESS,
+ makerAssetAmount: '1',
+ takerAssetAmount: '2',
+ makerAssetData: NULL_ADDRESS,
+ takerAssetData: NULL_ADDRESS,
salt: '67006738228878699843088602623665307406148487219438534730168799356281242528500',
- feeRecipient: NULL_ADDRESS,
- exchangeContractAddress: NULL_ADDRESS,
- expirationUnixTimestampSec: '42',
+ feeRecipientAddress: NULL_ADDRESS,
+ expirationTimeSeconds: '42',
};
describe('#orderSchema', () => {
it('should validate valid order', () => {
@@ -239,11 +204,8 @@ describe('Schema', () => {
describe('signed order including schemas', () => {
const signedOrder = {
...order,
- ecSignature: {
- v: 27,
- r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33',
- s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
- },
+ signature:
+ '0x031b61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3340349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
};
describe('#signedOrdersSchema', () => {
it('should validate valid signed orders', () => {
@@ -265,7 +227,7 @@ describe('Schema', () => {
const testCases = [
{
...signedOrder,
- ecSignature: undefined,
+ signature: undefined,
},
];
const shouldFail = true;