@diamondslab/diamonds-hardhat-foundry 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,110 @@
1
+ import { task, types } from "hardhat/config";
2
+ import { HardhatRuntimeEnvironment } from "hardhat/types";
3
+ import { DeploymentManager } from "../framework/DeploymentManager";
4
+ import { Logger } from "../utils/logger";
5
+ import { validateFoundryInstallation } from "../utils/validation";
6
+
7
+ /**
8
+ * Task: diamonds-forge:deploy
9
+ *
10
+ * Deploys a Diamond contract for Forge testing.
11
+ * - Validates Foundry installation
12
+ * - Deploys Diamond using LocalDiamondDeployer
13
+ * - Saves deployment record
14
+ * - Optionally reuses existing deployment
15
+ */
16
+ task("diamonds-forge:deploy", "Deploy Diamond contract for Forge testing")
17
+ .addOptionalParam(
18
+ "network",
19
+ "Target network for deployment",
20
+ "hardhat",
21
+ types.string
22
+ )
23
+ .addOptionalParam(
24
+ "diamondName",
25
+ "Name of the Diamond to deploy",
26
+ "ExampleDiamond",
27
+ types.string
28
+ )
29
+ .addFlag("reuse", "Reuse existing deployment if available")
30
+ .addFlag("force", "Force redeployment even if deployment exists")
31
+ .setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
32
+ Logger.section("Deploying Diamond for Forge Testing");
33
+
34
+ const networkName = taskArgs.network;
35
+ const diamondName = taskArgs.diamondName;
36
+ const reuse = taskArgs.reuse;
37
+ const force = taskArgs.force;
38
+
39
+ // Validate flags
40
+ if (reuse && force) {
41
+ Logger.error("Cannot use both --reuse and --force flags");
42
+ throw new Error("Conflicting flags: --reuse and --force");
43
+ }
44
+
45
+ Logger.info(`Diamond: ${diamondName}`);
46
+ Logger.info(`Network: ${networkName}`);
47
+ Logger.info(`Mode: ${force ? "force deploy" : reuse ? "reuse if exists" : "deploy new"}`);
48
+
49
+ // Step 1: Validate Foundry (optional for deployment, but recommended)
50
+ Logger.step("Checking Foundry installation...");
51
+ const foundryInstalled = validateFoundryInstallation();
52
+
53
+ if (!foundryInstalled) {
54
+ Logger.warn("Foundry is not installed");
55
+ Logger.warn("You'll need it to run tests later");
56
+ } else {
57
+ Logger.success("Foundry is installed");
58
+ }
59
+
60
+ // Step 2: Deploy or reuse Diamond
61
+ Logger.step("Deploying Diamond contract...");
62
+ const deploymentManager = new DeploymentManager(hre);
63
+
64
+ try {
65
+ let diamond;
66
+
67
+ if (reuse) {
68
+ // Try to reuse, deploy if not exists
69
+ diamond = await deploymentManager.ensureDeployment(
70
+ diamondName,
71
+ networkName,
72
+ false
73
+ );
74
+ } else {
75
+ // Deploy (force if flag is set)
76
+ diamond = await deploymentManager.deploy(
77
+ diamondName,
78
+ networkName,
79
+ force
80
+ );
81
+ }
82
+
83
+ // Step 3: Display deployment info
84
+ const deploymentData = diamond.getDeployedDiamondData();
85
+
86
+ Logger.section("Deployment Summary");
87
+ Logger.success(`Diamond Address: ${deploymentData.DiamondAddress}`);
88
+ Logger.info(`Deployer Address: ${deploymentData.DeployerAddress}`);
89
+
90
+ const facetCount = Object.keys(deploymentData.DeployedFacets || {}).length;
91
+ Logger.info(`Facets Deployed: ${facetCount}`);
92
+
93
+ if (facetCount > 0) {
94
+ Logger.info("\nDeployed Facets:");
95
+ for (const [name, facet] of Object.entries(deploymentData.DeployedFacets || {})) {
96
+ Logger.info(` - ${name}: ${facet.address}`);
97
+ }
98
+ }
99
+
100
+ Logger.section("Next Steps");
101
+ Logger.info("Generate helpers: npx hardhat diamonds-forge:generate-helpers");
102
+ Logger.info("Run tests: npx hardhat diamonds-forge:test");
103
+
104
+ } catch (error: any) {
105
+ Logger.error(`Deployment failed: ${error.message}`);
106
+ throw error;
107
+ }
108
+ });
109
+
110
+
@@ -0,0 +1,101 @@
1
+ import { task, types } from "hardhat/config";
2
+ import { HardhatRuntimeEnvironment } from "hardhat/types";
3
+ import { DeploymentManager } from "../framework/DeploymentManager";
4
+ import { HelperGenerator } from "../framework/HelperGenerator";
5
+ import { Logger } from "../utils/logger";
6
+
7
+ /**
8
+ * Task: diamonds-forge:generate-helpers
9
+ *
10
+ * Generates Solidity helper files from Diamond deployment data.
11
+ * - Reads deployment record
12
+ * - Generates DiamondDeployment.sol library
13
+ * - Creates constants for addresses and facets
14
+ */
15
+ task("diamonds-forge:generate-helpers", "Generate Solidity helpers from Diamond deployment")
16
+ .addOptionalParam(
17
+ "diamondName",
18
+ "Name of the deployed Diamond",
19
+ "ExampleDiamond",
20
+ types.string
21
+ )
22
+ .addOptionalParam(
23
+ "network",
24
+ "Network where Diamond is deployed",
25
+ "hardhat",
26
+ types.string
27
+ )
28
+ .addOptionalParam(
29
+ "outputDir",
30
+ "Directory for generated helper files",
31
+ undefined,
32
+ types.string
33
+ )
34
+ .setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
35
+ Logger.section("Generating Diamond Deployment Helpers");
36
+
37
+ const diamondName = taskArgs.diamondName;
38
+ const networkName = taskArgs.network;
39
+ const outputDir = taskArgs.outputDir || hre.diamondsFoundry.helpersDir;
40
+
41
+ Logger.info(`Diamond: ${diamondName}`);
42
+ Logger.info(`Network: ${networkName}`);
43
+ Logger.info(`Output: ${outputDir}`);
44
+
45
+ // Step 1: Get deployment
46
+ Logger.step("Loading deployment data...");
47
+ const deploymentManager = new DeploymentManager(hre);
48
+
49
+ try {
50
+ const diamond = await deploymentManager.getDeployment(
51
+ diamondName,
52
+ networkName
53
+ );
54
+
55
+ if (!diamond) {
56
+ Logger.error("No deployment found");
57
+ Logger.info(`Deploy first: npx hardhat diamonds-forge:deploy --diamond-name ${diamondName} --network ${networkName}`);
58
+ throw new Error("Deployment not found");
59
+ }
60
+
61
+ Logger.success("Deployment loaded");
62
+
63
+ // Step 2: Get network info for chainId
64
+ const provider = hre.ethers.provider;
65
+ const network = await provider.getNetwork();
66
+ const chainId = Number(network.chainId);
67
+
68
+ // Step 3: Generate helpers
69
+ Logger.step("Generating Solidity helpers...");
70
+ const generator = new HelperGenerator(hre);
71
+
72
+ const deploymentData = diamond.getDeployedDiamondData();
73
+
74
+ const helperPath = await generator.generateDeploymentHelpers(
75
+ diamondName,
76
+ networkName,
77
+ chainId,
78
+ deploymentData
79
+ );
80
+
81
+ // Step 4: Summary
82
+ Logger.section("Helper Generation Complete");
83
+ Logger.success(`Generated: ${helperPath}`);
84
+
85
+ const facetCount = Object.keys(deploymentData.DeployedFacets || {}).length;
86
+ Logger.info(`Diamond Address: ${deploymentData.DiamondAddress}`);
87
+ Logger.info(`Facets Included: ${facetCount}`);
88
+
89
+ Logger.section("Next Steps");
90
+ Logger.info("Import in your test files:");
91
+ Logger.info(` import "../../helpers/DiamondDeployment.sol";`);
92
+ Logger.info("\nRun tests:");
93
+ Logger.info(` npx hardhat diamonds-forge:test`);
94
+
95
+ } catch (error: any) {
96
+ Logger.error(`Helper generation failed: ${error.message}`);
97
+ throw error;
98
+ }
99
+ });
100
+
101
+
@@ -0,0 +1,90 @@
1
+ import { task, types } from "hardhat/config";
2
+ import { HardhatRuntimeEnvironment } from "hardhat/types";
3
+ import { HelperGenerator } from "../framework/HelperGenerator";
4
+ import { Logger } from "../utils/logger";
5
+ import { validateConfig, validateFoundryInstallation } from "../utils/validation";
6
+
7
+ /**
8
+ * Task: diamonds-forge:init
9
+ *
10
+ * Initializes the project for Forge testing with Diamond contracts.
11
+ * - Validates configuration
12
+ * - Checks Foundry installation
13
+ * - Scaffolds test directory structure
14
+ * - Optionally generates example tests
15
+ */
16
+ task("diamonds-forge:init", "Initialize Forge testing structure for Diamond contracts")
17
+ .addOptionalParam(
18
+ "helpersDir",
19
+ "Directory for generated helper files",
20
+ undefined,
21
+ types.string
22
+ )
23
+ .addFlag("examples", "Generate example test files")
24
+ .addFlag("force", "Overwrite existing files")
25
+ .setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
26
+ Logger.section("Initializing Diamonds-Forge Testing");
27
+
28
+ // Step 1: Validate configuration
29
+ Logger.step("Validating configuration...");
30
+ const config = validateConfig(hre.diamondsFoundry);
31
+
32
+ // Override with task args if provided
33
+ const helpersDir = taskArgs.helpersDir || config.helpersDir;
34
+ const generateExamples = taskArgs.examples || config.generateExamples;
35
+
36
+ Logger.info(`Helpers directory: ${helpersDir}`);
37
+ Logger.info(`Generate examples: ${generateExamples}`);
38
+
39
+ // Step 2: Check Foundry installation
40
+ Logger.step("Checking Foundry installation...");
41
+ const foundryInstalled = validateFoundryInstallation();
42
+
43
+ if (!foundryInstalled) {
44
+ Logger.warn("Foundry is not installed or not in PATH");
45
+ Logger.warn("Install from: https://book.getfoundry.sh/getting-started/installation");
46
+ Logger.warn("Continuing anyway...");
47
+ } else {
48
+ Logger.success("Foundry is installed");
49
+ }
50
+
51
+ // Step 3: Scaffold project structure
52
+ Logger.step("Creating test directory structure...");
53
+ const generator = new HelperGenerator(hre);
54
+
55
+ try {
56
+ await generator.scaffoldProject(helpersDir);
57
+ Logger.success("Directory structure created");
58
+ } catch (error: any) {
59
+ Logger.error(`Failed to scaffold project: ${error.message}`);
60
+ throw error;
61
+ }
62
+
63
+ // Step 4: Generate example tests if requested
64
+ if (generateExamples) {
65
+ Logger.step("Generating example test files...");
66
+ try {
67
+ const examplePaths = await generator.generateExampleTests();
68
+
69
+ if (examplePaths.length > 0) {
70
+ Logger.success(`Generated ${examplePaths.length} example test(s)`);
71
+ examplePaths.forEach((path) => Logger.info(` - ${path}`));
72
+ } else {
73
+ Logger.info("No example tests generated (implementation pending)");
74
+ }
75
+ } catch (error: any) {
76
+ Logger.error(`Failed to generate examples: ${error.message}`);
77
+ throw error;
78
+ }
79
+ }
80
+
81
+ // Step 5: Summary
82
+ Logger.section("Initialization Complete");
83
+ Logger.success("Your project is ready for Forge testing!");
84
+ Logger.info("\nNext steps:");
85
+ Logger.info(" 1. Deploy your Diamond: npx hardhat diamonds-forge:deploy");
86
+ Logger.info(" 2. Generate helpers: npx hardhat diamonds-forge:generate-helpers");
87
+ Logger.info(" 3. Run tests: npx hardhat diamonds-forge:test");
88
+ });
89
+
90
+
@@ -0,0 +1,108 @@
1
+ import { task, types } from "hardhat/config";
2
+ import { HardhatRuntimeEnvironment } from "hardhat/types";
3
+ import { ForgeFuzzingFramework, ForgeTestOptions } from "../framework/ForgeFuzzingFramework";
4
+ import { Logger } from "../utils/logger";
5
+
6
+ /**
7
+ * Task: diamonds-forge:test
8
+ *
9
+ * Runs Forge tests with Diamond deployment.
10
+ * - Ensures Diamond deployment exists
11
+ * - Generates Solidity helpers
12
+ * - Compiles Forge contracts
13
+ * - Runs forge test with specified options
14
+ */
15
+ task("diamonds-forge:test", "Run Forge tests with Diamond deployment")
16
+ .addOptionalParam(
17
+ "diamondName",
18
+ "Name of the Diamond to test",
19
+ "ExampleDiamond",
20
+ types.string
21
+ )
22
+ .addOptionalParam(
23
+ "network",
24
+ "Network for deployment",
25
+ "hardhat",
26
+ types.string
27
+ )
28
+ .addOptionalParam(
29
+ "matchTest",
30
+ "Run tests matching pattern (--match-test)",
31
+ undefined,
32
+ types.string
33
+ )
34
+ .addOptionalParam(
35
+ "matchContract",
36
+ "Run tests in contracts matching pattern (--match-contract)",
37
+ undefined,
38
+ types.string
39
+ )
40
+ .addOptionalParam(
41
+ "verbosity",
42
+ "Verbosity level (1-5, more v's = more verbose)",
43
+ 2,
44
+ types.int
45
+ )
46
+ .addFlag("gasReport", "Show gas report")
47
+ .addFlag("skipDeployment", "Skip Diamond deployment step")
48
+ .addFlag("skipHelpers", "Skip helper generation step")
49
+ .addFlag("force", "Force redeployment of Diamond")
50
+ .setAction(async (taskArgs, hre: HardhatRuntimeEnvironment) => {
51
+ Logger.section("Running Forge Tests with Diamond");
52
+
53
+ const diamondName = taskArgs.diamondName;
54
+ const networkName = taskArgs.network;
55
+ const matchTest = taskArgs.matchTest;
56
+ const matchContract = taskArgs.matchContract;
57
+ const verbosity = taskArgs.verbosity;
58
+ const gasReport = taskArgs.gasReport;
59
+ const skipDeployment = taskArgs.skipDeployment;
60
+ const skipHelpers = taskArgs.skipHelpers;
61
+ const force = taskArgs.force;
62
+
63
+ Logger.info(`Diamond: ${diamondName}`);
64
+ Logger.info(`Network: ${networkName}`);
65
+
66
+ if (matchTest) Logger.info(`Match Test: ${matchTest}`);
67
+ if (matchContract) Logger.info(`Match Contract: ${matchContract}`);
68
+ if (gasReport) Logger.info("Gas Report: enabled");
69
+ if (skipDeployment) Logger.info("Skip Deployment: true");
70
+ if (skipHelpers) Logger.info("Skip Helpers: true");
71
+
72
+ // Create test options
73
+ const options: ForgeTestOptions = {
74
+ diamondName,
75
+ networkName,
76
+ force,
77
+ matchTest,
78
+ matchContract,
79
+ verbosity,
80
+ gasReport,
81
+ skipHelpers,
82
+ skipDeployment,
83
+ };
84
+
85
+ // Run tests using the framework
86
+ const framework = new ForgeFuzzingFramework(hre);
87
+
88
+ try {
89
+ const success = await framework.runTests(options);
90
+
91
+ if (success) {
92
+ Logger.section("Test Execution Complete");
93
+ Logger.success("All tests passed!");
94
+ process.exitCode = 0;
95
+ } else {
96
+ Logger.section("Test Execution Complete");
97
+ Logger.error("Some tests failed");
98
+ process.exitCode = 1;
99
+ }
100
+
101
+ } catch (error: any) {
102
+ Logger.error(`Test execution failed: ${error.message}`);
103
+ process.exitCode = 1;
104
+ throw error;
105
+ }
106
+ });
107
+
108
+
@@ -0,0 +1,38 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ /**
5
+ * @title DiamondDeployment
6
+ * @notice Deployment data for {{DIAMOND_NAME}} on {{NETWORK_NAME}} (Chain ID: {{CHAIN_ID}})
7
+ * @dev Auto-generated by diamonds-hardhat-foundry
8
+ *
9
+ * Generated: {{TIMESTAMP}}
10
+ */
11
+ library DiamondDeployment {
12
+ // Diamond Contract Address
13
+ address constant DIAMOND_ADDRESS = {{DIAMOND_ADDRESS}};
14
+
15
+ // Deployer Address
16
+ address constant DEPLOYER_ADDRESS = {{DEPLOYER_ADDRESS}};
17
+
18
+ // Facet Addresses
19
+ {{FACET_ADDRESSES}}
20
+
21
+ /**
22
+ * @notice Get the Diamond contract address
23
+ * @return The address of the Diamond contract
24
+ */
25
+ function diamond() internal pure returns (address) {
26
+ return DIAMOND_ADDRESS;
27
+ }
28
+
29
+ /**
30
+ * @notice Get the deployer address
31
+ * @return The address that deployed the Diamond
32
+ */
33
+ function deployer() internal pure returns (address) {
34
+ return DEPLOYER_ADDRESS;
35
+ }
36
+
37
+ {{FACET_GETTERS}}
38
+ }
@@ -0,0 +1,109 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "forge-std/Test.sol";
5
+ import "forge-std/console.sol";
6
+ import "../../contracts/DiamondFuzzBase.sol";
7
+ import "../../helpers/DiamondDeployment.sol";
8
+
9
+ /**
10
+ * @title ExampleFuzzTest
11
+ * @notice Example fuzz test for Diamond contract
12
+ * @dev Uses DiamondFuzzBase for common fuzz testing utilities
13
+ */
14
+ contract ExampleFuzzTest is DiamondFuzzBase {
15
+ function setUp() public override {
16
+ super.setUp();
17
+
18
+ // Load Diamond deployment
19
+ setDiamondAddress(DiamondDeployment.diamond());
20
+
21
+ // Register facets (customize for your Diamond)
22
+ // registerFacet("FacetName", DiamondDeployment.facetName());
23
+
24
+ console.log("Fuzz test setup complete");
25
+ console.log("Diamond:", diamond);
26
+ }
27
+
28
+ /**
29
+ * @notice Fuzz test with random address input
30
+ * @param randomAddress Fuzzed address parameter
31
+ */
32
+ function testFuzz_AddressInput(address randomAddress) public {
33
+ // Filter invalid addresses
34
+ assumeValidAddress(randomAddress);
35
+
36
+ // TODO: Test your Diamond function with fuzzed address
37
+ // Example:
38
+ // MyDiamond(diamond).someFunction(randomAddress);
39
+
40
+ assertTrue(true, "Replace with actual fuzz test");
41
+ }
42
+
43
+ /**
44
+ * @notice Fuzz test with random amount input
45
+ * @param amount Fuzzed amount parameter
46
+ */
47
+ function testFuzz_AmountInput(uint256 amount) public {
48
+ // Bound the amount to valid range
49
+ assumeValidAmount(amount);
50
+
51
+ // TODO: Test your Diamond function with fuzzed amount
52
+ // Example:
53
+ // MyDiamond(diamond).transfer(user1, amount);
54
+
55
+ assertTrue(true, "Replace with actual fuzz test");
56
+ }
57
+
58
+ /**
59
+ * @notice Fuzz test with multiple parameters
60
+ * @param addr Fuzzed address
61
+ * @param value Fuzzed value
62
+ * @param data Fuzzed bytes data
63
+ */
64
+ function testFuzz_MultipleParams(
65
+ address addr,
66
+ uint256 value,
67
+ bytes memory data
68
+ ) public {
69
+ // Filter inputs
70
+ assumeValidAddress(addr);
71
+ assumeValidAmount(value);
72
+ vm.assume(data.length > 0);
73
+ vm.assume(data.length < 1024); // Reasonable size limit
74
+
75
+ // TODO: Test with multiple fuzzed parameters
76
+
77
+ assertTrue(true, "Replace with actual multi-param fuzz test");
78
+ }
79
+
80
+ /**
81
+ * @notice Fuzz test for failure conditions
82
+ * @param badValue Value that should cause revert
83
+ */
84
+ function testFuzz_ExpectedRevert(uint256 badValue) public {
85
+ // Set up conditions for expected revert
86
+ vm.assume(badValue > type(uint128).max);
87
+
88
+ // TODO: Test that function reverts with invalid input
89
+ // expectRevertWithMessage("Invalid amount");
90
+ // MyDiamond(diamond).someFunction(badValue);
91
+
92
+ assertTrue(true, "Replace with actual revert fuzz test");
93
+ }
94
+
95
+ /**
96
+ * @notice Fuzz test with bounded values
97
+ * @param rawValue Raw fuzzed value
98
+ */
99
+ function testFuzz_BoundedValue(uint256 rawValue) public {
100
+ // Bound value to specific range (e.g., 1 to 1000)
101
+ uint256 boundedValue = boundValue(rawValue, 1, 1000);
102
+
103
+ // TODO: Test with bounded value
104
+ assertGe(boundedValue, 1, "Value should be >= 1");
105
+ assertLe(boundedValue, 1000, "Value should be <= 1000");
106
+
107
+ assertTrue(true, "Replace with actual bounded fuzz test");
108
+ }
109
+ }
@@ -0,0 +1,79 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "forge-std/Test.sol";
5
+ import "forge-std/console.sol";
6
+ import "../../helpers/DiamondDeployment.sol";
7
+
8
+ /**
9
+ * @title ExampleIntegrationTest
10
+ * @notice Example integration test for Diamond contract
11
+ * @dev Tests interactions between multiple facets and Diamond functionality
12
+ */
13
+ contract ExampleIntegrationTest is Test {
14
+ address diamond;
15
+ address deployer;
16
+
17
+ // Test users
18
+ address user1;
19
+ address user2;
20
+
21
+ function setUp() public {
22
+ // Load Diamond deployment data
23
+ diamond = DiamondDeployment.diamond();
24
+ deployer = DiamondDeployment.deployer();
25
+
26
+ // Set up test users
27
+ user1 = makeAddr("user1");
28
+ user2 = makeAddr("user2");
29
+
30
+ // Fund test users
31
+ vm.deal(user1, 100 ether);
32
+ vm.deal(user2, 100 ether);
33
+
34
+ console.log("Diamond:", diamond);
35
+ console.log("User1:", user1);
36
+ console.log("User2:", user2);
37
+ }
38
+
39
+ /**
40
+ * @notice Test multi-facet interaction workflow
41
+ */
42
+ function test_MultiFacetWorkflow() public {
43
+ // TODO: Implement your multi-facet workflow test
44
+ // Example:
45
+ // 1. User1 calls function on Facet A
46
+ // 2. Verify state change
47
+ // 3. User2 calls function on Facet B
48
+ // 4. Verify combined state
49
+
50
+ vm.startPrank(user1);
51
+ // Your test logic here
52
+ vm.stopPrank();
53
+
54
+ assertTrue(true, "Replace with actual integration test");
55
+ }
56
+
57
+ /**
58
+ * @notice Test cross-facet state management
59
+ */
60
+ function test_CrossFacetState() public {
61
+ // TODO: Test that state is properly shared/isolated between facets
62
+
63
+ assertTrue(true, "Replace with actual state test");
64
+ }
65
+
66
+ /**
67
+ * @notice Test Diamond upgrade scenario (if applicable)
68
+ */
69
+ function test_DiamondUpgrade() public {
70
+ // TODO: Test facet addition/replacement/removal
71
+ // This requires diamondCut functionality
72
+
73
+ vm.startPrank(deployer);
74
+ // Your upgrade logic here
75
+ vm.stopPrank();
76
+
77
+ assertTrue(true, "Replace with actual upgrade test");
78
+ }
79
+ }
@@ -0,0 +1,59 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "forge-std/Test.sol";
5
+ import "forge-std/console.sol";
6
+ import "../../helpers/DiamondDeployment.sol";
7
+
8
+ /**
9
+ * @title ExampleUnitTest
10
+ * @notice Example unit test for Diamond contract
11
+ * @dev This is a template - customize for your specific Diamond implementation
12
+ */
13
+ contract ExampleUnitTest is Test {
14
+ address diamond;
15
+ address deployer;
16
+
17
+ function setUp() public {
18
+ // Load Diamond deployment data
19
+ diamond = DiamondDeployment.diamond();
20
+ deployer = DiamondDeployment.deployer();
21
+
22
+ console.log("Diamond deployed at:", diamond);
23
+ console.log("Deployed by:", deployer);
24
+ }
25
+
26
+ /**
27
+ * @notice Test that Diamond was deployed successfully
28
+ */
29
+ function test_DiamondDeployed() public view {
30
+ // Check that Diamond address is not zero
31
+ assertNotEq(diamond, address(0), "Diamond address should not be zero");
32
+
33
+ // Check that Diamond has code
34
+ uint256 codeSize;
35
+ assembly {
36
+ codeSize := extcodesize(diamond)
37
+ }
38
+ assertGt(codeSize, 0, "Diamond should have code deployed");
39
+ }
40
+
41
+ /**
42
+ * @notice Test that deployer address is set correctly
43
+ */
44
+ function test_DeployerSet() public view {
45
+ assertNotEq(deployer, address(0), "Deployer address should not be zero");
46
+ }
47
+
48
+ /**
49
+ * @notice Example test - customize for your Diamond's functionality
50
+ */
51
+ function test_ExampleFunctionality() public {
52
+ // TODO: Add your Diamond-specific tests here
53
+ // Example:
54
+ // MyDiamond(diamond).someFunction();
55
+ // assertEq(result, expectedValue);
56
+
57
+ assertTrue(true, "Replace this with actual test");
58
+ }
59
+ }