From d2df9bb314a1227640112791c6c29c9dd2c77301 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 9 Jun 2017 14:35:03 +0200 Subject: Add ecSignatureParameter test --- test/schema_test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/schema_test.ts') diff --git a/test/schema_test.ts b/test/schema_test.ts index 42a47c332..657cd1aad 100644 --- a/test/schema_test.ts +++ b/test/schema_test.ts @@ -6,6 +6,7 @@ import promisify = require('es6-promisify'); import {constants} from './utils/constants'; import {SchemaValidator} from '../src/utils/schema_validator'; import {addressSchema, numberSchema} from '../src/schemas/basic_type_schemas'; +import {ecSignatureParameter} from '../src/schemas/ec_signature_schema'; chai.config.includeStack = true; const expect = chai.expect; @@ -41,6 +42,25 @@ describe('Schema', () => { }); }); }); + describe('#ecSignatureParameter', () => { + describe('parameter regex', () => { + it('should validate valid parameters', () => { + const testCases = [ + '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', + '0X40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', + ]; + batchTestSchema(testCases, ecSignatureParameter); + }); + it('should fail for invalid parameters', () => { + const testCases = [ + '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3', // shorter + '0xzzzz9190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // invalid characters + '40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // no 0x + ]; + batchTestSchema(testCases, ecSignatureParameter, true); + }); + }); + }); describe('BigNumber serialization', () => { it('should correctly serialize BigNumbers', () => { const testCases = { -- cgit v1.2.3