Skip to content

Commit

Permalink
add test_StalenessCheckDisabled_Success
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanRHall committed Oct 8, 2024
1 parent 2c38141 commit 76cc301
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion contracts/src/v0.8/ccip/test/feeQuoter/FeeQuoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -594,13 +594,41 @@ contract FeeQuoter_getTokenAndGasPrices is FeeQuoterSetup {
assertEq(gasPrice, priceUpdates.gasPriceUpdates[0].usdPerUnitGas);
}

function test_StalenessCheckDisabled_Success() public {
// this should have no affect! But we do it anyway to make sure the staleness check is disabled
vm.warp(block.timestamp + 52_000_000 weeks); // 1M-ish years

uint64 neverStaleChainSelector = 345678;
FeeQuoter.DestChainConfigArgs[] memory destChainConfigArgs = _generateFeeQuoterDestChainConfigArgs();
destChainConfigArgs[0].destChainSelector = neverStaleChainSelector;
destChainConfigArgs[0].destChainConfig.gasPriceStalenessThreshold = 0; // disables the staleness check

s_feeQuoter.applyDestChainConfigUpdates(destChainConfigArgs);

Internal.GasPriceUpdate[] memory gasPriceUpdates = new Internal.GasPriceUpdate[](1);
gasPriceUpdates[0] = Internal.GasPriceUpdate({destChainSelector: neverStaleChainSelector, usdPerUnitGas: 999});

Internal.PriceUpdates memory priceUpdates =
Internal.PriceUpdates({tokenPriceUpdates: new Internal.TokenPriceUpdate[](0), gasPriceUpdates: gasPriceUpdates});
s_feeQuoter.updatePrices(priceUpdates);

(, uint224 gasPrice) = s_feeQuoter.getTokenAndGasPrices(s_sourceFeeToken, neverStaleChainSelector);

assertEq(gasPrice, 999);
}

function test_ZeroGasPrice_Success() public {
uint64 zeroGasDestChainSelector = 345678;
FeeQuoter.DestChainConfigArgs[] memory destChainConfigArgs = _generateFeeQuoterDestChainConfigArgs();
destChainConfigArgs[0].destChainSelector = zeroGasDestChainSelector;
destChainConfigArgs[0].destChainConfig.gasPriceStalenessThreshold = 0;

s_feeQuoter.applyDestChainConfigUpdates(destChainConfigArgs);
Internal.GasPriceUpdate[] memory gasPriceUpdates = new Internal.GasPriceUpdate[](1);
gasPriceUpdates[0] = Internal.GasPriceUpdate({destChainSelector: zeroGasDestChainSelector, usdPerUnitGas: 0});

Internal.PriceUpdates memory priceUpdates =
Internal.PriceUpdates({tokenPriceUpdates: new Internal.TokenPriceUpdate[](0), gasPriceUpdates: gasPriceUpdates});
s_feeQuoter.updatePrices(priceUpdates);

(, uint224 gasPrice) = s_feeQuoter.getTokenAndGasPrices(s_sourceFeeToken, zeroGasDestChainSelector);

Expand Down

0 comments on commit 76cc301

Please sign in to comment.