Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks committed Jul 4, 2023
1 parent 26eb366 commit 34cdea3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
4 changes: 2 additions & 2 deletions test/GasBenchmark.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ contract GasBenchmarkTest is ReflexConstants {
// Constants
// =========

uint32 internal constant _MODULE_ID_SINGLE = 2;
uint32 internal constant _MODULE_ID_BATCH = 3;
uint32 internal constant _MODULE_ID_BATCH = 2;
uint32 internal constant _MODULE_ID_SINGLE = 100;

// =======
// Storage
Expand Down
1 change: 0 additions & 1 deletion test/ImplementationERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ contract ImplementationERC20Test is ImplementationFixture {
// =========

uint32 internal constant _MODULE_ID_TOKEN_HUB = 100;

uint32 internal constant _MODULE_ID_TOKEN = 101;

string internal constant _MODULE_NAME_TOKEN = "TOKEN A";
Expand Down
34 changes: 17 additions & 17 deletions test/ImplementationState.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ contract ImplementationStateTest is ImplementationFixture {
// Constants
// =========

uint32 internal constant _MODULE_ID_EXAMPLE = 2;
uint32 internal constant _MODULE_ID_SINGLE = 100;

// =======
// Storage
// =======

MockImplementationModule public exampleModuleImplementation;
MockImplementationModule public exampleModuleEndpoint;
MockImplementationModule public singleModuleImplementation;
MockImplementationModule public singleModuleEndpoint;

// solhint-disable-next-line var-name-mixedcase
bytes32 public REFLEX_STORAGE_SLOT;
Expand All @@ -42,15 +42,15 @@ contract ImplementationStateTest is ImplementationFixture {
function setUp() public virtual override {
super.setUp();

exampleModuleImplementation = new MockImplementationModule(
IReflexModule.ModuleSettings({moduleId: _MODULE_ID_EXAMPLE, moduleType: _MODULE_TYPE_SINGLE_ENDPOINT})
singleModuleImplementation = new MockImplementationModule(
IReflexModule.ModuleSettings({moduleId: _MODULE_ID_SINGLE, moduleType: _MODULE_TYPE_SINGLE_ENDPOINT})
);

address[] memory moduleAddresses = new address[](1);
moduleAddresses[0] = address(exampleModuleImplementation);
moduleAddresses[0] = address(singleModuleImplementation);
installerEndpoint.addModules(moduleAddresses);

exampleModuleEndpoint = MockImplementationModule(dispatcher.getEndpoint(_MODULE_ID_EXAMPLE));
singleModuleEndpoint = MockImplementationModule(dispatcher.getEndpoint(_MODULE_ID_SINGLE));

REFLEX_STORAGE_SLOT = dispatcher.REFLEX_STORAGE_SLOT();
IMPLEMENTATION_STORAGE_SLOT = dispatcher.IMPLEMENTATION_STORAGE_SLOT();
Expand Down Expand Up @@ -115,36 +115,36 @@ contract ImplementationStateTest is ImplementationFixture {
* | ReflexState.modules | address | REFLEX_STORAGE_SLOT + 3 | 0 | 32 |
*/
vm.record();
dispatcher.getReflexState3(_MODULE_ID_EXAMPLE);
dispatcher.getReflexState3(_MODULE_ID_SINGLE);
(reads, ) = vm.accesses(address(dispatcher));
assertEq((reads[0]), keccak256(abi.encode(_MODULE_ID_EXAMPLE, uint256(REFLEX_STORAGE_SLOT) + 3)));
assertEq((reads[0]), keccak256(abi.encode(_MODULE_ID_SINGLE, uint256(REFLEX_STORAGE_SLOT) + 3)));
current = vm.load(address(dispatcher), bytes32(reads[0]));
assertEq(address(uint160(uint256(current))), address(exampleModuleImplementation));
assertEq(address(uint160(uint256(current))), address(singleModuleImplementation));

/**
* | Name | Type | Slot | Offset | Bytes |
* |-----------------------|---------|-------------------------|--------|-------|
* | ReflexState.endpoints | address | REFLEX_STORAGE_SLOT + 4 | 0 | 32 |
*/
vm.record();
dispatcher.getReflexState4(_MODULE_ID_EXAMPLE);
dispatcher.getReflexState4(_MODULE_ID_SINGLE);
(reads, ) = vm.accesses(address(dispatcher));
assertEq((reads[0]), keccak256(abi.encode(_MODULE_ID_EXAMPLE, uint256(REFLEX_STORAGE_SLOT) + 4)));
assertEq((reads[0]), keccak256(abi.encode(_MODULE_ID_SINGLE, uint256(REFLEX_STORAGE_SLOT) + 4)));
current = vm.load(address(dispatcher), bytes32(reads[0]));
assertEq(address(uint160(uint256(current))), address(exampleModuleEndpoint));
assertEq(address(uint160(uint256(current))), address(singleModuleEndpoint));

/**
* | Name | Type | Slot | Offset | Bytes |
* |-----------------------|---------|-------------------------|--------|-------|
* | ReflexState.relations | address | REFLEX_STORAGE_SLOT + 5 | 0 | 32 |
*/
vm.record();
dispatcher.getReflexState5(address(exampleModuleEndpoint));
dispatcher.getReflexState5(address(singleModuleEndpoint));
(reads, ) = vm.accesses(address(dispatcher));
assertEq((reads[0]), keccak256(abi.encode(address(exampleModuleEndpoint), uint256(REFLEX_STORAGE_SLOT) + 5)));
assertEq((reads[0]), keccak256(abi.encode(address(singleModuleEndpoint), uint256(REFLEX_STORAGE_SLOT) + 5)));
current = vm.load(address(dispatcher), bytes32(reads[0]));
assertEq(uint32(uint256(current)), exampleModuleImplementation.moduleId());
assertEq(address(uint160(uint256(current) >> 32)), address(exampleModuleImplementation));
assertEq(uint32(uint256(current)), singleModuleImplementation.moduleId());
assertEq(address(uint160(uint256(current) >> 32)), address(singleModuleImplementation));
}

function testFuzzStorageImplementationStorageLayout(
Expand Down
2 changes: 1 addition & 1 deletion test/ReflexModule.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract ReflexModuleTest is ReflexFixture {
// Constants
// =========

uint32 internal constant _MODULE_ID_VALID = 5;
uint32 internal constant _MODULE_ID_VALID = 777;
uint16 internal constant _MODULE_TYPE_VALID = _MODULE_TYPE_SINGLE_ENDPOINT;

uint32 internal constant _MODULE_ID_INVALID = 0;
Expand Down

0 comments on commit 34cdea3

Please sign in to comment.