github.com/ethereum-optimism/optimism@v1.7.2/packages/contracts-bedrock/test/dispute/lib/LibGameId.t.sol (about)

     1  // SPDX-License-Identifier: MIT
     2  pragma solidity ^0.8.15;
     3  
     4  import { Test } from "forge-std/Test.sol";
     5  
     6  import { LibGameId } from "src/dispute/lib/LibGameId.sol";
     7  import { IDisputeGame } from "src/dispute/interfaces/IDisputeGame.sol";
     8  import "src/libraries/DisputeTypes.sol";
     9  
    10  contract LibGameId_Test is Test {
    11      /// @dev Tests that a round trip of packing and unpacking a GameId maintains the same values.
    12      function testFuzz_gameId_roundTrip_succeeds(
    13          GameType _gameType,
    14          Timestamp _timestamp,
    15          IDisputeGame _gameProxy
    16      )
    17          public
    18      {
    19          GameId gameId = LibGameId.pack(_gameType, _timestamp, _gameProxy);
    20          (GameType gameType_, Timestamp timestamp_, IDisputeGame gameProxy_) = LibGameId.unpack(gameId);
    21  
    22          assertEq(GameType.unwrap(gameType_), GameType.unwrap(_gameType));
    23          assertEq(Timestamp.unwrap(timestamp_), Timestamp.unwrap(_timestamp));
    24          assertEq(address(gameProxy_), address(_gameProxy));
    25      }
    26  }