From 7f657c1d7de90f93c0da834f78f62768c82d3afb Mon Sep 17 00:00:00 2001 From: smart_ex Date: Mon, 18 Apr 2022 16:59:10 +1000 Subject: [PATCH] add test for isKnownContract validation --- src/utils.js | 14 ++++++-------- test/validator.js | 8 +++++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/utils.js b/src/utils.js index 743d370..78d2dbd 100644 --- a/src/utils.js +++ b/src/utils.js @@ -15,14 +15,12 @@ for (const [key, value] of Object.entries(instances)) { const netId = Number(key.substring(5)) for (const [currency, { instanceAddress, symbol, decimals }] of Object.entries(value)) { Object.entries(instanceAddress).forEach(([amount, address]) => - addressMap.set(`${netId}_${address}`, - { - currency, - amount, - symbol, - decimals, - }, - ), + addressMap.set(`${netId}_${address}`, { + currency, + amount, + symbol, + decimals, + }), ) } } diff --git a/test/validator.js b/test/validator.js index 9d5cf93..420d79c 100644 --- a/test/validator.js +++ b/test/validator.js @@ -19,7 +19,13 @@ describe('Validator', () => { '.proof should match pattern "^0x[a-fA-F0-9]{512}$"', ) }) - + it('should throw if unknown contract', () => { + const malformedData = { ...withdrawData } + malformedData.contract = '0xf17f52151ebef6c7334fad080c5704d77216b732' + getTornadoWithdrawInputError(malformedData).should.be.equal( + '.contract should pass "isKnownContract" keyword validation', + ) + }) it('should throw something is missing', () => { const malformedData = { ...withdrawData } delete malformedData.proof