Skip to content

Commit

Permalink
test: add gas bench for canClaim
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Oct 3, 2024
1 parent a602e42 commit 0145376
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/contracts-rfq/test/FastBridgeV2.GasBench.Src.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,21 @@ contract FastBridgeV2GasBenchmarkSrcTest is FastBridgeV2SrcBaseTest {
}

function test_claim_token() public {
bytes32 txId = getTxId(provenTokenTx);
skipTimeAtLeast({time: CLAIM_DELAY + 1});
assertTrue(fastBridge.canClaim(txId, relayerA));
claim({caller: relayerA, bridgeTx: provenTokenTx});
assertEq(fastBridge.bridgeStatuses(getTxId(provenTokenTx)), IFastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(fastBridge.bridgeStatuses(txId), IFastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(srcToken.balanceOf(relayerA), INITIAL_RELAYER_BALANCE + tokenTx.originAmount);
assertEq(srcToken.balanceOf(address(fastBridge)), initialFastBridgeBalanceToken - tokenTx.originAmount);
}

function test_claimWithAddress_token() public {
bytes32 txId = getTxId(provenTokenTx);
skipTimeAtLeast({time: CLAIM_DELAY + 1});
assertTrue(fastBridge.canClaim(txId, relayerA));
claim({caller: relayerA, bridgeTx: provenTokenTx, to: relayerB});
assertEq(fastBridge.bridgeStatuses(getTxId(provenTokenTx)), IFastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(fastBridge.bridgeStatuses(txId), IFastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(srcToken.balanceOf(relayerB), INITIAL_RELAYER_BALANCE + tokenTx.originAmount);
assertEq(srcToken.balanceOf(address(fastBridge)), initialFastBridgeBalanceToken - tokenTx.originAmount);
}
Expand Down Expand Up @@ -217,17 +221,21 @@ contract FastBridgeV2GasBenchmarkSrcTest is FastBridgeV2SrcBaseTest {
}

function test_claim_eth() public {
bytes32 txId = getTxId(provenEthTx);
skipTimeAtLeast({time: CLAIM_DELAY + 1});
assertTrue(fastBridge.canClaim(txId, relayerA));
claim({caller: relayerA, bridgeTx: provenEthTx});
assertEq(fastBridge.bridgeStatuses(getTxId(provenEthTx)), IFastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(fastBridge.bridgeStatuses(txId), IFastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(relayerA.balance, INITIAL_RELAYER_BALANCE + ethTx.originAmount);
assertEq(address(fastBridge).balance, initialFastBridgeBalanceEth - ethTx.originAmount);
}

function test_claimWithAddress_eth() public {
bytes32 txId = getTxId(provenEthTx);
skipTimeAtLeast({time: CLAIM_DELAY + 1});
assertTrue(fastBridge.canClaim(txId, relayerA));
claim({caller: relayerA, bridgeTx: provenEthTx, to: relayerB});
assertEq(fastBridge.bridgeStatuses(getTxId(provenEthTx)), IFastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(fastBridge.bridgeStatuses(txId), IFastBridgeV2.BridgeStatus.RELAYER_CLAIMED);
assertEq(relayerB.balance, INITIAL_RELAYER_BALANCE + ethTx.originAmount);
assertEq(address(fastBridge).balance, initialFastBridgeBalanceEth - ethTx.originAmount);
}
Expand Down

0 comments on commit 0145376

Please sign in to comment.