From 1ad9cff1aee7d93c5c810cca8bd2642991ebec10 Mon Sep 17 00:00:00 2001 From: huyhuynh3103 Date: Sat, 27 Jan 2024 19:06:44 +0700 Subject: [PATCH] test: fix nonce --- test/bridge/integration/BaseIntegration.t.sol | 33 ++++++++++++++----- ...oteBridgeOperator.RoninBridgeManager.t.sol | 6 ++-- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/test/bridge/integration/BaseIntegration.t.sol b/test/bridge/integration/BaseIntegration.t.sol index b9ba4536..9737356e 100644 --- a/test/bridge/integration/BaseIntegration.t.sol +++ b/test/bridge/integration/BaseIntegration.t.sol @@ -86,9 +86,6 @@ contract BaseIntegration_Test is Base_Test { RoninBridgeAdminUtils _roninProposalUtils; ProposalUtils _mainchainProposalUtils; - uint256 _roninNonce = 1; - uint256 _mainchainNonce = 1; - function setUp() public virtual { _deployGeneralConfig(); @@ -325,7 +322,7 @@ contract BaseIntegration_Test is Base_Test { value: 0, calldata_: abi.encodeCall(GlobalCoreGovernance.updateManyTargetOption, (param.targetOptions, param.targets)), gasAmount: 500_000, - nonce: _roninNonce++ + nonce: _roninBridgeManager.round(0) + 1 }); SignatureConsumer.Signature[] memory signatures = @@ -342,7 +339,7 @@ contract BaseIntegration_Test is Base_Test { value: 0, calldata_: abi.encodeCall(IHasContracts.setContract, (ContractType.BRIDGE, param.bridgeContract)), gasAmount: 500_000, - nonce: _roninNonce++ + nonce: _roninBridgeManager.round(0) + 1 }); SignatureConsumer.Signature[] memory signatures = @@ -362,7 +359,7 @@ contract BaseIntegration_Test is Base_Test { value: 0, calldata_: calldata_, gasAmount: 500_000, - nonce: _roninNonce++ + nonce: _roninBridgeManager.round(0) + 1 }); SignatureConsumer.Signature[] memory signatures = @@ -400,7 +397,7 @@ contract BaseIntegration_Test is Base_Test { value: 0, calldata_: abi.encodeCall(GlobalCoreGovernance.updateManyTargetOption, (param.targetOptions, param.targets)), gasAmount: 500_000, - nonce: _mainchainNonce++ + nonce: _mainchainBridgeManager.round(0) + 1 }); SignatureConsumer.Signature[] memory signatures = @@ -417,7 +414,27 @@ contract BaseIntegration_Test is Base_Test { value: 0, calldata_: abi.encodeCall(IHasContracts.setContract, (ContractType.BRIDGE, param.bridgeContract)), gasAmount: 500_000, - nonce: _mainchainNonce++ + nonce: _mainchainBridgeManager.round(0) + 1 + }); + + SignatureConsumer.Signature[] memory signatures = + _mainchainProposalUtils.generateSignaturesGlobal(globalProposal, _param.test.governorPKs); + + vm.prank(_param.roninBridgeManager.governors[0]); + _mainchainBridgeManager.relayGlobalProposal(globalProposal, supports_, signatures); + } + + { + // set callback register + bytes memory calldata_ = + abi.encodeCall(IBridgeManagerCallbackRegister.registerCallbacks, (param.callbackRegisters)); + GlobalProposal.GlobalProposalDetail memory globalProposal = _mainchainProposalUtils.createGlobalProposal({ + expiryTimestamp: block.timestamp + 10, + targetOption: GlobalProposal.TargetOption.BridgeManager, + value: 0, + calldata_: calldata_, + gasAmount: 500_000, + nonce: _mainchainBridgeManager.round(0) + 1 }); SignatureConsumer.Signature[] memory signatures = diff --git a/test/bridge/integration/bridge-manager/propose-and-cast-vote/voteBridgeOperator.RoninBridgeManager.t.sol b/test/bridge/integration/bridge-manager/propose-and-cast-vote/voteBridgeOperator.RoninBridgeManager.t.sol index 4bc604b3..0b831b4c 100644 --- a/test/bridge/integration/bridge-manager/propose-and-cast-vote/voteBridgeOperator.RoninBridgeManager.t.sol +++ b/test/bridge/integration/bridge-manager/propose-and-cast-vote/voteBridgeOperator.RoninBridgeManager.t.sol @@ -62,8 +62,8 @@ contract VoteBridgeOperator_RoninBridgeManager_Test is BaseIntegration_Test { targetOption: GlobalProposal.TargetOption.BridgeManager, value: 0, calldata_: abi.encodeCall(IBridgeManager.addBridgeOperators, (_voteWeights, _addingGovernors, _addingOperators)), - gasAmount: 500_000, - nonce: _roninNonce++ + gasAmount: 1_000_000, + nonce: _roninBridgeManager.round(0) + 1 }); SignatureConsumer.Signature[] memory signatures = @@ -125,7 +125,7 @@ contract VoteBridgeOperator_RoninBridgeManager_Test is BaseIntegration_Test { value: 0, calldata_: abi.encodeCall(IBridgeManager.addBridgeOperators, (_voteWeights, _addingGovernors, _addingOperators)), gasAmount: 200_000 * numAddingOperators, - nonce: _roninNonce++ + nonce: _roninBridgeManager.round(0) + 1 }); SignatureConsumer.Signature[] memory signatures =