Skip to content

LibHexStringExternal and NonConformingVm constructed inline 12 and 11 times in LibHexString.bytesToHex.t.sol #63

Description

@thedavidmeister

Audit scope: whole-repo, commit 7aa85a4

Dimension 4 (code quality) · low

Location:test/src/lib/LibHexString.bytesToHex.t.sol:226, 269-270, 277-278, 288-289, 298-299, 308-309, 318-319, 327-328, 338-339, 349-350, 357-358, 374-375

Path note: PR #56 is open and unmerged as of filing. On main today this file is test/lib/LibHexString.bytesToHex.t.sol; it becomes test/src/lib/LibHexString.bytesToHex.t.sol after #56 merges.

Problem

Every revert test opens with the same two new statements, one of them inside a
2048-run fuzz (lines 226 and 374). The repo's own pattern already covers this:
LibFsTest and LibFsBuildFileForContractTest hold an iExternal immutable
built in the constructor, and the five tooling suites build their mock in
setUp. This file uses neither.

Proposed fix

One LibHexStringExternal internal immutable iExternal; assigned in the
constructor, plus function badVm(string memory toStringReturn) internal returns (Vm) { return Vm(address(new NonConformingVm(toStringReturn))); }. Each revert
test then reads vm.expectRevert(…); iExternal.bytesToHex(badVm("0xaa"), hex"aabb");.

Metadata

Metadata

Labels

auditAudit findinglowAudit findingpass4Audit finding

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions