Skip to content

Commit

Permalink
Start first cycle when first time enable prod mode
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiushi committed May 14, 2024
1 parent 663ae5c commit 355a5d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion contracts/exchange.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract Exchange is Initializable, UUPSUpgradeable, OwnableUpgradeable {

test_mode = true;

_newCycle();
//_newCycle();
}

function getCircleBalance(uint256 circle) public view returns (uint256) {
Expand Down Expand Up @@ -207,6 +207,11 @@ contract Exchange is Initializable, UUPSUpgradeable, OwnableUpgradeable {

// 将剩余的DMC还给owner
DMC(dmcToken).transfer(msg.sender, DMC(dmcToken).balanceOf(address(this)));

// 如果是首次开启生产模式,初始化第一个周期
if (current_circle == 0) {
_newCycle();
}
}

function addFreeDMCTestMintBalance(uint256 amount) public onlyOwner testEnabled {
Expand Down
2 changes: 2 additions & 0 deletions test/test_exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ describe("Exchange", function () {
})

it("enable prod mode", async () => {
// 模拟在开启生产模式之前过了很久,超过一个周期的情况
mine(20, {interval: 1000});
await (await exchange.enableProdMode()).wait();

await expect(exchange.enableProdMode()).to.revertedWith("contract not in test mode");
Expand Down

0 comments on commit 355a5d8

Please sign in to comment.