Skip to content

Commit

Permalink
chore(world): add gas reports for deploying world via WorldFactory (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaa authored Jan 16, 2024
1 parent 942f20e commit e3fab07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/world/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@
"name": "call systems with batchCall",
"gasUsed": 45206
},
{
"file": "test/Factories.t.sol",
"test": "testCreate2Factory",
"name": "deploy contract via Create2",
"gasUsed": 4663033
},
{
"file": "test/Factories.t.sol",
"test": "testWorldFactory",
"name": "deploy world via WorldFactory",
"gasUsed": 11933749
},
{
"file": "test/World.t.sol",
"test": "testCall",
Expand Down
7 changes: 6 additions & 1 deletion packages/world/test/Factories.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity >=0.8.21;
import { Test, console } from "forge-std/Test.sol";

import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
import { WORLD_VERSION } from "../src/version.sol";
import { World } from "../src/World.sol";
import { ResourceId } from "../src/WorldResourceId.sol";
Expand All @@ -16,7 +17,7 @@ import { InstalledModules } from "../src/codegen/tables/InstalledModules.sol";
import { NamespaceOwner } from "../src/codegen/tables/NamespaceOwner.sol";
import { ROOT_NAMESPACE_ID } from "../src/constants.sol";

contract FactoriesTest is Test {
contract FactoriesTest is Test, GasReporter {
event ContractDeployed(address addr, uint256 salt);
event WorldDeployed(address indexed newContract);
event HelloWorld(bytes32 indexed version);
Expand Down Expand Up @@ -44,7 +45,9 @@ contract FactoriesTest is Test {
// Confirm event for deployment
vm.expectEmit(true, false, false, false);
emit ContractDeployed(calculatedAddress, uint256(0));
startGasReport("deploy contract via Create2");
create2Factory.deployContract(combinedBytes, uint256(0));
endGasReport();

// Confirm worldFactory was deployed correctly
IWorldFactory worldFactory = IWorldFactory(calculatedAddress);
Expand All @@ -67,7 +70,9 @@ contract FactoriesTest is Test {
// Check for WorldDeployed event from Factory
vm.expectEmit(true, false, false, false);
emit WorldDeployed(calculatedAddress);
startGasReport("deploy world via WorldFactory");
worldFactory.deployWorld();
endGasReport();

// Set the store address manually
StoreSwitch.setStoreAddress(calculatedAddress);
Expand Down

0 comments on commit e3fab07

Please sign in to comment.