Skip to content

Conversation

@OT-kraftchain
Copy link
Collaborator

@OT-kraftchain OT-kraftchain commented Oct 24, 2025

Test Migration Status: Hardhat to Forge

Summary

Test Suite Hardhat Tests Forge Tests Migration Status
Bridge Implementation 50 50 Complete
Bridge Management 37 37 Complete

Detailed Test Mappings

Bridge Implementation Tests

Deployment Block (2 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Bridge should be initialized to the correct version" test_BridgeShouldBeInitializedToCorrectVersion Migrated - Direct 1:1 mapping
"Bridge Management should be initialized to the correct version" test_BridgeManagementShouldBeInitializedToCorrectVersion Migrated - Direct 1:1 mapping

Parameter setters Block (6 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Set withdrawal fee" test_SetWithdrawalFee Migrated - Direct 1:1 mapping
"Set min withdrawal amount" test_SetMinWithdrawalAmount Migrated - Direct 1:1 mapping
"Set max withdrawal amount" test_SetMaxWithdrawalAmount Migrated - Direct 1:1 mapping
"Set invalid min and max withdrawal amounts" test_SetInvalidMinAndMaxWithdrawalAmounts Migrated - Direct 1:1 mapping
"Set max deposits per distribution" test_SetMaxDepositsPerDistribution Migrated - Direct 1:1 mapping
"Fail setting max deposits per distribution to zero" test_FailSettingMaxDepositsPerDistributionToZero Migrated - Direct 1:1 mapping

Funding the bridge Block (3 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Fund the bridge contract" test_FundTheBridgeContract Migrated - Direct 1:1 mapping
"Not funder fails to fund the bridge contract" test_NotFunderFailsToFundTheBridgeContract Migrated - Direct 1:1 mapping
"Can fund after set as funder" test_CanFundAfterSetAsFunder Migrated - Direct 1:1 mapping

Deposit Block (19 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Deposit the first Nonce" test_DepositTheFirstNonce Migrated - Direct 1:1 mapping
"Deposit with signatures out of any order" test_DepositWithSignaturesOutOfAnyOrder Migrated - Direct 1:1 mapping
"Deposit with Multiple Continous Nonce" test_DepositWithMultipleContinuousNonce Migrated - Minor spelling fix: "Continous" → "Continuous"
"Deposit with Multiple Times with different Nonce Array" test_DepositWithMultipleTimesWithDifferentNonceArray Migrated - FIXED: Event emission order corrected
"Bridge two deposits with insufficient funds for executing the first deposit" test_BridgeTwoDepositsWithInsufficientFundsForExecutingTheFirstDeposit Migrated - Direct 1:1 mapping
"Bridge three deposits with insufficient funds for executing the second deposit" test_BridgeThreeDepositsWithInsufficientFundsForExecutingTheSecondDeposit Migrated - Direct 1:1 mapping
"Deposit When Recipient is Contract" test_DepositWhenRecipientIsContract Migrated - Direct 1:1 mapping
"Deposit When Deposit Length is Equal to 10" test_DepositWhenDepositLengthIsEqualTo10 Migrated - Direct 1:1 mapping
"Deposit When Recipient Address is Zero Address" test_DepositWhenRecipientAddressIsZeroAddress Migrated - FIXED: Event emission order corrected
"Should revert with no deposits" test_ShouldRevertWithNoDeposits Migrated - Direct 1:1 mapping
"Should revert when providing too many deposits in single transaction" test_ShouldRevertWhenProvidingTooManyDepositsInSingleTransaction Migrated - Direct 1:1 mapping
"Should revert with the wrong first nonce" test_ShouldRevertWithWrongFirstNonce Migrated - Direct 1:1 mapping
"Should revert when nonce is not subsequent" test_ShouldRevertWhenNonceIsNotSubsequent Migrated - Direct 1:1 mapping
"Should revert when signature length less than 5" test_ShouldRevertWhenSignatureLengthLessThan5 Migrated - Direct 1:1 mapping
"Should revert when signature length is 5 but with two duplicate signature" test_ShouldRevertWhenSignatureLengthIs5ButWithTwoDuplicateSignature Migrated - Direct 1:1 mapping
"Should revert when signature verify failed" test_ShouldRevertWhenSignatureVerifyFailed Migrated - Direct 1:1 mapping
"Should revert when root is invalid" test_ShouldRevertWhenRootIsInvalid Migrated - Direct 1:1 mapping

Withdraw Block (6 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"withdraw only once" test_WithdrawOnlyOnce Migrated - Direct 1:1 mapping
"withdraw multiple times" test_WithdrawMultipleTimes Migrated - Direct 1:1 mapping
"withdraw with amount edge case" test_WithdrawWithAmountEdgeCase Migrated - Direct 1:1 mapping
"withdraw with the wrong amount" test_WithdrawWithTheWrongAmount Migrated - Direct 1:1 mapping
"withdraw is too low" test_WithdrawIsTooLow Migrated - Direct 1:1 mapping
"withdraw is too high" test_WithdrawIsTooHigh Migrated - Direct 1:1 mapping
"Withdraw with different fees and verify unclaimed rewards" test_WithdrawWithDifferentFeesAndVerifyUnclaimedRewards Migrated - Direct 1:1 mapping

Claim Block (4 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Claim successful for EOA account" test_ClaimSuccessfulForEOAAccount Migrated - Direct 1:1 mapping
"Claim successful for payable contract" test_ClaimSuccessfulForPayableContract Migrated - Direct 1:1 mapping
"Fail to claim due to Contract not payable" test_FailToClaimDueToContractNotPayable Migrated - Direct 1:1 mapping
"Fail to claim for not existed nonce in the claim table" test_FailToClaimForNotExistedNonceInTheClaimTable Migrated - Direct 1:1 mapping

Pausing Block (6 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Pause with Governor or security guard and unpause with governor" test_PauseWithGovernorOrSecurityGuardAndUnpauseWithGovernor Migrated - Direct 1:1 mapping
"Can only pause if governor or security guard" test_CanOnlyPauseIfGovernorOrSecurityGuard Migrated - Direct 1:1 mapping
"Cannot unpause contract if it's already unpaused" test_CannotUnpauseContractIfItsAlreadyUnpaused Migrated - Direct 1:1 mapping
"Cannot pause contract if it's paused already" test_CannotPauseContractIfItsPausedAlready Migrated - Direct 1:1 mapping
"Cannot deposit, claim or withdraw native coin if contract is paused" test_CannotDepositClaimOrWithdrawNativeCoinIfContractIsPaused Migrated - Direct 1:1 mapping

Withdrawal Pausing Block (6 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Governor can pause withdrawals" test_GovernorCanPauseWithdrawals Migrated - Direct 1:1 mapping
"Governor can unpause withdrawals" test_GovernorCanUnpauseWithdrawals Migrated - Direct 1:1 mapping
"Non-Governor cannot pause withdrawals" test_NonGovernorCannotPauseWithdrawals Migrated - Direct 1:1 mapping
"Non-Governor cannot unpause withdrawals" test_NonGovernorCannotUnpauseWithdrawals Migrated - Direct 1:1 mapping
"Native coin withdrawals are rejected while withdrawals are paused" test_NativeCoinWithdrawalsAreRejectedWhileWithdrawalsArePaused Migrated - Direct 1:1 mapping
"Native coin deposits are allowed while withdrawals are paused" test_NativeCoinDepositsAreAllowedWhileWithdrawalsArePaused Migrated - Direct 1:1 mapping

Bridge Management Tests

Deployment Block (7 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Should be initialized to the correct version" test_ShouldBeInitializedToTheCorrectVersion Migrated - Direct 1:1 mapping
"Should have the right relayer" test_ShouldHaveTheRightRelayer Migrated - Direct 1:1 mapping
"Should have the right validators" test_ShouldHaveTheRightValidators Migrated - Direct 1:1 mapping
"Should have the right owner" test_ShouldHaveTheRightOwner Migrated - Direct 1:1 mapping
"Should have the right governor" test_ShouldHaveTheRightGovernor Migrated - Direct 1:1 mapping
"Should have the right securityGuard" test_ShouldHaveTheRightSecurityGuard Migrated - Direct 1:1 mapping
"Should have the right funder" test_ShouldHaveTheRightFunder Migrated - Direct 1:1 mapping

Bridge role setting Block (10 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Set owner" test_SetOwner Migrated - Direct 1:1 mapping
"Set relayer" test_SetRelayer Migrated - Direct 1:1 mapping
"Set governor" test_SetGovernor Migrated - Direct 1:1 mapping
"Set securityGuard" test_SetSecurityGuard Migrated - Direct 1:1 mapping
"Set funder" test_SetFunder Migrated - Direct 1:1 mapping
"Non-owner fail to start ownership transfer" test_NonOwnerFailToStartOwnershipTransfer Migrated - Direct 1:1 mapping
"Non-owner fail to set relayer" test_NonOwnerFailToSetRelayer Migrated - Direct 1:1 mapping
"Non-owner fail to set governor" test_NonOwnerFailToSetGovernor Migrated - Direct 1:1 mapping
"Non-owner fail to set security guard" test_NonOwnerFailToSetSecurityGuard Migrated - Direct 1:1 mapping
"Non-owner fail to set funder" test_NonOwnerFailToSetFunder Migrated - Direct 1:1 mapping

Bridge validator changes Block (20 tests)

OLD_TEST_NAME (Hardhat) NEW_TEST_NAME (Forge) MIGRATION_STATUS / OBSERVATIONS
"Add validator and increase threshold" test_AddValidatorAndIncreaseThreshold Migrated - Direct 1:1 mapping
"Add validator and keep current threshold" test_AddValidatorAndKeepCurrentThreshold Migrated - Direct 1:1 mapping
"Fail adding validator without authorization" test_FailAddingValidatorWithoutAuthorization Migrated - Direct 1:1 mapping
"Fail adding validator that is already a validator" test_FailAddingValidatorThatIsAlreadyAValidator Migrated - Direct 1:1 mapping
"Fail adding validator with zero address" test_FailAddingValidatorWithZeroAddress Migrated - Direct 1:1 mapping
"Remove validator and decrease current threshold" test_RemoveValidatorAndDecreaseCurrentThreshold Migrated - Direct 1:1 mapping
"Remove validator and keep current threshold" test_RemoveValidatorAndKeepCurrentThreshold Migrated - Direct 1:1 mapping
"Fail removing validator without authorization" test_FailRemovingValidatorWithoutAuthorization Migrated - Direct 1:1 mapping
"Fail removing validator if not a validator" test_FailRemovingValidatorIfNotAValidator Migrated - Direct 1:1 mapping
"Fail removing validator and keep current threshold if threshold was equal to number of validators" test_FailRemovingValidatorAndKeepCurrentThresholdIfThresholdWasEqualToNumberOfValidators Migrated - Direct 1:1 mapping
"Fail removing validator if there are only two validators" test_FailRemovingValidatorIfThereAreOnlyTwoValidators Migrated - Direct 1:1 mapping
"Replace validator" test_ReplaceValidator Migrated - Direct 1:1 mapping
"Fail replacing validator without authorization" test_FailReplacingValidatorWithoutAuthorization Migrated - Direct 1:1 mapping
"Fail replacing validator with zero address" test_FailReplacingValidatorWithZeroAddress Migrated - Direct 1:1 mapping
"Fail replacing a validator address that is no validator" test_FailReplacingAValidatorAddressThatIsNoValidator Migrated - Direct 1:1 mapping
"Fail replacing validator with address that is already a validator" test_FailReplacingValidatorWithAddressThatIsAlreadyAValidator Migrated - Direct 1:1 mapping
"Set validator threshold" test_SetValidatorThreshold Migrated - Direct 1:1 mapping
"Fail setting validator threshold without authorization" test_FailSettingValidatorThresholdWithoutAuthorization Migrated - Direct 1:1 mapping
"Fail setting validator threshold lower than 2" test_FailSettingValidatorThresholdLowerThan2 Migrated - Direct 1:1 mapping
"Fail setting validator threshold higher than number of validators" test_FailSettingValidatorThresholdHigherThanNumberOfValidators Migrated - Direct 1:1 mapping

Migration Notes

Key Fixes Applied During Migration

  1. Event Emission Order Issues:

    • test_DepositWhenRecipientAddressIsZeroAddress(): Fixed event order expectations - NativeDepositRootUpdate emitted before NativeDeposit
    • test_DepositWithMultipleTimesWithDifferentNonceArray(): Fixed event order expectations - same as above
  2. Naming Conventions:

    • Hardhat: describe blocks with it() functions using human-readable strings
    • Forge: function test_*() naming with CamelCase conversion

@OT-kraftchain OT-kraftchain requested a review from Copilot October 24, 2025 13:50
@OT-kraftchain OT-kraftchain changed the base branch from develop to feat/initializable-message-bridge October 24, 2025 13:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the test suite from Hardhat (TypeScript) to Forge (Solidity), completing the transition for both Bridge Implementation and Bridge Management test suites with 87 total tests migrated.

Key changes:

  • All 50 Bridge Implementation tests successfully migrated to Forge with minor fixes for event emission ordering
  • All 37 Bridge Management tests migrated with 1:1 mapping to original functionality
  • Test helper contracts refactored to use production MessageBridge instead of test version
  • Documentation emoji formatting standardized across deployment scripts

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/test-equivalence.md New comprehensive tracking document mapping all 87 migrated tests from Hardhat to Forge with migration notes
test/BridgeImplementationForge.t.sol Complete Bridge Implementation test suite (50 tests) migrated to Solidity with helper functions and fixed event ordering
test/BridgeManagementForge.t.sol Complete Bridge Management test suite (37 tests) migrated to Solidity with role and validator management tests
test/MessageBridgeTestHelper.sol Updated to use production MessageBridge contract instead of TestMessageBridge
contracts/tests/TestMessageBridge.sol Simplified to delegate initialization to parent MessageBridge class
contracts/messageBridge/MessageBridge.sol Added initialize and __initialize functions to support both production and test initialization patterns
scripts/deploy/*.ts Standardized console output by removing emoji characters from deployment logging

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@OT-kraftchain OT-kraftchain force-pushed the chore/move-tests-to-forge branch from a221f6e to 8823d5e Compare October 24, 2025 13:52
Base automatically changed from feat/initializable-message-bridge to develop October 24, 2025 13:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mialbu mialbu requested a review from Copilot October 31, 2025 10:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

)
external
override
initializer
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The override keyword is used here, but the parent MessageBridge.initialize function is marked as virtual, not as an interface function. Additionally, both this function and the parent use the initializer modifier. When overriding, only one initializer modifier should be used in the inheritance chain to avoid issues. The parent's initializer modifier will not be invoked when this override is called. Consider removing the initializer modifier from this override since __initialize uses onlyInitializing which works correctly in the override pattern.

Suggested change
initializer

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants