@@ -313,22 +313,36 @@ contract UnitL2Resolver is Test {
313313 _l2Resolver.setRecord (_nodeNameHash, _key, _chainIdBytes);
314314 }
315315
316- function test_GetRecordWhenTheRecordExists (bytes32 _node , string calldata _recordKey , bytes memory _value ) external {
316+ function test_GetRecordWhenTheRecordExists (bytes32 _node , string calldata _recordKey , bytes memory _data ) external {
317317 vm.assume (_node != _reverseLookupNode);
318318
319- _mockAndExpect (address (_ensRegistry), abi.encodeWithSelector (IENS.owner.selector , _node), abi.encode (_nodeOwner));
320- vm.prank (_nodeOwner);
321- _l2Resolver.setRecord (_node, _recordKey, _value);
319+ _setRecord (_node, _recordKey, _data);
322320
323321 // it returns the stored bytes
324- assertEq (_l2Resolver.getRecord (_node, _recordKey), _value );
322+ assertEq (_l2Resolver.getRecord (_node, _recordKey), _data );
325323 }
326324
327325 function test_GetRecordWhenTheRecordDoesNotExist (bytes32 _node , string calldata _recordKey ) external view {
328326 // it returns empty bytes
329327 assertEq (_l2Resolver.getRecord (_node, _recordKey), '' );
330328 }
331329
330+ function test_ChainIdWhenTheChainIdentifierIsSet (bytes calldata _data ) external {
331+ _setRecord (_nodeNameHash, _key, _data);
332+
333+ // it returns the stored EIP-7930 bytes
334+ assertEq (_l2Resolver.chainId (_nodeNameHash), _data);
335+ }
336+
337+ function test_ChainIdWhenTheChainIdentifierIsNotSet (string calldata _recordKey , bytes calldata _data ) external {
338+ // sets the _data for a different key
339+ vm.assume (keccak256 (bytes (_recordKey)) != keccak256 (bytes (_key)));
340+ _setRecord (_nodeNameHash, _recordKey, _data);
341+
342+ // it returns empty bytes
343+ assertEq (_l2Resolver.chainId (_nodeNameHash), '' );
344+ }
345+
332346 /**
333347 * @notice Sets up a mock and expects a call to it
334348 *
@@ -340,4 +354,17 @@ contract UnitL2Resolver is Test {
340354 vm.mockCall (_receiver, _calldata, _returned);
341355 vm.expectCall (_receiver, _calldata);
342356 }
357+
358+ /**
359+ * @notice Sets a record for a given node
360+ * @dev Mocks the _nodeOwner as the owner of the _node in the ENSRegistry
361+ * @param _node The ENS node to set the record for
362+ * @param _recordKey The key to set the record for
363+ * @param _data The data to set the record for
364+ */
365+ function _setRecord (bytes32 _node , string memory _recordKey , bytes memory _data ) internal {
366+ _mockAndExpect (address (_ensRegistry), abi.encodeWithSelector (IENS.owner.selector , _node), abi.encode (_nodeOwner));
367+ vm.prank (_nodeOwner);
368+ _l2Resolver.setRecord (_node, _recordKey, _data);
369+ }
343370}
0 commit comments