From 7997644706b3ad0fd9299d26e3f7dca9542b1cd5 Mon Sep 17 00:00:00 2001 From: garyghayrat Date: Thu, 4 Jan 2024 19:32:14 -0500 Subject: [PATCH] Add deploy script test --- test/Deploy.t.sol | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/Deploy.t.sol diff --git a/test/Deploy.t.sol b/test/Deploy.t.sol new file mode 100644 index 0000000..295fff4 --- /dev/null +++ b/test/Deploy.t.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.23; + +import {Deploy} from "script/Deploy.s.sol"; +import {Test} from "forge-std/Test.sol"; +import {ERC5564Announcer} from "src/ERC5564Announcer.sol"; +import {ERC6538Registry} from "src/ERC6538Registry.sol"; + +contract DeployTest is Test, Deploy { + bytes announcerContractCode; + ERC5564Announcer announcerTestDeployment; + + function setUp() public { + announcerTestDeployment = new ERC5564Announcer(); + announcerContractCode = address(announcerTestDeployment).code; + } + + function test_Deploy() external { + bytes memory erc5564CreationCode = abi.encodePacked(type(ERC5564Announcer).creationCode); + bytes memory erc6538CreationCode = abi.encodePacked(type(ERC6538Registry).creationCode); + + address erc5564ComputedAddress = + computeCreate2Address(salt, keccak256(erc5564CreationCode), deployer); + address erc6538ComputedAddress = + computeCreate2Address(salt, keccak256(erc6538CreationCode), deployer); + + require(erc5564ComputedAddress.code.length == 0); + require(erc6538ComputedAddress.code.length == 0); + + /// Run deploy script + Deploy.run(); + + assertTrue(erc5564ComputedAddress.code.length > 0); + assertTrue(erc6538ComputedAddress.code.length > 0); + assertEq(erc5564ComputedAddress.code, announcerContractCode); + } +}