forked from axieinfinity/ronin-dpos-contracts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c71511
commit aad0891
Showing
2 changed files
with
139 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
test/bridge/integration/ronin-gateway/updateOperator.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import { console2 as console } from "forge-std/console2.sol"; | ||
import { Transfer } from "@ronin/contracts/libraries/Transfer.sol"; | ||
import { Token } from "@ronin/contracts/libraries/Token.sol"; | ||
import { ContractType } from "@ronin/contracts/utils/ContractType.sol"; | ||
import { IsolatedGovernance } from "@ronin/contracts/libraries/IsolatedGovernance.sol"; | ||
import { VoteStatusConsumer } from "@ronin/contracts/interfaces/consumers/VoteStatusConsumer.sol"; | ||
import { MockRoninGatewayV3Extended } from "@ronin/contracts/mocks/ronin/MockRoninGatewayV3Extended.sol"; | ||
import "../BaseIntegration.t.sol"; | ||
|
||
contract UpdateOperator_RoninGatewayV3_Test is BaseIntegration_Test { | ||
using Transfer for Transfer.Receipt; | ||
|
||
address _newBridgeOperator; | ||
uint256 _numOperatorsForVoteExecuted; | ||
Transfer.Receipt[] first50Receipts; | ||
Transfer.Receipt[] second50Receipts; | ||
|
||
function setUp() public virtual override { | ||
super.setUp(); | ||
_config.switchTo(Network.RoninLocal.key()); | ||
|
||
vm.deal(address(_bridgeReward), 10 ether); | ||
_newBridgeOperator = makeAddr("new-bridge-operator"); | ||
Transfer.Receipt memory sampleReceipt = Transfer.Receipt({ | ||
id: 0, | ||
kind: Transfer.Kind.Deposit, | ||
ronin: Token.Owner({ addr: makeAddr("recipient"), tokenAddr: address(_roninWeth), chainId: _param.test.roninChainId }), | ||
mainchain: Token.Owner({ | ||
addr: makeAddr("requester"), | ||
tokenAddr: address(_mainchainWeth), | ||
chainId: _param.test.mainchainChainId | ||
}), | ||
info: Token.Info({ erc: Token.Standard.ERC20, id: 0, quantity: 100 }) | ||
}); | ||
|
||
uint256 id = 1; | ||
for (uint256 i; i < 50; i++) { | ||
first50Receipts.push(sampleReceipt); | ||
second50Receipts.push(sampleReceipt); | ||
first50Receipts[i].id = id; | ||
second50Receipts[i].id = id + 50; | ||
|
||
id++; | ||
} | ||
|
||
_numOperatorsForVoteExecuted = | ||
_param.roninBridgeManager.bridgeOperators.length * _param.roninBridgeManager.num / _param.roninBridgeManager.denom; | ||
} | ||
|
||
function test_bulkDeposit_100Txs() public { | ||
_setTimestampToPeriodEnding(); | ||
_wrapUpEpochAndMine(); | ||
uint256 periodAfter = _validatorSet.currentPeriod(); | ||
|
||
for (uint256 i; i < _numOperatorsForVoteExecuted; i++) { | ||
vm.prank(_param.roninBridgeManager.bridgeOperators[i]); | ||
_roninGatewayV3.tryBulkDepositFor(first50Receipts); | ||
} | ||
|
||
vm.prank(_param.roninBridgeManager.governors[0]); | ||
_roninBridgeManager.updateBridgeOperator(_newBridgeOperator); | ||
|
||
_param.roninBridgeManager.bridgeOperators[0] = _newBridgeOperator; | ||
|
||
for (uint256 i; i < _numOperatorsForVoteExecuted; i++) { | ||
vm.prank(_param.roninBridgeManager.bridgeOperators[i]); | ||
_roninGatewayV3.tryBulkDepositFor(second50Receipts); | ||
} | ||
|
||
uint256[] memory totalBallots2 = | ||
_bridgeTracking.getManyTotalBallots(periodAfter, _param.roninBridgeManager.bridgeOperators); | ||
|
||
_setTimestampToPeriodEnding(); | ||
_wrapUpEpochAndMine(); | ||
_wrapUpEpochAndMine(); | ||
|
||
Transfer.Receipt memory sampleReceipt = first50Receipts[0]; | ||
sampleReceipt.id = 101; | ||
|
||
for (uint256 i; i < _numOperatorsForVoteExecuted; i++) { | ||
vm.prank(_param.roninBridgeManager.bridgeOperators[i]); | ||
_roninGatewayV3.depositFor(sampleReceipt); | ||
} | ||
} | ||
} |