Skip to content

Commit

Permalink
test: update for changes from #3204
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Sep 27, 2024
1 parent 181410c commit aaa5b2c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
6 changes: 3 additions & 3 deletions packages/contracts-rfq/test/FastBridgeV2.Dst.Base.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {FastBridgeV2, FastBridgeV2Test, IFastBridge} from "./FastBridgeV2.t.sol";
import {FastBridgeV2, FastBridgeV2Test, IFastBridgeV2} from "./FastBridgeV2.t.sol";

// solhint-disable func-name-mixedcase, ordering
contract FastBridgeV2DstBaseTest is FastBridgeV2Test {
Expand Down Expand Up @@ -29,7 +29,7 @@ contract FastBridgeV2DstBaseTest is FastBridgeV2Test {

// ══════════════════════════════════════════════════ HELPERS ══════════════════════════════════════════════════════

function relay(address caller, uint256 msgValue, IFastBridge.BridgeTransaction memory bridgeTx) public {
function relay(address caller, uint256 msgValue, IFastBridgeV2.BridgeTransactionV2 memory bridgeTx) public {
bytes memory request = abi.encode(bridgeTx);
vm.prank({msgSender: caller, txOrigin: caller});
fastBridge.relay{value: msgValue}(request);
Expand All @@ -39,7 +39,7 @@ contract FastBridgeV2DstBaseTest is FastBridgeV2Test {
address caller,
address relayer,
uint256 msgValue,
IFastBridge.BridgeTransaction memory bridgeTx
IFastBridgeV2.BridgeTransactionV2 memory bridgeTx
)
public
{
Expand Down
20 changes: 10 additions & 10 deletions packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.PFees.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ contract FastBridgeV2GasBenchmarkSrcProtocolFeesTest is FastBridgeV2GasBenchmark

function createFixtures() public virtual override {
super.createFixtures();
tokenTx.originFeeAmount = 0.01e6;
tokenTx.originAmount = 0.99e6;
tokenTx.destAmount = 0.98e6;
tokenTx.txV1.originFeeAmount = 0.01e6;
tokenTx.txV1.originAmount = 0.99e6;
tokenTx.txV1.destAmount = 0.98e6;
tokenParams.destAmount = 0.98e6;
ethTx.originFeeAmount = 0.01 ether;
ethTx.originAmount = 0.99 ether;
ethTx.destAmount = 0.98 ether;
ethTx.txV1.originFeeAmount = 0.01 ether;
ethTx.txV1.originAmount = 0.99 ether;
ethTx.txV1.destAmount = 0.98 ether;
ethParams.destAmount = 0.98 ether;

// Copy txs to bridged and proven with different nonce
Expand All @@ -28,9 +28,9 @@ contract FastBridgeV2GasBenchmarkSrcProtocolFeesTest is FastBridgeV2GasBenchmark
bridgedEthTx = ethTx;
provenEthTx = ethTx;

bridgedTokenTx.nonce = 0;
bridgedEthTx.nonce = 1;
provenTokenTx.nonce = 2;
provenEthTx.nonce = 3;
bridgedTokenTx.txV1.nonce = 0;
bridgedEthTx.txV1.nonce = 1;
provenTokenTx.txV1.nonce = 2;
provenEthTx.txV1.nonce = 3;
}
}
38 changes: 19 additions & 19 deletions packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {FastBridgeV2, FastBridgeV2SrcBaseTest, IFastBridge} from "./FastBridgeV2.Src.Base.t.sol";
import {FastBridgeV2, FastBridgeV2SrcBaseTest, IFastBridgeV2} from "./FastBridgeV2.Src.Base.t.sol";

// solhint-disable func-name-mixedcase, ordering
/// @notice This test is used to estimate the gas cost of FastBridgeV2 source chain functions.
Expand All @@ -10,11 +10,11 @@ contract FastBridgeV2GasBenchmarkSrcTest is FastBridgeV2SrcBaseTest {
uint256 public constant BLOCK_TIME = 12 seconds;
uint256 public constant INITIAL_RELAYER_BALANCE = 100 ether;

IFastBridge.BridgeTransaction public bridgedTokenTx;
IFastBridge.BridgeTransaction public bridgedEthTx;
IFastBridgeV2.BridgeTransactionV2 public bridgedTokenTx;
IFastBridgeV2.BridgeTransactionV2 public bridgedEthTx;

IFastBridge.BridgeTransaction public provenTokenTx;
IFastBridge.BridgeTransaction public provenEthTx;
IFastBridgeV2.BridgeTransactionV2 public provenTokenTx;
IFastBridgeV2.BridgeTransactionV2 public provenEthTx;

uint256 public initialUserBalanceToken;
uint256 public initialUserBalanceEth;
Expand All @@ -37,13 +37,13 @@ contract FastBridgeV2GasBenchmarkSrcTest is FastBridgeV2SrcBaseTest {
bridgedEthTx = ethTx;
provenEthTx = ethTx;

bridgedTokenTx.nonce = 0;
bridgedEthTx.nonce = 1;
provenTokenTx.nonce = 2;
provenEthTx.nonce = 3;
bridgedTokenTx.txV1.nonce = 0;
bridgedEthTx.txV1.nonce = 1;
provenTokenTx.txV1.nonce = 2;
provenEthTx.txV1.nonce = 3;
// Next nonce for userA tx would be 4 (either token or eth)
tokenTx.nonce = 4;
ethTx.nonce = 4;
tokenTx.txV1.nonce = 4;
ethTx.txV1.nonce = 4;
}

function mintTokens() public virtual override {
Expand Down Expand Up @@ -114,16 +114,16 @@ contract FastBridgeV2GasBenchmarkSrcTest is FastBridgeV2SrcBaseTest {
skipTimeAtLeast({time: CLAIM_DELAY + 1});
claim({caller: relayerA, bridgeTx: provenTokenTx});
assertEq(fastBridge.bridgeStatuses(getTxId(provenTokenTx)), FastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(srcToken.balanceOf(relayerA), INITIAL_RELAYER_BALANCE + tokenTx.originAmount);
assertEq(srcToken.balanceOf(address(fastBridge)), initialFastBridgeBalanceToken - tokenTx.originAmount);
assertEq(srcToken.balanceOf(relayerA), INITIAL_RELAYER_BALANCE + tokenTx.txV1.originAmount);
assertEq(srcToken.balanceOf(address(fastBridge)), initialFastBridgeBalanceToken - tokenTx.txV1.originAmount);
}

function test_claimWithAddress_token() public {
skipTimeAtLeast({time: CLAIM_DELAY + 1});
claim({caller: relayerA, bridgeTx: provenTokenTx, to: relayerB});
assertEq(fastBridge.bridgeStatuses(getTxId(provenTokenTx)), FastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(srcToken.balanceOf(relayerB), INITIAL_RELAYER_BALANCE + tokenTx.originAmount);
assertEq(srcToken.balanceOf(address(fastBridge)), initialFastBridgeBalanceToken - tokenTx.originAmount);
assertEq(srcToken.balanceOf(relayerB), INITIAL_RELAYER_BALANCE + tokenTx.txV1.originAmount);
assertEq(srcToken.balanceOf(address(fastBridge)), initialFastBridgeBalanceToken - tokenTx.txV1.originAmount);
}

function test_dispute_token() public {
Expand Down Expand Up @@ -184,16 +184,16 @@ contract FastBridgeV2GasBenchmarkSrcTest is FastBridgeV2SrcBaseTest {
skipTimeAtLeast({time: CLAIM_DELAY + 1});
claim({caller: relayerA, bridgeTx: provenEthTx});
assertEq(fastBridge.bridgeStatuses(getTxId(provenEthTx)), FastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(relayerA.balance, INITIAL_RELAYER_BALANCE + ethTx.originAmount);
assertEq(address(fastBridge).balance, initialFastBridgeBalanceEth - ethTx.originAmount);
assertEq(relayerA.balance, INITIAL_RELAYER_BALANCE + ethTx.txV1.originAmount);
assertEq(address(fastBridge).balance, initialFastBridgeBalanceEth - ethTx.txV1.originAmount);
}

function test_claimWithAddress_eth() public {
skipTimeAtLeast({time: CLAIM_DELAY + 1});
claim({caller: relayerA, bridgeTx: provenEthTx, to: relayerB});
assertEq(fastBridge.bridgeStatuses(getTxId(provenEthTx)), FastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(relayerB.balance, INITIAL_RELAYER_BALANCE + ethTx.originAmount);
assertEq(address(fastBridge).balance, initialFastBridgeBalanceEth - ethTx.originAmount);
assertEq(relayerB.balance, INITIAL_RELAYER_BALANCE + ethTx.txV1.originAmount);
assertEq(address(fastBridge).balance, initialFastBridgeBalanceEth - ethTx.txV1.originAmount);
}

function test_dispute_eth() public {
Expand Down
12 changes: 6 additions & 6 deletions packages/contracts-rfq/test/FastBridgeV2.Src.Base.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {FastBridgeV2, FastBridgeV2Test, IFastBridge} from "./FastBridgeV2.t.sol";
import {FastBridgeV2, FastBridgeV2Test, IFastBridge, IFastBridgeV2} from "./FastBridgeV2.t.sol";

// solhint-disable func-name-mixedcase, ordering
abstract contract FastBridgeV2SrcBaseTest is FastBridgeV2Test {
Expand Down Expand Up @@ -48,7 +48,7 @@ abstract contract FastBridgeV2SrcBaseTest is FastBridgeV2Test {

// ══════════════════════════════════════════════════ HELPERS ══════════════════════════════════════════════════════

function bridge(address caller, uint256 msgValue, IFastBridge.BridgeParams memory params) public {
function bridge(address caller, uint256 msgValue, IFastBridge.BridgeParams memory params) public virtual {
vm.prank({msgSender: caller, txOrigin: caller});
fastBridge.bridge{value: msgValue}(params);
}
Expand All @@ -58,17 +58,17 @@ abstract contract FastBridgeV2SrcBaseTest is FastBridgeV2Test {
fastBridge.prove(transactionId, destTxHash, relayer);
}

function prove(address caller, IFastBridge.BridgeTransaction memory bridgeTx, bytes32 destTxHash) public {
function prove(address caller, IFastBridgeV2.BridgeTransactionV2 memory bridgeTx, bytes32 destTxHash) public {
vm.prank({msgSender: caller, txOrigin: caller});
fastBridge.prove(abi.encode(bridgeTx), destTxHash);
}

function claim(address caller, IFastBridge.BridgeTransaction memory bridgeTx) public {
function claim(address caller, IFastBridgeV2.BridgeTransactionV2 memory bridgeTx) public {
vm.prank({msgSender: caller, txOrigin: caller});
fastBridge.claim(abi.encode(bridgeTx));
}

function claim(address caller, IFastBridge.BridgeTransaction memory bridgeTx, address to) public {
function claim(address caller, IFastBridgeV2.BridgeTransactionV2 memory bridgeTx, address to) public {
vm.prank({msgSender: caller, txOrigin: caller});
fastBridge.claim(abi.encode(bridgeTx), to);
}
Expand All @@ -78,7 +78,7 @@ abstract contract FastBridgeV2SrcBaseTest is FastBridgeV2Test {
fastBridge.dispute(txId);
}

function refund(address caller, IFastBridge.BridgeTransaction memory bridgeTx) public {
function refund(address caller, IFastBridgeV2.BridgeTransactionV2 memory bridgeTx) public {
vm.prank({msgSender: caller, txOrigin: caller});
fastBridge.refund(abi.encode(bridgeTx));
}
Expand Down

0 comments on commit aaa5b2c

Please sign in to comment.