diff --git a/foundry/src/FoxStaking.sol b/foundry/src/FoxStaking.sol index d598a06..9f995f6 100644 --- a/foundry/src/FoxStaking.sol +++ b/foundry/src/FoxStaking.sol @@ -16,6 +16,7 @@ contract FoxStaking is OwnableUpgradeable { using SafeERC20 for IERC20; + uint256 public version; IERC20 public foxToken; mapping(address => StakingInfo) public stakingInfo; bool public stakingPaused; @@ -46,6 +47,7 @@ contract FoxStaking is __Ownable_init(msg.sender); __UUPSUpgradeable_init(); __Pausable_init(); + version = 1; foxToken = IERC20(foxTokenAddress); stakingPaused = false; withdrawalsPaused = false; diff --git a/foundry/test/FoxStakingTestUpgrades.t.sol b/foundry/test/FoxStakingTestUpgrades.t.sol new file mode 100644 index 0000000..dfb4248 --- /dev/null +++ b/foundry/test/FoxStakingTestUpgrades.t.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.25; + +import "forge-std/Test.sol"; +import "../src/FoxStaking.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; +import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; +import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol"; +import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol"; +import {MockFOXToken} from "./MockFOXToken.sol"; + +contract FOXStakingTestUpgrades is Test { + FoxStaking public foxStaking; + MockFOXToken public foxToken; + address user = address(0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045); + + function setUp() public { + foxToken = new MockFOXToken(); + address foxStakingProxy = Upgrades.deployUUPSProxy( + "FoxStaking.sol", + abi.encodeCall(FoxStaking.initialize, (address(foxToken))) + ); + foxStaking = FoxStaking(foxStakingProxy); + } + + function testCanDeploy() public view { + uint256 expectedVersion = 1; + assertEq(foxStaking.version(), expectedVersion); + } +} diff --git a/foundry/test/MockFOXToken.sol b/foundry/test/MockFOXToken.sol new file mode 100644 index 0000000..dfa7110 --- /dev/null +++ b/foundry/test/MockFOXToken.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.25; + +import "forge-std/Test.sol"; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +contract MockFOXToken is ERC20 { + constructor() ERC20("Mock FOX Token", "FOX") { + // 1M FOX for testing, only in local chain can't use this as voting power soz + _mint(address(this), 1e24); + } + + function makeItRain(address to, uint256 amount) public { + _transfer(address(this), to, amount); + } +}