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.
test(RoninGatewayV3): test deposit vote
- Loading branch information
1 parent
44f1f07
commit 5a30ecb
Showing
10 changed files
with
303 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import "foundry-deployment-kit/BaseMigration.s.sol"; | ||
|
||
abstract contract BaseMigrationV2 is BaseMigration { | ||
using StdStyle for *; | ||
using LibString for bytes32; | ||
using LibProxy for address payable; | ||
|
||
function _deployProxy(TContract contractType, bytes memory args) | ||
internal | ||
virtual | ||
override | ||
logFn(string.concat("_deployProxy ", TContract.unwrap(contractType).unpackOne())) | ||
returns (address payable deployed) | ||
{ | ||
string memory contractName = CONFIG.getContractName(contractType); | ||
|
||
address logic = _deployLogic(contractType); | ||
string memory proxyAbsolutePath = "TransparentUpgradeableProxyV2.sol:TransparentUpgradeableProxyV2"; | ||
uint256 proxyNonce; | ||
address proxyAdmin = _getProxyAdmin(); | ||
assertTrue(proxyAdmin != address(0x0), "BaseMigration: Null ProxyAdmin"); | ||
|
||
(deployed, proxyNonce) = _deployRaw(proxyAbsolutePath, abi.encode(logic, proxyAdmin, args)); | ||
|
||
// validate proxy admin | ||
address actualProxyAdmin = deployed.getProxyAdmin(); | ||
assertEq( | ||
actualProxyAdmin, | ||
proxyAdmin, | ||
string.concat( | ||
"BaseMigration: Invalid proxy admin\n", | ||
"Actual: ", | ||
vm.toString(actualProxyAdmin), | ||
"\nExpected: ", | ||
vm.toString(proxyAdmin) | ||
) | ||
); | ||
|
||
CONFIG.setAddress(network(), contractType, deployed); | ||
ARTIFACT_FACTORY.generateArtifact( | ||
sender(), deployed, proxyAbsolutePath, string.concat(contractName, "Proxy"), args, proxyNonce | ||
); | ||
} | ||
} |
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
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
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
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
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
Empty file.
64 changes: 64 additions & 0 deletions
64
test/bridge/integration/ronin-gateway/depositVote.RoninGatewayV3.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,64 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
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 DepositVote_RoninGatewayV3_Test is BaseIntegration_Test { | ||
using Transfer for Transfer.Receipt; | ||
|
||
Transfer.Receipt[] _depositReceipts; | ||
|
||
function setUp() public virtual override { | ||
super.setUp(); | ||
_config.switchTo(Network.RoninLocal.key()); | ||
|
||
bytes memory calldata_ = | ||
abi.encodeCall(IHasContracts.setContract, (ContractType.BRIDGE_TRACKING, address(_bridgeTracking))); | ||
_roninProposalUtils.functionDelegateCallGlobal( | ||
GlobalProposal.TargetOption.GatewayContract, _roninNonce++, calldata_ | ||
); | ||
|
||
vm.etch(address(_roninGatewayV3), address(new MockRoninGatewayV3Extended()).code); | ||
} | ||
|
||
function test_depositVote() public { | ||
Transfer.Receipt memory receipt = 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 }) | ||
}); | ||
|
||
_depositReceipts.push(receipt); | ||
receipt.id = 1; | ||
_depositReceipts.push(receipt); | ||
|
||
for (uint256 i; i < _param.roninBridgeManager.num - 1; i++) { | ||
vm.prank(_param.roninBridgeManager.bridgeOperators[i]); | ||
_roninGatewayV3.tryBulkDepositFor(_depositReceipts); | ||
} | ||
|
||
for (uint256 i = 0; i < _depositReceipts.length; i++) { | ||
(VoteStatusConsumer.VoteStatus status,,,) = | ||
_roninGatewayV3.depositVote(_depositReceipts[i].mainchain.chainId, _depositReceipts[i].id); | ||
|
||
assertEq(uint256(uint8(status)), uint256(uint8(VoteStatusConsumer.VoteStatus.Pending))); | ||
|
||
uint256 totalWeight = MockRoninGatewayV3Extended(payable(address(_roninGatewayV3))).getDepositVoteWeight( | ||
_depositReceipts[i].mainchain.chainId, i, Transfer.hash(_depositReceipts[i]) | ||
); | ||
assertEq(totalWeight, (_param.roninBridgeManager.num - 1) * 100); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.