add test for isKnownContract validation

This commit is contained in:
smart_ex 2022-04-18 16:59:10 +10:00 committed by Danil Kovtonyuk
parent e386a1d23c
commit 7f657c1d7d
2 changed files with 13 additions and 9 deletions

@ -15,14 +15,12 @@ for (const [key, value] of Object.entries(instances)) {
const netId = Number(key.substring(5)) const netId = Number(key.substring(5))
for (const [currency, { instanceAddress, symbol, decimals }] of Object.entries(value)) { for (const [currency, { instanceAddress, symbol, decimals }] of Object.entries(value)) {
Object.entries(instanceAddress).forEach(([amount, address]) => Object.entries(instanceAddress).forEach(([amount, address]) =>
addressMap.set(`${netId}_${address}`, addressMap.set(`${netId}_${address}`, {
{ currency,
currency, amount,
amount, symbol,
symbol, decimals,
decimals, }),
},
),
) )
} }
} }

@ -19,7 +19,13 @@ describe('Validator', () => {
'.proof should match pattern "^0x[a-fA-F0-9]{512}$"', '.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', () => { it('should throw something is missing', () => {
const malformedData = { ...withdrawData } const malformedData = { ...withdrawData }
delete malformedData.proof delete malformedData.proof