MCPcopy Create free account
hub / github.com/NomicFoundation/hardhat / assertEncodingError

Function assertEncodingError

packages/hardhat-utils/test/abi.ts:42–59  ·  view source on GitHub ↗

Asserts that encoding rejects with the given error name and fields.

(
  parameters: Array<Record<string, unknown>>,
  values: unknown[],
  name: string,
  fields: Record<string, unknown> = {},
)

Source from the content-addressed store, hash-verified

40
41/** Asserts that encoding rejects with the given error name and fields. */
42async function assertEncodingError(
43 parameters: Array<Record<string, unknown>>,
44 values: unknown[],
45 name: string,
46 fields: Record<string, unknown> = {},
47): Promise<void> {
48 await assert.rejects(encode(parameters, values), (error: Error) => {
49 assert.equal(error.name, name, `expected a ${name}, got a ${error.name}`);
50 for (const [key, expected] of Object.entries(fields)) {
51 assert.deepEqual(
52 Reflect.get(error, key),
53 expected,
54 `unexpected "${key}" in ${name}`,
55 );
56 }
57 return true;
58 });
59}
60
61/** Returns the reason why parsing a signature with an unknown type fails. */
62function unknownType(type: string): string {

Callers 1

abi.tsFile · 0.85

Calls 2

encodeFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected