diff --git a/contracts/src/v0.8/llo-feeds/test/fee-manager/BaseFeeManager.t.sol b/contracts/src/v0.8/llo-feeds/test/fee-manager/BaseFeeManager.t.sol index bcc5aa7031a..a0d38cc9943 100644 --- a/contracts/src/v0.8/llo-feeds/test/fee-manager/BaseFeeManager.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/fee-manager/BaseFeeManager.t.sol @@ -98,8 +98,8 @@ contract BaseFeeManagerTest is Test { native = new WERC20Mock(); feeManagerProxy = new FeeManagerProxy(); - rewardManager = new RewardManager(getLinkAddress()); - feeManager = new FeeManager(getLinkAddress(), getNativeAddress(), address(feeManagerProxy), address(rewardManager)); + rewardManager = new RewardManager(address(link)); + feeManager = new FeeManager(address(link), address(native), address(feeManagerProxy), address(rewardManager)); //link the feeManager to the proxy feeManagerProxy.setFeeManager(feeManager); @@ -156,7 +156,7 @@ contract BaseFeeManagerTest is Test { // solium-disable-next-line no-unused-vars function getFee( bytes memory report, - IFeeManager.Quote memory quote, + address quote, address subscriber ) public view returns (Common.Asset memory) { //get the fee @@ -167,7 +167,7 @@ contract BaseFeeManagerTest is Test { function getReward( bytes memory report, - IFeeManager.Quote memory quote, + address quote, address subscriber ) public view returns (Common.Asset memory) { //get the reward @@ -178,7 +178,7 @@ contract BaseFeeManagerTest is Test { function getAppliedDiscount( bytes memory report, - IFeeManager.Quote memory quote, + address quote, address subscriber ) public view returns (uint256) { //get the reward @@ -239,12 +239,12 @@ contract BaseFeeManagerTest is Test { ); } - function getLinkQuote() public view returns (IFeeManager.Quote memory) { - return IFeeManager.Quote(getLinkAddress()); + function getLinkQuote() public view returns (address) { + return address(link); } - function getNativeQuote() public view returns (IFeeManager.Quote memory) { - return IFeeManager.Quote(getNativeAddress()); + function getNativeQuote() public view returns (address) { + return address(native); } function withdraw(address assetAddress, address recipient, uint256 amount, address sender) public { @@ -302,6 +302,7 @@ contract BaseFeeManagerTest is Test { function ProcessFeeAsUser( bytes memory payload, address subscriber, + address tokenAddress, uint256 wrappedNativeValue, address sender ) public { @@ -310,52 +311,47 @@ contract BaseFeeManagerTest is Test { changePrank(sender); //process the fee - feeManager.processFee{value: wrappedNativeValue}(payload, subscriber); + feeManager.processFee{value: wrappedNativeValue}(payload, abi.encode(tokenAddress), subscriber); //change ProcessFeeAsUserback to the original address changePrank(originalAddr); } - function processFee(bytes memory payload, address subscriber, uint256 wrappedNativeValue) public { + function processFee(bytes memory payload, address subscriber, address feeAddress, uint256 wrappedNativeValue) public { //record the current address and switch to the recipient address originalAddr = msg.sender; changePrank(subscriber); //process the fee - feeManagerProxy.processFee{value: wrappedNativeValue}(payload); + feeManagerProxy.processFee{value: wrappedNativeValue}(payload, abi.encode(feeAddress)); //change back to the original address changePrank(originalAddr); } - function processFee(bytes[] memory payloads, address subscriber, uint256 wrappedNativeValue) public { + function processFee(bytes[] memory payloads, address subscriber, address feeAddress, uint256 wrappedNativeValue) public { //record the current address and switch to the recipient address originalAddr = msg.sender; changePrank(subscriber); //process the fee - feeManagerProxy.processFeeBulk{value: wrappedNativeValue}(payloads); + feeManagerProxy.processFeeBulk{value: wrappedNativeValue}(payloads, abi.encode(feeAddress)); //change back to the original address changePrank(originalAddr); } - function getPayload(bytes memory reportPayload, bytes memory quotePayload) public pure returns (bytes memory) { + function getPayload(bytes memory reportPayload) public pure returns (bytes memory) { return abi.encode( [DEFAULT_CONFIG_DIGEST, 0, 0], reportPayload, new bytes32[](1), new bytes32[](1), - bytes32(""), - quotePayload + bytes32("") ); } - function getQuotePayload(address quoteAddress) public pure returns (bytes memory) { - return abi.encode(quoteAddress); - } - function approveLink(address spender, uint256 quantity, address sender) public { //record the current address and switch to the recipient address originalAddr = msg.sender; @@ -380,14 +376,6 @@ contract BaseFeeManagerTest is Test { changePrank(originalAddr); } - function getLinkAddress() public view returns (address) { - return address(link); - } - - function getNativeAddress() public view returns (address) { - return address(native); - } - function payLinkDeficit(bytes32 configDigest, address sender) public { //record the current address and switch to the recipient address originalAddr = msg.sender; diff --git a/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.general.t.sol b/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.general.t.sol index d776c54eb36..5277f3b6873 100644 --- a/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.general.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.general.t.sol @@ -28,7 +28,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { uint256 withdrawAmount = contractBalance / 2; //withdraw some balance - withdraw(getLinkAddress(), ADMIN, withdrawAmount, ADMIN); + withdraw(address(link), ADMIN, withdrawAmount, ADMIN); //check the balance has been reduced uint256 newContractBalance = getLinkBalance(address(feeManager)); @@ -76,7 +76,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { vm.expectRevert(ONLY_CALLABLE_BY_OWNER_ERROR); //withdraw some balance - withdraw(getLinkAddress(), ADMIN, DEFAULT_LINK_MINT_QUANTITY, USER); + withdraw(address(link), ADMIN, DEFAULT_LINK_MINT_QUANTITY, USER); } function test_eventIsEmittedAfterSurchargeIsSet() public { @@ -101,10 +101,10 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { vm.expectEmit(); //emit the event that is expected to be emitted - emit SubscriberDiscountUpdated(USER, DEFAULT_FEED_1_V3, getNativeAddress(), discount); + emit SubscriberDiscountUpdated(USER, DEFAULT_FEED_1_V3, address(native), discount); //set the surcharge - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), discount, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), discount, ADMIN); } function test_eventIsEmittedUponWithdraw() public { @@ -118,10 +118,10 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { vm.expectEmit(); //the event to be emitted - emit Withdraw(ADMIN, ADMIN, getLinkAddress(), withdrawAmount); + emit Withdraw(ADMIN, ADMIN, address(link), withdrawAmount); //withdraw some balance - withdraw(getLinkAddress(), ADMIN, withdrawAmount, ADMIN); + withdraw(address(link), ADMIN, withdrawAmount, ADMIN); } function test_linkAvailableForPaymentReturnsLinkBalance() public { @@ -137,7 +137,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_payLinkDeficit() public { //get the default payload - bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V3)); approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); @@ -150,7 +150,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { emit InsufficientLink(contractFees); //process the fee - processFee(payload, USER, 0); + processFee(payload, USER, address(native), 0); //double check the rewardManager balance is 0 assertEq(getLinkBalance(address(rewardManager)), 0); @@ -170,7 +170,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_payLinkDeficitTwice() public { //get the default payload - bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V3)); approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); @@ -184,7 +184,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { emit InsufficientLink(contractFees); //process the fee - processFee(payload, USER, 0); + processFee(payload, USER, address(native), 0); //double check the rewardManager balance is 0 assertEq(getLinkBalance(address(rewardManager)), 0); @@ -209,14 +209,14 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_payLinkDeficitPaysAllFeesProcessed() public { //get the default payload - bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V3)); //approve the native to be transferred from the user approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE * 2, USER); //processing the fee will transfer the native from the user to the feeManager - processFee(payload, USER, 0); - processFee(payload, USER, 0); + processFee(payload, USER, address(native), 0); + processFee(payload, USER, address(native), 0); //check the deficit has been increased twice assertEq(getLinkDeficit(DEFAULT_CONFIG_DIGEST), DEFAULT_REPORT_LINK_FEE * 2); diff --git a/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.getFeeAndReward.t.sol b/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.getFeeAndReward.t.sol index f31c06bd41e..03b8da04046 100644 --- a/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.getFeeAndReward.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.getFeeAndReward.t.sol @@ -31,7 +31,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_discountAIsNotAppliedWhenSetForOtherUsers() public { //set the subscriber discount for another user - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), INVALID_ADDRESS); @@ -50,7 +50,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_discountIsAppliedForLink() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); @@ -61,7 +61,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_DiscountIsAppliedForNative() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -72,7 +72,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_discountIsNoLongerAppliedAfterRemoving() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); @@ -81,7 +81,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { assertEq(fee.amount, DEFAULT_REPORT_LINK_FEE / 2); //remove the discount - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), 0, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), 0, ADMIN); //get the fee required by the feeManager fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); @@ -181,7 +181,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { uint256 nativeSurcharge = FEE_SCALAR / 5; //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //set the surcharge setNativeSurcharge(nativeSurcharge, ADMIN); @@ -204,7 +204,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { vm.expectRevert(INVALID_QUOTE_ERROR); //get the fee required by the feeManager - getFee(getV3Report(DEFAULT_FEED_1_V3), IFeeManager.Quote(address(0)), USER); + getFee(getV3Report(DEFAULT_FEED_1_V3), address(0), USER); } function test_nativeSurcharge100Percent() public { @@ -239,7 +239,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_discountIsAppliedWith100PercentSurcharge() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //set the surcharge setNativeSurcharge(FEE_SCALAR, ADMIN); @@ -256,7 +256,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_feeIsZeroWith100PercentDiscount() public { //set the subscriber discount to 100% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -267,7 +267,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_feeIsUpdatedAfterDiscountIsRemoved() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -279,7 +279,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { assertEq(fee.amount, DEFAULT_REPORT_NATIVE_FEE - expectedDiscount); //remove the discount - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), 0, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), 0, ADMIN); //get the fee required by the feeManager fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -290,7 +290,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_feeIsUpdatedAfterNewDiscountIsApplied() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -302,7 +302,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { assertEq(fee.amount, DEFAULT_REPORT_NATIVE_FEE - expectedDiscount); //change the discount to 25% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 4, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 4, ADMIN); //get the fee required by the feeManager fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -319,7 +319,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { vm.expectRevert(INVALID_DISCOUNT_ERROR); //set the subscriber discount to over 100% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR + 1, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR + 1, ADMIN); } function test_surchargeIsNotAppliedWith100PercentDiscount() public { @@ -327,7 +327,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { uint256 nativeSurcharge = FEE_SCALAR / 5; //set the subscriber discount to 100% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR, ADMIN); //set the surcharge setNativeSurcharge(nativeSurcharge, ADMIN); @@ -344,7 +344,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { vm.expectRevert(ONLY_CALLABLE_BY_OWNER_ERROR); //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR, USER); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR, USER); } function test_surchargeFeeRoundsUpWhenUneven() public { @@ -369,7 +369,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { uint256 discount = FEE_SCALAR / 3; //set the subscriber discount to 33.333% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), discount, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), discount, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -391,8 +391,8 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_correctDiscountIsAppliedWhenBothTokensAreDiscounted() public { //set the subscriber and native discounts - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 4, ADMIN); - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 4, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager for both tokens Common.Asset memory linkFee = getFee(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); @@ -409,7 +409,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_discountIsNotAppliedToOtherFeeds() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_2_V3), getNativeQuote(), USER); @@ -420,7 +420,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_noFeeIsAppliedWhenReportHasZeroFee() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee( @@ -435,7 +435,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_noFeeIsAppliedWhenReportHasZeroFeeAndDiscountAndSurchargeIsSet() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //set the surcharge setNativeSurcharge(FEE_SCALAR / 2, ADMIN); @@ -475,7 +475,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_getRewardWithLinkQuoteAndLinkDiscount() public { //set the link discount - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory reward = getReward(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); @@ -505,7 +505,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_getRewardWithLinkDiscount() public { //set the link discount - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 2, ADMIN); //get the fee required by the feeManager Common.Asset memory reward = getReward(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); @@ -516,7 +516,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_getLinkFeeIsRoundedUp() public { //set the link discount - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 3, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 3, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); @@ -527,14 +527,14 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_getLinkRewardIsSameAsFee() public { //set the link discount - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 3, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 3, ADMIN); //get the fee required by the feeManager Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); Common.Asset memory reward = getReward(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); //check the reward is in link - assertEq(fee.assetAddress, getLinkAddress()); + assertEq(fee.assetAddress, address(link)); //the reward should equal .66% of the base fee due to a 33% discount rounded down assertEq(reward.amount, fee.amount); @@ -545,7 +545,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { setNativeSurcharge(FEE_SCALAR / 2, ADMIN); //set the link discount - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 3, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 3, ADMIN); //get the fee required by the feeManager Common.Asset memory reward = getReward(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -573,7 +573,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_discountIsReturnedForLink() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getLinkAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(link), FEE_SCALAR / 2, ADMIN); //get the fee applied uint256 discount = getAppliedDiscount(getV3Report(DEFAULT_FEED_1_V3), getLinkQuote(), USER); @@ -584,7 +584,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_DiscountIsReturnedForNative() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //get the discount applied uint256 discount = getAppliedDiscount(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -595,7 +595,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_DiscountIsReturnedForNativeWithSurcharge() public { //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //set the surcharge setNativeSurcharge(FEE_SCALAR / 5, ADMIN); diff --git a/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.processFee.t.sol b/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.processFee.t.sol index aa0ca063d85..6522cc15a8d 100644 --- a/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.processFee.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.processFee.t.sol @@ -19,24 +19,24 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_nonAdminProxyUserCannotProcessFee() public { //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //should revert as the user is not the owner vm.expectRevert(UNAUTHORIZED_ERROR); //process the fee - ProcessFeeAsUser(payload, USER, 0, USER); + ProcessFeeAsUser(payload, USER, address(link), 0, USER); } function test_processFeeAsProxy() public { //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //approve the link to be transferred from the from the subscriber to the rewardManager approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, USER); //processing the fee will transfer the link from the user to the rewardManager - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); //check the link has been transferred assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE); @@ -47,35 +47,35 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_processFeeIfSubscriberIsSelf() public { //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //expect a revert due to the feeManager being the subscriber vm.expectRevert(INVALID_ADDRESS_ERROR); //process the fee will fail due to assertion - processFee(payload, address(feeManager), 0); + processFee(payload, address(feeManager), address(native), 0); } function test_processFeeWithWithEmptyQuotePayload() public { //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), bytes("")); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //expect a revert as the quote is invalid vm.expectRevert(); //processing the fee will transfer the link by default - processFee(payload, USER, 0); + processFee(payload, USER, address(0), 0); } function test_processFeeWithWithZeroQuotePayload() public { //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(INVALID_ADDRESS)); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //expect a revert as the quote is invalid vm.expectRevert(INVALID_QUOTE_ERROR); //processing the fee will transfer the link by default - processFee(payload, USER, 0); + processFee(payload, USER, INVALID_ADDRESS, 0); } function test_processFeeWithWithCorruptQuotePayload() public { @@ -92,23 +92,23 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { vm.expectRevert(); //processing the fee will not withdraw anything as there is no fee to collect - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); } function test_processFeeDefaultReportsStillVerifiesWithEmptyQuote() public { //get the default payload - bytes memory payload = getPayload(getV1Report(DEFAULT_FEED_1_V1), bytes("")); + bytes memory payload = getPayload(getV1Report(DEFAULT_FEED_1_V1)); //processing the fee will transfer the link from the user to the rewardManager - processFee(payload, USER, 0); + processFee(payload, USER, address(0), 0); } function test_processFeeWithDefaultReportPayloadAndQuoteStillVerifies() public { //get the default payload - bytes memory payload = getPayload(getV1Report(DEFAULT_FEED_1_V1), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV1Report(DEFAULT_FEED_1_V1)); //processing the fee will not withdraw anything as there is no fee to collect - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); } function test_processFeeNative() public { @@ -116,13 +116,13 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //approve the native to be transferred from the user approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); //processing the fee will transfer the native from the user to the feeManager - processFee(payload, USER, 0); + processFee(payload, USER, address(native), 0); //check the native has been transferred assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE); @@ -142,7 +142,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE / 2); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //approve the native to be transferred from the user approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); @@ -157,7 +157,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { emit InsufficientLink(contractFees); //processing the fee will transfer the native from the user to the feeManager - processFee(payload, USER, 0); + processFee(payload, USER, address(native), 0); //check the native has been transferred assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE); @@ -175,10 +175,10 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //only the proxy or admin can call processFee, they will pass in the native value on the users behalf - processFee(payload, USER, DEFAULT_REPORT_NATIVE_FEE); + processFee(payload, USER, address(native), DEFAULT_REPORT_NATIVE_FEE); //check the native has been transferred and converted to wrapped native assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE); @@ -199,13 +199,13 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //expect a revert as not enough funds vm.expectRevert(INVALID_DEPOSIT_ERROR); //only the proxy or admin can call processFee, they will pass in the native value on the users behalf - processFee(payload, USER, DEFAULT_REPORT_NATIVE_FEE - 1); + processFee(payload, USER, address(native), DEFAULT_REPORT_NATIVE_FEE - 1); } function test_processFeeWithUnwrappedNativeLinkAddress() public { @@ -213,13 +213,13 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //expect a revert as not enough funds vm.expectRevert(INSUFFICIENT_ALLOWANCE_ERROR); //the change will be returned and the user will attempted to be billed in LINK - processFee(payload, USER, DEFAULT_REPORT_NATIVE_FEE - 1); + processFee(payload, USER, address(link), DEFAULT_REPORT_NATIVE_FEE - 1); } function test_processFeeWithUnwrappedNativeLinkAddressExcessiveFee() public { @@ -227,10 +227,10 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, PROXY); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //call processFee from the proxy to test whether the funds are returned to the subscriber. In reality, the funds would be returned to the caller of the proxy. - processFee(payload, PROXY, DEFAULT_REPORT_NATIVE_FEE); + processFee(payload, PROXY, address(link), DEFAULT_REPORT_NATIVE_FEE); //check the native unwrapped is no longer in the account assertEq(getNativeBalance(address(feeManager)), 0); @@ -251,10 +251,10 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //call processFee from the proxy to test whether the funds are returned to the subscriber. In reality, the funds would be returned to the caller of the proxy. - processFee(payload, PROXY, DEFAULT_REPORT_NATIVE_FEE * 2); + processFee(payload, PROXY, address(native), DEFAULT_REPORT_NATIVE_FEE * 2); //check the native has been transferred and converted to wrapped native assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE); @@ -272,13 +272,13 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_processFeeUsesCorrectDigest() public { //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //approve the link to be transferred from the from the subscriber to the rewardManager approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, USER); //processing the fee will transfer the link from the user to the rewardManager - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); //check the link has been transferred assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE); @@ -301,18 +301,18 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { ); //processing the fee will transfer the link from the user to the rewardManager - processFee(payload, USER, 0); + processFee(payload, USER, address(0), 0); } function test_V2PayloadVerifies() public { //get the default payload - bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V2), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V2)); //approve the link to be transferred from the from the subscriber to the rewardManager approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, USER); //processing the fee will transfer the link from the user to the rewardManager - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); //check the link has been transferred assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE); @@ -323,62 +323,60 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_V2PayloadWithoutQuoteFails() public { //get the default payload - bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V2), bytes("")); + bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V2)); //expect a revert as the quote is invalid vm.expectRevert(); //processing the fee will transfer the link from the user to the rewardManager - processFee(payload, USER, 0); + processFee(payload, USER, address(0), 0); } function test_V2PayloadWithoutZeroFee() public { //get the default payload - bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V2), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV2Report(DEFAULT_FEED_1_V2)); //expect a revert as the quote is invalid vm.expectRevert(); //processing the fee will transfer the link from the user to the rewardManager - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); } function test_processFeeWithInvalidReportVersionFailsToDecode() public { bytes memory data = abi.encode(0x0000100000000000000000000000000000000000000000000000000000000000); //get the default payload - bytes memory payload = getPayload(data, getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(data); //serialization will fail as there is no report to decode vm.expectRevert(); //processing the fee will not withdraw anything as there is no fee to collect - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); } function test_processFeeWithZeroNativeNonZeroLinkWithNativeQuote() public { //get the default payload bytes memory payload = getPayload( - getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, DEFAULT_REPORT_LINK_FEE, 0), - getQuotePayload(getNativeAddress()) + getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, DEFAULT_REPORT_LINK_FEE, 0) ); //call processFee should not revert as the fee is 0 - processFee(payload, PROXY, 0); + processFee(payload, PROXY, address(native), 0); } function test_processFeeWithZeroNativeNonZeroLinkWithLinkQuote() public { //get the default payload bytes memory payload = getPayload( - getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, DEFAULT_REPORT_LINK_FEE, 0), - getQuotePayload(getLinkAddress()) + getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, DEFAULT_REPORT_LINK_FEE, 0) ); //approve the link to be transferred from the from the subscriber to the rewardManager approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, USER); //processing the fee will transfer the link to the rewardManager from the user - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); //check the link has been transferred assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE); @@ -393,15 +391,14 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { //get the default payload bytes memory payload = getPayload( - getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, 0, DEFAULT_REPORT_NATIVE_FEE), - getQuotePayload(getNativeAddress()) + getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, 0, DEFAULT_REPORT_NATIVE_FEE) ); //approve the native to be transferred from the user approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); //processing the fee will transfer the native from the user to the feeManager - processFee(payload, USER, 0); + processFee(payload, USER, address(native), 0); //check the native has been transferred assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE); @@ -419,23 +416,21 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_processFeeWithZeroLinkNonZeroNativeWithLinkQuote() public { //get the default payload bytes memory payload = getPayload( - getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, 0, DEFAULT_REPORT_NATIVE_FEE), - getQuotePayload(getLinkAddress()) + getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, 0, DEFAULT_REPORT_NATIVE_FEE) ); //call processFee should not revert as the fee is 0 - processFee(payload, USER, 0); + processFee(payload, USER, address(link), 0); } function test_processFeeWithZeroNativeNonZeroLinkReturnsChange() public { //get the default payload bytes memory payload = getPayload( - getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, 0, DEFAULT_REPORT_NATIVE_FEE), - getQuotePayload(getLinkAddress()) + getV3ReportWithCustomExpiryAndFee(DEFAULT_FEED_1_V3, block.timestamp, 0, DEFAULT_REPORT_NATIVE_FEE) ); //call processFee should not revert as the fee is 0 - processFee(payload, USER, DEFAULT_REPORT_NATIVE_FEE); + processFee(payload, USER, address(link), DEFAULT_REPORT_NATIVE_FEE); //check the change has been returned assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY); @@ -443,10 +438,9 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_V1PayloadVerifiesAndReturnsChange() public { //emulate a V1 payload with no quote - bytes memory quotePayload; - bytes memory payload = getPayload(getV1Report(DEFAULT_FEED_1_V1), quotePayload); + bytes memory payload = getPayload(getV1Report(DEFAULT_FEED_1_V1)); - processFee(payload, USER, DEFAULT_REPORT_NATIVE_FEE); + processFee(payload, USER, address(0), DEFAULT_REPORT_NATIVE_FEE); //Fee manager should not contain any native assertEq(address(feeManager).balance, 0); @@ -461,13 +455,13 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE); //set the subscriber discount to 50% - setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, getNativeAddress(), FEE_SCALAR / 2, ADMIN); + setSubscriberDiscount(USER, DEFAULT_FEED_1_V3, address(native), FEE_SCALAR / 2, ADMIN); //approve the native to be transferred from the user approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE / 2, USER); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); Common.Asset memory fee = getFee(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); Common.Asset memory reward = getReward(getV3Report(DEFAULT_FEED_1_V3), getNativeQuote(), USER); @@ -478,7 +472,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { emit DiscountApplied(DEFAULT_CONFIG_DIGEST, USER, fee, reward, appliedDiscount); //call processFee should not revert as the fee is 0 - processFee(payload, USER, 0); + processFee(payload, USER, address(native), 0); } function test_processFeeWithNoDiscountDoesNotEmitEvent() public { @@ -489,10 +483,10 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); //get the default payload - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); //call processFee should not revert as the fee is 0 - processFee(payload, USER, 0); + processFee(payload, USER, address(native), 0); //no logs should have been emitted assertEq(vm.getRecordedLogs().length, 0); diff --git a/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.processFeeBulk.t.sol b/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.processFeeBulk.t.sol index ba415598b7c..d2df2548208 100644 --- a/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.processFeeBulk.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/fee-manager/FeeManager.processFeeBulk.t.sol @@ -20,7 +20,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { } function test_processMultipleLinkReports() public { - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); bytes[] memory payloads = new bytes[](NUMBER_OF_REPORTS); for (uint256 i = 0; i < NUMBER_OF_REPORTS; ++i) { @@ -29,7 +29,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * NUMBER_OF_REPORTS, USER); - processFee(payloads, USER, DEFAULT_NATIVE_MINT_QUANTITY); + processFee(payloads, USER, address(link), DEFAULT_NATIVE_MINT_QUANTITY); assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * NUMBER_OF_REPORTS); assertEq(getLinkBalance(address(feeManager)), 0); @@ -43,7 +43,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_processMultipleWrappedNativeReports() public { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE * NUMBER_OF_REPORTS + 1); - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); bytes[] memory payloads = new bytes[](NUMBER_OF_REPORTS); for (uint256 i; i < NUMBER_OF_REPORTS; ++i) { @@ -52,7 +52,7 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE * NUMBER_OF_REPORTS, USER); - processFee(payloads, USER, 0); + processFee(payloads, USER, address(native), 0); assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * NUMBER_OF_REPORTS); assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * NUMBER_OF_REPORTS); @@ -63,14 +63,14 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { function test_processMultipleUnwrappedNativeReports() public { mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE * NUMBER_OF_REPORTS + 1); - bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); + bytes memory payload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); bytes[] memory payloads = new bytes[](NUMBER_OF_REPORTS); for (uint256 i; i < NUMBER_OF_REPORTS; ++i) { payloads[i] = payload; } - processFee(payloads, USER, DEFAULT_REPORT_NATIVE_FEE * NUMBER_OF_REPORTS * 2); + processFee(payloads, USER, address(native), DEFAULT_REPORT_NATIVE_FEE * NUMBER_OF_REPORTS * 2); assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * NUMBER_OF_REPORTS); assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * NUMBER_OF_REPORTS); @@ -80,59 +80,8 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * NUMBER_OF_REPORTS); } - function test_processMultipleLinkAndNativeWrappedReports() public { - mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE * 2 + 1); - - bytes memory nativePayload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); - bytes memory linkPayload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); - - bytes[] memory payloads = new bytes[](5); - payloads[0] = linkPayload; - payloads[1] = linkPayload; - payloads[2] = linkPayload; - payloads[3] = nativePayload; - payloads[4] = nativePayload; - - approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE * 2, USER); - approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * 3, USER); - - processFee(payloads, USER, 0); - - assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * 5); - assertEq(getLinkBalance(address(feeManager)), 1); - assertEq(getNativeBalance(USER), DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(getLinkBalance(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * 3); - } - - function test_processMultipleLinkAndNativeUnwrappedReports() public { - mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE * 2 + 1); - - bytes memory nativePayload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); - bytes memory linkPayload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); - - bytes[] memory payloads = new bytes[](5); - payloads[0] = linkPayload; - payloads[1] = linkPayload; - payloads[2] = linkPayload; - payloads[3] = nativePayload; - payloads[4] = nativePayload; - - approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * 3, USER); - - processFee(payloads, USER, DEFAULT_REPORT_NATIVE_FEE * 4); - - assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * 5); - assertEq(getLinkBalance(address(feeManager)), 1); - - assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(PROXY.balance, DEFAULT_NATIVE_MINT_QUANTITY); - assertEq(getLinkBalance(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * 3); - } - function test_processV1V2V3Reports() public { - mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE * 2 + 1); + mintLink(address(feeManager), 1); bytes memory payloadV1 = abi.encode( [DEFAULT_CONFIG_DIGEST, 0, 0], @@ -142,34 +91,30 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { bytes32("") ); - bytes memory nativePayloadV2 = getPayload(getV2Report(DEFAULT_FEED_1_V2), getQuotePayload(getNativeAddress())); - bytes memory linkPayloadV2 = getPayload(getV2Report(DEFAULT_FEED_1_V2), getQuotePayload(getLinkAddress())); - - bytes memory nativePayloadV3 = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); - bytes memory linkPayloadV3 = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory linkPayloadV2 = getPayload(getV2Report(DEFAULT_FEED_1_V2)); + bytes memory linkPayloadV3 = getPayload(getV3Report(DEFAULT_FEED_1_V3)); bytes[] memory payloads = new bytes[](5); payloads[0] = payloadV1; - payloads[1] = nativePayloadV2; + payloads[1] = linkPayloadV2; payloads[2] = linkPayloadV2; - payloads[3] = nativePayloadV3; + payloads[3] = linkPayloadV3; payloads[4] = linkPayloadV3; - approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE * 2, USER); - approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * 2, USER); + approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * 4, USER); - processFee(payloads, USER, 0); + processFee(payloads, USER, address(link), 0); - assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * 2); + assertEq(getNativeBalance(address(feeManager)), 0); assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * 4); assertEq(getLinkBalance(address(feeManager)), 1); - assertEq(getLinkBalance(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * 2); - assertEq(getNativeBalance(USER), DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 2); + assertEq(getLinkBalance(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * 4); + assertEq(getNativeBalance(USER), DEFAULT_NATIVE_MINT_QUANTITY - 0); } function test_processV1V2V3ReportsWithUnwrapped() public { - mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE * 2 + 1); + mintLink(address(feeManager), DEFAULT_REPORT_LINK_FEE * 4 + 1); bytes memory payloadV1 = abi.encode( [DEFAULT_CONFIG_DIGEST, 0, 0], @@ -179,29 +124,23 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { bytes32("") ); - bytes memory nativePayloadV2 = getPayload(getV2Report(DEFAULT_FEED_1_V2), getQuotePayload(getNativeAddress())); - bytes memory linkPayloadV2 = getPayload(getV2Report(DEFAULT_FEED_1_V2), getQuotePayload(getLinkAddress())); - - bytes memory nativePayloadV3 = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); - bytes memory linkPayloadV3 = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory nativePayloadV2 = getPayload(getV2Report(DEFAULT_FEED_1_V2)); + bytes memory nativePayloadV3 = getPayload(getV3Report(DEFAULT_FEED_1_V3)); bytes[] memory payloads = new bytes[](5); payloads[0] = payloadV1; payloads[1] = nativePayloadV2; - payloads[2] = linkPayloadV2; + payloads[2] = nativePayloadV2; payloads[3] = nativePayloadV3; - payloads[4] = linkPayloadV3; - - approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * 2, USER); + payloads[4] = nativePayloadV3; - processFee(payloads, USER, DEFAULT_REPORT_NATIVE_FEE * 4); + processFee(payloads, USER, address(native), DEFAULT_REPORT_NATIVE_FEE * 4); - assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * 2); + assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * 4); assertEq(getLinkBalance(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * 4); assertEq(getLinkBalance(address(feeManager)), 1); - assertEq(getLinkBalance(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * 2); - assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 2); + assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 4); assertEq(PROXY.balance, DEFAULT_NATIVE_MINT_QUANTITY); } @@ -219,38 +158,39 @@ contract FeeManagerProcessFeeTest is BaseFeeManagerTest { payloads[i] = payload; } - processFee(payloads, USER, DEFAULT_REPORT_NATIVE_FEE * 5); + processFee(payloads, USER, address(native), DEFAULT_REPORT_NATIVE_FEE * 5); assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY); assertEq(PROXY.balance, DEFAULT_NATIVE_MINT_QUANTITY); } function test_eventIsEmittedIfNotEnoughLink() public { - bytes memory nativePayload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getNativeAddress())); - bytes memory linkPayload = getPayload(getV3Report(DEFAULT_FEED_1_V3), getQuotePayload(getLinkAddress())); + bytes memory nativePayload = getPayload(getV3Report(DEFAULT_FEED_1_V3)); bytes[] memory payloads = new bytes[](5); - payloads[0] = linkPayload; - payloads[1] = linkPayload; - payloads[2] = linkPayload; + payloads[0] = nativePayload; + payloads[1] = nativePayload; + payloads[2] = nativePayload; payloads[3] = nativePayload; payloads[4] = nativePayload; - approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE * 2, USER); - approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * 3, USER); + approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE * 5, USER); - IRewardManager.FeePayment[] memory payments = new IRewardManager.FeePayment[](2); + IRewardManager.FeePayment[] memory payments = new IRewardManager.FeePayment[](5); payments[0] = IRewardManager.FeePayment(DEFAULT_CONFIG_DIGEST, uint192(DEFAULT_REPORT_LINK_FEE)); payments[1] = IRewardManager.FeePayment(DEFAULT_CONFIG_DIGEST, uint192(DEFAULT_REPORT_LINK_FEE)); + payments[2] = IRewardManager.FeePayment(DEFAULT_CONFIG_DIGEST, uint192(DEFAULT_REPORT_LINK_FEE)); + payments[3] = IRewardManager.FeePayment(DEFAULT_CONFIG_DIGEST, uint192(DEFAULT_REPORT_LINK_FEE)); + payments[4] = IRewardManager.FeePayment(DEFAULT_CONFIG_DIGEST, uint192(DEFAULT_REPORT_LINK_FEE)); vm.expectEmit(); emit InsufficientLink(payments); - processFee(payloads, USER, 0); + processFee(payloads, USER, address(native), 0); - assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(getNativeBalance(USER), DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(getLinkBalance(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * 3); + assertEq(getNativeBalance(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * 5); + assertEq(getNativeBalance(USER), DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 5); + assertEq(getLinkBalance(USER), DEFAULT_LINK_MINT_QUANTITY); } } diff --git a/contracts/src/v0.8/llo-feeds/test/gas/Gas_VerifierTest.t.sol b/contracts/src/v0.8/llo-feeds/test/gas/Gas_VerifierTest.t.sol index d5c26fcd13e..9b10a2430f9 100644 --- a/contracts/src/v0.8/llo-feeds/test/gas/Gas_VerifierTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/gas/Gas_VerifierTest.t.sol @@ -69,25 +69,23 @@ contract Verifier_verifyWithFee is BaseTestWithConfiguredVerifierAndFeeManager { } function testVerifyProxyWithLinkFeeSuccess_gas() public { - bytes memory signedLinkPayload = _generateEncodedBlobWithQuote( + bytes memory signedLinkPayload = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(link)) + _getSigners(FAULT_TOLERANCE + 1) ); - s_verifierProxy.verify(signedLinkPayload); + s_verifierProxy.verify(signedLinkPayload, abi.encode(link)); } function testVerifyProxyWithNativeFeeSuccess_gas() public { - bytes memory signedNativePayload = _generateEncodedBlobWithQuote( + bytes memory signedNativePayload = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); - s_verifierProxy.verify(signedNativePayload); + s_verifierProxy.verify(signedNativePayload, abi.encode(native)); } } @@ -130,11 +128,10 @@ contract Verifier_bulkVerifyWithFee is BaseTestWithConfiguredVerifierAndFeeManag } function testBulkVerifyProxyWithLinkFeeSuccess_gas() public { - bytes memory signedLinkPayload = _generateEncodedBlobWithQuote( + bytes memory signedLinkPayload = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(link)) + _getSigners(FAULT_TOLERANCE + 1) ); bytes[] memory signedLinkPayloads = new bytes[](NUMBER_OF_REPORTS_TO_VERIFY); @@ -142,15 +139,14 @@ contract Verifier_bulkVerifyWithFee is BaseTestWithConfiguredVerifierAndFeeManag signedLinkPayloads[i] = signedLinkPayload; } - s_verifierProxy.verifyBulk(signedLinkPayloads); + s_verifierProxy.verifyBulk(signedLinkPayloads, abi.encode(link)); } function testBulkVerifyProxyWithNativeFeeSuccess_gas() public { - bytes memory signedNativePayload = _generateEncodedBlobWithQuote( + bytes memory signedNativePayload = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); bytes[] memory signedNativePayloads = new bytes[](NUMBER_OF_REPORTS_TO_VERIFY); @@ -158,7 +154,7 @@ contract Verifier_bulkVerifyWithFee is BaseTestWithConfiguredVerifierAndFeeManag signedNativePayloads[i] = signedNativePayload; } - s_verifierProxy.verifyBulk(signedNativePayloads); + s_verifierProxy.verifyBulk(signedNativePayloads, abi.encode(native)); } } @@ -183,7 +179,7 @@ contract Verifier_verify is BaseTestWithConfiguredVerifierAndFeeManager { bytes32[3] memory reportContext; reportContext[0] = s_configDigest; reportContext[1] = bytes32(abi.encode(uint32(5), uint8(1))); - s_signedReport = _generateEncodedBlob(s_testReportOne, reportContext, _getSigners(FAULT_TOLERANCE + 1)); + s_signedReport = _generateV1EncodedBlob(s_testReportOne, reportContext, _getSigners(FAULT_TOLERANCE + 1)); } function testVerifySuccess_gas() public { @@ -193,7 +189,7 @@ contract Verifier_verify is BaseTestWithConfiguredVerifierAndFeeManager { } function testVerifyProxySuccess_gas() public { - s_verifierProxy.verify(s_signedReport); + s_verifierProxy.verify(s_signedReport, abi.encode(native)); } } @@ -222,7 +218,7 @@ contract Verifier_accessControlledVerify is BaseTestWithConfiguredVerifierAndFee bytes32[3] memory reportContext; reportContext[0] = s_configDigest; reportContext[1] = bytes32(abi.encode(uint32(5), uint8(1))); - s_signedReport = _generateEncodedBlob(s_testReportOne, reportContext, _getSigners(FAULT_TOLERANCE + 1)); + s_signedReport = _generateV1EncodedBlob(s_testReportOne, reportContext, _getSigners(FAULT_TOLERANCE + 1)); s_accessController = new SimpleWriteAccessController(); s_verifierProxy.setAccessController(s_accessController); s_accessController.addAccess(CLIENT); @@ -230,6 +226,6 @@ contract Verifier_accessControlledVerify is BaseTestWithConfiguredVerifierAndFee function testVerifyWithAccessControl_gas() public { changePrank(CLIENT); - s_verifierProxy.verify(s_signedReport); + s_verifierProxy.verify(s_signedReport, abi.encode(native)); } } diff --git a/contracts/src/v0.8/llo-feeds/test/mocks/FeeManagerProxy.sol b/contracts/src/v0.8/llo-feeds/test/mocks/FeeManagerProxy.sol index 4e4a8d00e6f..6873a05a601 100644 --- a/contracts/src/v0.8/llo-feeds/test/mocks/FeeManagerProxy.sol +++ b/contracts/src/v0.8/llo-feeds/test/mocks/FeeManagerProxy.sol @@ -6,12 +6,12 @@ import "../../dev/interfaces/IFeeManager.sol"; contract FeeManagerProxy { IFeeManager internal i_feeManager; - function processFee(bytes calldata payload) public payable { - i_feeManager.processFee{value: msg.value}(payload, msg.sender); + function processFee(bytes calldata payload, bytes calldata feePayload) public payable { + i_feeManager.processFee{value: msg.value}(payload, feePayload, msg.sender); } - function processFeeBulk(bytes[] calldata payloads) public payable { - i_feeManager.processFeeBulk{value: msg.value}(payloads, msg.sender); + function processFeeBulk(bytes[] calldata payloads, bytes calldata feePayload) public payable { + i_feeManager.processFeeBulk{value: msg.value}(payloads, feePayload, msg.sender); } function setFeeManager(IFeeManager feeManager) public { diff --git a/contracts/src/v0.8/llo-feeds/test/verifier/BaseVerifierTest.t.sol b/contracts/src/v0.8/llo-feeds/test/verifier/BaseVerifierTest.t.sol index 0525e3ed14a..ab84703fc61 100644 --- a/contracts/src/v0.8/llo-feeds/test/verifier/BaseVerifierTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/verifier/BaseVerifierTest.t.sol @@ -163,7 +163,7 @@ contract BaseTest is Test { ); } - function _generateEncodedBlob( + function _generateV1EncodedBlob( V1Report memory report, bytes32[3] memory reportContext, Signer[] memory signers @@ -336,11 +336,10 @@ contract BaseTestWithConfiguredVerifierAndFeeManager is BaseTest { ); } - function _generateEncodedBlobWithQuote( + function _generateV3EncodedBlob( V3Report memory report, bytes32[3] memory reportContext, - Signer[] memory signers, - bytes memory quote + Signer[] memory signers ) internal pure returns (bytes memory) { bytes memory reportBytes = _encodeReport(report); (bytes32[] memory rs, bytes32[] memory ss, bytes32 rawVs) = _generateSignerSignatures( @@ -348,12 +347,7 @@ contract BaseTestWithConfiguredVerifierAndFeeManager is BaseTest { reportContext, signers ); - - return abi.encode(reportContext, reportBytes, rs, ss, rawVs, quote); - } - - function _generateQuote(address billingAddress) internal pure returns (bytes memory) { - return abi.encode(billingAddress); + return abi.encode(reportContext, reportBytes, rs, ss, rawVs); } function _generateV1Report() internal view returns (V1Report memory) { @@ -409,20 +403,20 @@ contract BaseTestWithConfiguredVerifierAndFeeManager is BaseTest { changePrank(originalAddr); } - function _verify(bytes memory payload, uint256 wrappedNativeValue, address sender) internal { + function _verify(bytes memory payload, address feeAddress, uint256 wrappedNativeValue, address sender) internal { address originalAddr = msg.sender; changePrank(sender); - s_verifierProxy.verify{value: wrappedNativeValue}(payload); + s_verifierProxy.verify{value: wrappedNativeValue}(payload, abi.encode(feeAddress)); changePrank(originalAddr); } - function _verifyBulk(bytes[] memory payload, uint256 wrappedNativeValue, address sender) internal { + function _verifyBulk(bytes[] memory payload, address feeAddress, uint256 wrappedNativeValue, address sender) internal { address originalAddr = msg.sender; changePrank(sender); - s_verifierProxy.verifyBulk{value: wrappedNativeValue}(payload); + s_verifierProxy.verifyBulk{value: wrappedNativeValue}(payload, abi.encode(feeAddress)); changePrank(originalAddr); } diff --git a/contracts/src/v0.8/llo-feeds/test/verifier/VerifierActivateConfigTest.t.sol b/contracts/src/v0.8/llo-feeds/test/verifier/VerifierActivateConfigTest.t.sol index 1905d28da9f..641d2772595 100644 --- a/contracts/src/v0.8/llo-feeds/test/verifier/VerifierActivateConfigTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/verifier/VerifierActivateConfigTest.t.sol @@ -54,7 +54,7 @@ contract VerifierActivateConfigWithDeactivatedConfigTest is BaseTestWithMultiple s_verifier.activateConfig(FEED_ID, s_configDigestTwo); changePrank(address(s_verifierProxy)); - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE_TWO + 1) diff --git a/contracts/src/v0.8/llo-feeds/test/verifier/VerifierDeactivateFeedTest.t.sol b/contracts/src/v0.8/llo-feeds/test/verifier/VerifierDeactivateFeedTest.t.sol index 985283fe223..fc6814d3bfe 100644 --- a/contracts/src/v0.8/llo-feeds/test/verifier/VerifierDeactivateFeedTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/verifier/VerifierDeactivateFeedTest.t.sol @@ -59,7 +59,7 @@ contract VerifierDeactivateFeedWithVerifyTest is BaseTestWithMultipleConfiguredD s_verifier.activateFeed(FEED_ID); changePrank(address(s_verifierProxy)); - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -72,7 +72,7 @@ contract VerifierDeactivateFeedWithVerifyTest is BaseTestWithMultipleConfiguredD changePrank(address(s_verifierProxy)); s_reportContext[0] = s_configDigestTwo; - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE_TWO + 1) @@ -83,7 +83,7 @@ contract VerifierDeactivateFeedWithVerifyTest is BaseTestWithMultipleConfiguredD function test_currentReportFailsVerification() public { changePrank(address(s_verifierProxy)); - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -97,7 +97,7 @@ contract VerifierDeactivateFeedWithVerifyTest is BaseTestWithMultipleConfiguredD changePrank(address(s_verifierProxy)); s_reportContext[0] = s_configDigestTwo; - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE_TWO + 1) diff --git a/contracts/src/v0.8/llo-feeds/test/verifier/VerifierTestBillingReport.t.sol b/contracts/src/v0.8/llo-feeds/test/verifier/VerifierTestBillingReport.t.sol index c6533747614..daa264d4bdb 100644 --- a/contracts/src/v0.8/llo-feeds/test/verifier/VerifierTestBillingReport.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/verifier/VerifierTestBillingReport.t.sol @@ -25,59 +25,55 @@ contract VerifierTestWithConfiguredVerifierAndFeeManager is BaseTestWithConfigur contract VerifierTestBillingReport is VerifierTestWithConfiguredVerifierAndFeeManager { function test_verifyWithLink() public { - bytes memory signedReport = _generateEncodedBlobWithQuote( + bytes memory signedReport = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(link)) + _getSigners(FAULT_TOLERANCE + 1) ); _approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, USER); - _verify(signedReport, 0, USER); + _verify(signedReport, address(link), 0, USER); assertEq(link.balanceOf(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE); } function test_verifyWithNative() public { - bytes memory signedReport = _generateEncodedBlobWithQuote( + bytes memory signedReport = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); _approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); - _verify(signedReport, 0, USER); + _verify(signedReport, address(native), 0, USER); assertEq(native.balanceOf(USER), DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE); assertEq(link.balanceOf(address(rewardManager)), DEFAULT_REPORT_LINK_FEE); } function test_verifyWithNativeUnwrapped() public { - bytes memory signedReport = _generateEncodedBlobWithQuote( + bytes memory signedReport = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); - _verify(signedReport, DEFAULT_REPORT_NATIVE_FEE, USER); + _verify(signedReport, address(native), DEFAULT_REPORT_NATIVE_FEE, USER); assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE); assertEq(address(feeManager).balance, 0); } function test_verifyWithNativeUnwrappedReturnsChange() public { - bytes memory signedReport = _generateEncodedBlobWithQuote( + bytes memory signedReport = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); - _verify(signedReport, DEFAULT_REPORT_NATIVE_FEE * 2, USER); + _verify(signedReport, address(native), DEFAULT_REPORT_NATIVE_FEE * 2, USER); assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE); assertEq(address(feeManager).balance, 0); @@ -88,11 +84,10 @@ contract VerifierBulkVerifyBillingReport is VerifierTestWithConfiguredVerifierAn uint256 internal constant NUMBERS_OF_REPORTS = 5; function test_verifyWithBulkLink() public { - bytes memory signedReport = _generateEncodedBlobWithQuote( + bytes memory signedReport = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(link)) + _getSigners(FAULT_TOLERANCE + 1) ); bytes[] memory signedReports = new bytes[](NUMBERS_OF_REPORTS); @@ -102,18 +97,17 @@ contract VerifierBulkVerifyBillingReport is VerifierTestWithConfiguredVerifierAn _approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * NUMBERS_OF_REPORTS, USER); - _verifyBulk(signedReports, 0, USER); + _verifyBulk(signedReports, address(link), 0, USER); assertEq(link.balanceOf(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * NUMBERS_OF_REPORTS); assertEq(link.balanceOf(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * NUMBERS_OF_REPORTS); } function test_verifyWithBulkNative() public { - bytes memory signedReport = _generateEncodedBlobWithQuote( + bytes memory signedReport = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); bytes[] memory signedReports = new bytes[](NUMBERS_OF_REPORTS); @@ -123,17 +117,16 @@ contract VerifierBulkVerifyBillingReport is VerifierTestWithConfiguredVerifierAn _approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE * NUMBERS_OF_REPORTS, USER); - _verifyBulk(signedReports, 0, USER); + _verifyBulk(signedReports, address(native), 0, USER); assertEq(native.balanceOf(USER), DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * NUMBERS_OF_REPORTS); } function test_verifyWithBulkNativeUnwrapped() public { - bytes memory signedReport = _generateEncodedBlobWithQuote( + bytes memory signedReport = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); bytes[] memory signedReports = new bytes[](NUMBERS_OF_REPORTS); @@ -141,18 +134,17 @@ contract VerifierBulkVerifyBillingReport is VerifierTestWithConfiguredVerifierAn signedReports[i] = signedReport; } - _verifyBulk(signedReports, DEFAULT_REPORT_NATIVE_FEE * NUMBERS_OF_REPORTS, USER); + _verifyBulk(signedReports, address(native), DEFAULT_REPORT_NATIVE_FEE * NUMBERS_OF_REPORTS, USER); assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 5); assertEq(address(feeManager).balance, 0); } function test_verifyWithBulkNativeUnwrappedReturnsChange() public { - bytes memory signedReport = _generateEncodedBlobWithQuote( + bytes memory signedReport = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); bytes[] memory signedReports = new bytes[](NUMBERS_OF_REPORTS); @@ -160,176 +152,65 @@ contract VerifierBulkVerifyBillingReport is VerifierTestWithConfiguredVerifierAn signedReports[i] = signedReport; } - _verifyBulk(signedReports, DEFAULT_REPORT_NATIVE_FEE * (NUMBERS_OF_REPORTS * 2), USER); + _verifyBulk(signedReports, address(native), DEFAULT_REPORT_NATIVE_FEE * (NUMBERS_OF_REPORTS * 2), USER); assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * NUMBERS_OF_REPORTS); assertEq(address(feeManager).balance, 0); } - function test_verifyBulkWithLinkAndWrappedNative() public { - bytes memory linkReport = _generateEncodedBlobWithQuote( - _generateV3Report(), - _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(link)) - ); - - bytes memory nativeReport = _generateEncodedBlobWithQuote( - _generateV3Report(), - _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) - ); - - bytes[] memory signedReports = new bytes[](5); - - signedReports[0] = linkReport; - signedReports[1] = linkReport; - signedReports[2] = linkReport; - signedReports[3] = nativeReport; - signedReports[4] = nativeReport; - - _approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * 3, USER); - _approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE * 2, USER); - - _verifyBulk(signedReports, 0, USER); - - assertEq(native.balanceOf(USER), DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(link.balanceOf(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * 3); - assertEq(link.balanceOf(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * 3); - } - - function test_verifyBulkWithLinkAndUnwrappedNative() public { - bytes memory linkReport = _generateEncodedBlobWithQuote( - _generateV3Report(), - _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(link)) - ); - - bytes memory nativeReport = _generateEncodedBlobWithQuote( - _generateV3Report(), - _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) - ); - - bytes[] memory signedReports = new bytes[](5); - - signedReports[0] = linkReport; - signedReports[1] = linkReport; - signedReports[2] = linkReport; - signedReports[3] = nativeReport; - signedReports[4] = nativeReport; - - _approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE * 3, USER); - - _verifyBulk(signedReports, DEFAULT_REPORT_NATIVE_FEE * 40, USER); - - //user should have some link returned as twice the amount was passed into msg.value - assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(native.balanceOf(address(feeManager)), DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(link.balanceOf(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE * 3); - assertEq(link.balanceOf(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * 3); - } - - function test_verifyBulkReportWithUnwrappedAndWrappedNativeDefaultsToUnwrapped() public { - bytes memory nativeReport1 = _generateEncodedBlobWithQuote( - _generateV3Report(), - _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) - ); - - bytes memory nativeReport2 = _generateEncodedBlobWithQuote( - _generateV3Report(), - _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) - ); - - bytes[] memory signedReports = new bytes[](2); - - signedReports[0] = nativeReport1; - signedReports[1] = nativeReport2; - - _verifyBulk(signedReports, DEFAULT_REPORT_NATIVE_FEE * 2, USER); - - assertEq(USER.balance, DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE * 2); - assertEq(native.balanceOf(USER), DEFAULT_NATIVE_MINT_QUANTITY); - } - function test_verifyMultiVersions() public { - bytes memory signedReportV1 = _generateEncodedBlob( + bytes memory signedReportV1 = _generateV1EncodedBlob( _generateV1Report(), _generateReportContext(v1ConfigDigest), _getSigners(FAULT_TOLERANCE + 1) ); - bytes memory signedReportV3Link = _generateEncodedBlobWithQuote( + bytes memory signedReportV3 = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(link)) - ); - - bytes memory signedReportV3Native = _generateEncodedBlobWithQuote( - _generateV3Report(), - _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); bytes[] memory signedReports = new bytes[](3); signedReports[0] = signedReportV1; - signedReports[1] = signedReportV3Link; - signedReports[2] = signedReportV3Native; + signedReports[1] = signedReportV3; + signedReports[2] = signedReportV3; - _approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, USER); - _approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); + _approveLink(address(rewardManager), 2* DEFAULT_REPORT_LINK_FEE, USER); - _verifyBulk(signedReports, 0, USER); + _verifyBulk(signedReports, address(link), 0, USER); - assertEq(link.balanceOf(USER), DEFAULT_LINK_MINT_QUANTITY - DEFAULT_REPORT_LINK_FEE); - assertEq(native.balanceOf(USER), DEFAULT_NATIVE_MINT_QUANTITY - DEFAULT_REPORT_NATIVE_FEE); + assertEq(link.balanceOf(USER), DEFAULT_LINK_MINT_QUANTITY - 2 * DEFAULT_REPORT_LINK_FEE); + assertEq(native.balanceOf(USER), DEFAULT_NATIVE_MINT_QUANTITY); assertEq(link.balanceOf(address(rewardManager)), DEFAULT_REPORT_LINK_FEE * 2); } function test_verifyMultiVersionsReturnsVerifiedReports() public { - bytes memory signedReportV1 = _generateEncodedBlob( + bytes memory signedReportV1 = _generateV1EncodedBlob( _generateV1Report(), _generateReportContext(v1ConfigDigest), _getSigners(FAULT_TOLERANCE + 1) ); - bytes memory signedReportV3Link = _generateEncodedBlobWithQuote( - _generateV3Report(), - _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(link)) - ); - - bytes memory signedReportV3Native = _generateEncodedBlobWithQuote( + bytes memory signedReportV3 = _generateV3EncodedBlob( _generateV3Report(), _generateReportContext(v3ConfigDigest), - _getSigners(FAULT_TOLERANCE + 1), - _generateQuote(address(native)) + _getSigners(FAULT_TOLERANCE + 1) ); bytes[] memory signedReports = new bytes[](3); signedReports[0] = signedReportV1; - signedReports[1] = signedReportV3Link; - signedReports[2] = signedReportV3Native; + signedReports[1] = signedReportV3; + signedReports[2] = signedReportV3; - _approveLink(address(rewardManager), DEFAULT_REPORT_LINK_FEE, USER); - _approveNative(address(feeManager), DEFAULT_REPORT_NATIVE_FEE, USER); + _approveLink(address(rewardManager), 2 * DEFAULT_REPORT_LINK_FEE, USER); address originalAddr = msg.sender; changePrank(USER); - bytes[] memory verifierReports = s_verifierProxy.verifyBulk{value: 0}(signedReports); + bytes[] memory verifierReports = s_verifierProxy.verifyBulk{value: 0}(signedReports, abi.encode(link)); changePrank(originalAddr); diff --git a/contracts/src/v0.8/llo-feeds/test/verifier/VerifierVerifyTest.t.sol b/contracts/src/v0.8/llo-feeds/test/verifier/VerifierVerifyTest.t.sol index 149ac71feb8..8d770163e00 100644 --- a/contracts/src/v0.8/llo-feeds/test/verifier/VerifierVerifyTest.t.sol +++ b/contracts/src/v0.8/llo-feeds/test/verifier/VerifierVerifyTest.t.sol @@ -57,23 +57,23 @@ contract VerifierVerifyTest is BaseTestWithConfiguredVerifierAndFeeManager { contract VerifierProxyVerifyTest is VerifierVerifyTest { function test_revertsIfNoVerifierConfigured() public { s_reportContext[0] = bytes32("corrupt-digest"); - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) ); vm.expectRevert(abi.encodeWithSelector(VerifierProxy.VerifierNotFound.selector, bytes32("corrupt-digest"))); - s_verifierProxy.verify(signedReport); + s_verifierProxy.verify(signedReport, bytes("")); } function test_proxiesToTheCorrectVerifier() public { - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) ); - bytes memory response = s_verifierProxy.verify(signedReport); + bytes memory response = s_verifierProxy.verify(signedReport, abi.encode(native)); assertReportsEqual(response, s_testReportOne); } } @@ -92,7 +92,7 @@ contract VerifierProxyAccessControlledVerificationTest is VerifierVerifyTest { abi.encodeWithSelector(AccessControllerInterface.hasAccess.selector, USER), abi.encode(false) ); - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -100,7 +100,7 @@ contract VerifierProxyAccessControlledVerificationTest is VerifierVerifyTest { vm.expectRevert(abi.encodeWithSelector(VerifierProxy.AccessForbidden.selector)); changePrank(USER); - s_verifierProxy.verify(signedReport); + s_verifierProxy.verify(signedReport, abi.encode(native)); } function test_proxiesToTheVerifierIfHasAccess() public { @@ -110,21 +110,21 @@ contract VerifierProxyAccessControlledVerificationTest is VerifierVerifyTest { abi.encode(true) ); - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) ); changePrank(USER); - bytes memory response = s_verifierProxy.verify(signedReport); + bytes memory response = s_verifierProxy.verify(signedReport, bytes("")); assertReportsEqual(response, s_testReportOne); } } contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { function test_revertsIfVerifiedByNonProxy() public { - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -136,7 +136,7 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { function test_revertsIfVerifiedWithIncorrectAddresses() public { Signer[] memory signers = _getSigners(FAULT_TOLERANCE + 1); signers[10].mockPrivateKey = 1234; - bytes memory signedReport = _generateEncodedBlob(s_testReportOne, s_reportContext, signers); + bytes memory signedReport = _generateV1EncodedBlob(s_testReportOne, s_reportContext, signers); changePrank(address(s_verifierProxy)); vm.expectRevert(abi.encodeWithSelector(Verifier.BadVerification.selector)); s_verifier.verify(signedReport, msg.sender); @@ -155,7 +155,7 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { function test_revertsIfConfigDigestNotSet() public { bytes32[3] memory reportContext = s_reportContext; reportContext[0] = bytes32("wrong-context-digest"); - bytes memory signedReport = _generateEncodedBlob(s_testReportOne, reportContext, _getSigners(FAULT_TOLERANCE + 1)); + bytes memory signedReport = _generateV1EncodedBlob(s_testReportOne, reportContext, _getSigners(FAULT_TOLERANCE + 1)); vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, FEED_ID, reportContext[0])); changePrank(address(s_verifierProxy)); s_verifier.verify(signedReport, msg.sender); @@ -173,14 +173,14 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { BLOCKNUMBER_LOWER_BOUND, uint32(block.timestamp) ); - bytes memory signedReport = _generateEncodedBlob(report, s_reportContext, _getSigners(FAULT_TOLERANCE + 1)); + bytes memory signedReport = _generateV1EncodedBlob(report, s_reportContext, _getSigners(FAULT_TOLERANCE + 1)); vm.expectRevert(abi.encodeWithSelector(Verifier.DigestInactive.selector, FEED_ID_2, s_reportContext[0])); changePrank(address(s_verifierProxy)); s_verifier.verify(signedReport, msg.sender); } function test_revertsIfWrongNumberOfSigners() public { - bytes memory signedReport = _generateEncodedBlob(s_testReportOne, s_reportContext, _getSigners(10)); + bytes memory signedReport = _generateV1EncodedBlob(s_testReportOne, s_reportContext, _getSigners(10)); vm.expectRevert(abi.encodeWithSelector(Verifier.IncorrectSignatureCount.selector, 10, FAULT_TOLERANCE + 1)); changePrank(address(s_verifierProxy)); s_verifier.verify(signedReport, msg.sender); @@ -190,14 +190,14 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { Signer[] memory signers = _getSigners(FAULT_TOLERANCE + 1); // Duplicate signer at index 1 signers[0] = signers[1]; - bytes memory signedReport = _generateEncodedBlob(s_testReportOne, s_reportContext, signers); + bytes memory signedReport = _generateV1EncodedBlob(s_testReportOne, s_reportContext, signers); vm.expectRevert(abi.encodeWithSelector(Verifier.BadVerification.selector)); changePrank(address(s_verifierProxy)); s_verifier.verify(signedReport, msg.sender); } function test_returnsThePriceAndBlockNumIfReportVerified() public { - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -210,7 +210,7 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { function test_setsTheCorrectEpoch() public { s_reportContext[1] = bytes32(uint256(5 << 8)); - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -223,7 +223,7 @@ contract VerifierVerifySingleConfigDigestTest is VerifierVerifyTest { } function test_emitsAnEventIfReportVerified() public { - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -260,7 +260,7 @@ contract VerifierVerifyMultipleConfigDigestTest is VerifierVerifyTest { function test_revertsIfVerifyingWithAnUnsetDigest() public { s_verifier.deactivateConfig(FEED_ID, (s_oldConfigDigest)); - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -271,7 +271,7 @@ contract VerifierVerifyMultipleConfigDigestTest is VerifierVerifyTest { } function test_canVerifyOlderReportsWithOlderConfigs() public { - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE + 1) @@ -283,7 +283,7 @@ contract VerifierVerifyMultipleConfigDigestTest is VerifierVerifyTest { function test_canVerifyNewerReportsWithNewerConfigs() public { s_reportContext[0] = s_newConfigDigest; - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE_TWO + 1) @@ -296,7 +296,7 @@ contract VerifierVerifyMultipleConfigDigestTest is VerifierVerifyTest { function test_revertsIfAReportIsVerifiedWithAnExistingButIncorrectDigest() public { // Try sending the older digest signed with the new set of signers s_reportContext[0] = s_oldConfigDigest; - bytes memory signedReport = _generateEncodedBlob( + bytes memory signedReport = _generateV1EncodedBlob( s_testReportOne, s_reportContext, _getSigners(FAULT_TOLERANCE_TWO + 1)