Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad-Altabba committed Dec 4, 2023
1 parent 87a9b06 commit 71ef140
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions packages/web3-eth-abi/test/unit/coders/base/invalid.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
This file is part of web3.js.
web3.js is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
web3.js is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
*/

import { AbiError } from 'web3-errors';
import {
decodeParamFromAbiParameter,
encodeParamFromAbiParameter,
} from '../../../../src/coders/base';

describe('abi - coder - base - invalid', () => {
describe('invalid type', () => {
it('invalid should cause `decodeParamFromAbiParameter` to throw', () => {
expect(() =>
decodeParamFromAbiParameter({ type: 'invalid', name: '' }, new Uint8Array()),
).toThrow(AbiError);
});
it('invalid should cause `encodeParamFromAbiParameter` to throw', () => {
expect(() =>
encodeParamFromAbiParameter({ type: 'invalid', name: '' }, 'something'),
).toThrow(AbiError);
});
});
});

0 comments on commit 71ef140

Please sign in to comment.