-
Notifications
You must be signed in to change notification settings - Fork 159
Add integration tests for the contract upgrade #1749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
de9067c
Add integration tests for the 202603 contract upgrade
yrong 6a0f5c2
Revamp the test
yrong 2aa8920
Test submitV1
yrong a46d337
Test IGatewayV1.sendToken
yrong 3f3bc55
Test v2_sendMessage
yrong bab49bd
Update control
yrong 002d7d6
Add command alias
yrong bb8aac7
Update runtime
yrong da3f4ad
Disable control build in CI
yrong 2bfa830
Add DOT test
yrong 0b194bb
Use deployed address
yrong 0841e84
Use wss endpoint
yrong e49e9a2
Optimize imports
yrong e54751a
Cleanup
yrong 714b565
Remove legacy tenderly forked
yrong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,36 +1,26 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity 0.8.34; | ||
|
|
||
| import {Vm} from "forge-std/Vm.sol"; | ||
| import {Test} from "forge-std/Test.sol"; | ||
| import {stdJson} from "forge-std/StdJson.sol"; | ||
| import {console} from "forge-std/console.sol"; | ||
| import {UD60x18, ud60x18, unwrap} from "prb/math/src/UD60x18.sol"; | ||
|
|
||
| import {IUpgradable} from "../../src/interfaces/IUpgradable.sol"; | ||
| import {IGatewayV1} from "../../src/v1/IGateway.sol"; | ||
| import {Verification} from "../../src/Verification.sol"; | ||
| import {Gateway} from "../../src/Gateway.sol"; | ||
| import {Gateway202509} from "../../src/upgrade/Gateway202509.sol"; | ||
| import {AgentExecutor} from "../../src/AgentExecutor.sol"; | ||
| import {UD60x18, unwrap} from "prb/math/src/UD60x18.sol"; | ||
| import {WETH9} from "canonical-weth/WETH9.sol"; | ||
|
|
||
| import {IUpgradable} from "../src/interfaces/IUpgradable.sol"; | ||
| import {IGatewayV1} from "../src/v1/IGateway.sol"; | ||
| import {Verification} from "../src/Verification.sol"; | ||
| import {Gateway} from "../src/Gateway.sol"; | ||
| import {Gateway202509} from "../src/upgrade/Gateway202509.sol"; | ||
| import {AgentExecutor} from "../src/AgentExecutor.sol"; | ||
| import { | ||
| UpgradeParams, | ||
| SetOperatingModeParams, | ||
| OperatingMode, | ||
| RegisterForeignTokenParams | ||
| } from "../../src/v1/Types.sol"; | ||
| import { | ||
| ChannelID, | ||
| ParaID, | ||
| OperatingMode, | ||
| InboundMessage, | ||
| Command, | ||
| TokenInfo, | ||
| MintForeignTokenParams | ||
| } from "../../src/v1/Types.sol"; | ||
| import {MultiAddress, multiAddressFromBytes32} from "../../src/v1/MultiAddress.sol"; | ||
| } from "../src/v1/Types.sol"; | ||
|
Comment on lines
14
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can simplify to:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| import {MultiAddress, multiAddressFromBytes32} from "../src/v1/MultiAddress.sol"; | ||
| import {ForkTestFixtures, SubmitMessageFixture} from "../test/utils/ForkTestFixtures.sol"; | ||
| import {WETH9} from "canonical-weth/WETH9.sol"; | ||
|
|
||
| contract ForkUpgradeTest is Test { | ||
| address private constant GATEWAY_PROXY = 0x27ca963C279c93801941e1eB8799c23f407d68e7; | ||
|
|
@@ -52,16 +42,15 @@ contract ForkUpgradeTest is Test { | |
| 0x4e241583d94b5d48a27a22064cd49b2ed6f5231d2d950e432f9b7c2e0ade52b2; | ||
| address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; | ||
| WETH9 public weth = WETH9(payable(WETH)); | ||
| string internal constant FORK_RPC_URL = | ||
| "https://virtual.mainnet.eu.rpc.tenderly.co/61589e0a-d204-449b-b095-64366ea949cb"; | ||
|
|
||
| event Transfer(address indexed from, address indexed to, uint256 value); | ||
|
|
||
| function setUp() public {} | ||
|
|
||
| function setUp23432697() public { | ||
| vm.createSelectFork( | ||
| "https://virtual.mainnet.eu.rpc.tenderly.co/dc7e68d7-5fac-4a88-a797-01ed4155f437", | ||
| 23_432_697 | ||
| ); | ||
| vm.createSelectFork(FORK_RPC_URL, 23_432_697); | ||
|
|
||
| (UD60x18 exchangeRate, uint128 deliveryCost) = | ||
| IGatewayV1(GATEWAY_PROXY).pricingParameters(); | ||
|
|
@@ -183,16 +172,14 @@ contract ForkUpgradeTest is Test { | |
| vm.expectEmit(true, false, false, false); | ||
| emit IGatewayV1.OutboundMessageAccepted(paraID.into(), 1, bytes32("0x"), hex""); | ||
| hoax(user, amount + fee); | ||
| IGatewayV1(address(GATEWAY_PROXY)) | ||
| .sendToken{value: amount + fee}(address(0), paraID, recipientAddress32, 1, amount); | ||
| IGatewayV1(address(GATEWAY_PROXY)).sendToken{value: amount + fee}( | ||
| address(0), paraID, recipientAddress32, 1, amount | ||
| ); | ||
| assertEq(user.balance, 0); | ||
| } | ||
|
|
||
| function setUp23526799() public { | ||
| vm.createSelectFork( | ||
| "https://virtual.mainnet.eu.rpc.tenderly.co/1d4ab8c5-01fe-45a7-8583-8b4925e5a435", | ||
| 23_526_799 | ||
| ); | ||
| vm.createSelectFork(FORK_RPC_URL, 23_526_799); | ||
|
|
||
| // Mock call to Verification.verifyCommitment to bypass BEEFY verification. | ||
| // Note that after the gateway is upgraded, the gateway will be linked to a new Verification | ||
|
|
@@ -311,8 +298,9 @@ contract ForkUpgradeTest is Test { | |
| bytes32(0x65b3c8970f6316e368291bddf21059f298f18ad356faafed0ac19244f15dc67f), | ||
| hex"" | ||
| ); | ||
| IGatewayV1(address(GATEWAY_PROXY)) | ||
| .sendToken{value: fee}(DOT, paraID, recipientAddress32, 1, amount); | ||
| IGatewayV1(address(GATEWAY_PROXY)).sendToken{value: fee}( | ||
| DOT, paraID, recipientAddress32, 1, amount | ||
| ); | ||
| } | ||
|
|
||
| // Send WETH can work with the upgraded Gateway | ||
|
|
@@ -337,7 +325,8 @@ contract ForkUpgradeTest is Test { | |
| emit IGatewayV1.TokenSent(WETH, user, paraID, recipientAddress32, amount); | ||
| vm.expectEmit(true, false, false, false); | ||
| emit IGatewayV1.OutboundMessageAccepted(paraID.into(), 1, bytes32("0x"), hex""); | ||
| IGatewayV1(address(GATEWAY_PROXY)) | ||
| .sendToken{value: fee}(WETH, paraID, recipientAddress32, 1, amount); | ||
| IGatewayV1(address(GATEWAY_PROXY)).sendToken{value: fee}( | ||
| WETH, paraID, recipientAddress32, 1, amount | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.