-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(
cheatcodes
): getArtifactPathByCode
and `getArtifactPathByDep…
…loyedCode` (#8938) * feat(`cheatcodes`): vm.getArtifactPath * cargo cheats * nit * nit * fix * test: vm.getArtifactPath * feat: vm.getArtifactPath(creationCode) * cheats * nit * change seed * rm vm.getArtifactPath(contractName) * fmt * nit * fix * nit * rename * nit * fix --------- Co-authored-by: grandizzy <[email protected]>
- Loading branch information
1 parent
9a0f66e
commit c59d97e
Showing
5 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
pragma solidity 0.8.18; | ||
|
||
import "ds-test/test.sol"; | ||
import "cheats/Vm.sol"; | ||
|
||
contract DummyForGetArtifactPath {} | ||
|
||
contract GetArtifactPathTest is DSTest { | ||
Vm constant vm = Vm(HEVM_ADDRESS); | ||
|
||
function testGetArtifactPathByCode() public { | ||
DummyForGetArtifactPath dummy = new DummyForGetArtifactPath(); | ||
bytes memory dummyCreationCode = type(DummyForGetArtifactPath).creationCode; | ||
|
||
string memory root = vm.projectRoot(); | ||
string memory path = vm.getArtifactPathByCode(dummyCreationCode); | ||
|
||
string memory expectedPath = | ||
string.concat(root, "/out/default/GetArtifactPath.t.sol/DummyForGetArtifactPath.json"); | ||
|
||
assertEq(path, expectedPath); | ||
} | ||
|
||
function testGetArtifactPathByDeployedCode() public { | ||
DummyForGetArtifactPath dummy = new DummyForGetArtifactPath(); | ||
bytes memory dummyRuntimeCode = address(dummy).code; | ||
|
||
string memory root = vm.projectRoot(); | ||
string memory path = vm.getArtifactPathByDeployedCode(dummyRuntimeCode); | ||
|
||
string memory expectedPath = | ||
string.concat(root, "/out/default/GetArtifactPath.t.sol/DummyForGetArtifactPath.json"); | ||
|
||
assertEq(path, expectedPath); | ||
} | ||
} |