Skip to content

Commit

Permalink
Transfer unit tests for new token implementation (#2310)
Browse files Browse the repository at this point in the history
* remove nonreentrant modifiers from the toke code as they are not needed

* add setup for all account types

* check all relevant contract initial states

* add test between any possible contract accounts

* prettier

* add some documentation and prettier
  • Loading branch information
sparrowDom authored Nov 15, 2024
1 parent d7a303f commit 2b3189f
Show file tree
Hide file tree
Showing 6 changed files with 608 additions and 46 deletions.
25 changes: 25 additions & 0 deletions contracts/contracts/mocks/TestUpgradedOUSD.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../token/OUSD.sol";

// used to alter internal state of OUSD contract
contract TestUpgradedOUSD is OUSD {
constructor() OUSD() {}

function overwriteCreditBalances(address _account, uint256 _creditBalance)
public
{
_creditBalances[_account] = _creditBalance;
}

function overwriteAlternativeCPT(address _account, uint256 _acpt) public {
alternativeCreditsPerToken[_account] = _acpt;
}

function overwriteRebaseState(address _account, RebaseOptions _rebaseOption)
public
{
rebaseState[_account] = _rebaseOption;
}
}
4 changes: 2 additions & 2 deletions contracts/contracts/token/OUSD.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ contract OUSD is Governable {
uint256 public _totalSupply;
mapping(address => mapping(address => uint256)) private _allowances;
address public vaultAddress = address(0);
mapping(address => uint256) private _creditBalances;
mapping(address => uint256) internal _creditBalances;
uint256 private _rebasingCredits; // Sum of all rebasing credits (_creditBalances for rebasing accounts)
uint256 private _rebasingCreditsPerToken;
uint256 public nonRebasingSupply; // All nonrebasing balances
Expand Down Expand Up @@ -538,7 +538,7 @@ contract OUSD is Governable {
// prettier-ignore
require(
state == RebaseOptions.StdNonRebasing ||
state == RebaseOptions.NotSet,
state == RebaseOptions.NotSet,
"Only standard non-rebasing accounts can opt in"
);

Expand Down
8 changes: 7 additions & 1 deletion contracts/deploy/deployActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
getOracleAddresses,
isMainnet,
isHolesky,
isTest,
} = require("../test/helpers.js");
const { deployWithConfirmation, withConfirmation } = require("../utils/deploy");
const {
Expand Down Expand Up @@ -1190,7 +1191,12 @@ const deployOUSDCore = async () => {
await deployWithConfirmation("VaultProxy");

// Main contracts
const dOUSD = await deployWithConfirmation("OUSD");
let dOUSD;
if (isTest) {
dOUSD = await deployWithConfirmation("TestUpgradedOUSD");
} else {
dOUSD = await deployWithConfirmation("OUSD");
}
const dVault = await deployWithConfirmation("Vault");
const dVaultCore = await deployWithConfirmation("VaultCore");
const dVaultAdmin = await deployWithConfirmation("VaultAdmin");
Expand Down
Loading

0 comments on commit 2b3189f

Please sign in to comment.