|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
pragma solidity ^0.8.0;
|
|
|
|
|
|
|
|
import "../proxy/utils/Initializable.sol";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @title InitializableMock
|
|
|
|
* @dev This contract is a mock to test initializable functionality
|
|
|
|
*/
|
|
|
|
contract InitializableMock is Initializable {
|
|
|
|
bool public initializerRan;
|
|
|
|
bool public onlyInitializingRan;
|
|
|
|
uint256 public x;
|
|
|
|
|
|
|
|
function initialize() public initializer {
|
|
|
|
initializerRan = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function initializeOnlyInitializing() public onlyInitializing {
|
|
|
|
onlyInitializingRan = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function initializerNested() public initializer {
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onlyInitializingNested() public initializer {
|
|
|
|
initializeOnlyInitializing();
|
|
|
|
}
|
|
|
|
|
|
|
|
function initializeWithX(uint256 _x) public payable initializer {
|
|
|
|
x = _x;
|
|
|
|
}
|
|
|
|
|
|
|
|
function nonInitializable(uint256 _x) public payable {
|
|
|
|
x = _x;
|
|
|
|
}
|
|
|
|
|
|
|
|
function fail() public pure {
|
|
|
|
require(false, "InitializableMock forced failure");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contract ConstructorInitializableMock is Initializable {
|
|
|
|
bool public initializerRan;
|
|
|
|
bool public onlyInitializingRan;
|
|
|
|
|
|
|
|
constructor() initializer {
|
|
|
|
initialize();
|
|
|
|
initializeOnlyInitializing();
|
|
|
|
}
|
|
|
|
|
|
|
|
function initialize() public initializer {
|
|
|
|
initializerRan = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function initializeOnlyInitializing() public onlyInitializing {
|
|
|
|
onlyInitializingRan = true;
|
|
|
|
}
|
|
|
|
}
|