Skip to content

Commit d72e298

Browse files
committed
Add a test
1 parent 2b87b7b commit d72e298

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packages/hardhat-verify/test/unit/utilities.ts

+33
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,39 @@ but 2 arguments were provided instead.`);
537537
);
538538
});
539539

540+
it("should throw if a parameter type does not match its expected type: number instead of string", async () => {
541+
const abi: JsonFragment[] = [
542+
{
543+
inputs: [
544+
{
545+
name: "amount",
546+
type: "uint256",
547+
},
548+
{
549+
name: "amount",
550+
type: "string",
551+
},
552+
{
553+
name: "amount",
554+
type: "address",
555+
},
556+
],
557+
stateMutability: "nonpayable",
558+
type: "constructor",
559+
},
560+
];
561+
const constructorArguments: any[] = [
562+
50,
563+
50, // Invalid string
564+
"0x752C8191E6b1Db38B41A8c8921F7a703F2969d18",
565+
];
566+
await expect(
567+
encodeArguments(abi, sourceName, contractName, constructorArguments)
568+
).to.be.rejectedWith(
569+
/Value 50 cannot be encoded for the parameter amount./
570+
);
571+
});
572+
540573
it("should throw if an unsafe integer is provided as an argument", async () => {
541574
const abi: JsonFragment[] = [
542575
{

0 commit comments

Comments
 (0)