Revert if delivery address is 0, and add forge tests testing this (#115)
* Revert if delivery address is 0, and add forge tests testing this * Test passes
This commit is contained in:
parent
11874c5c76
commit
db355a2f1d
|
@ -265,19 +265,19 @@ contract CoreRelayer is CoreRelayerDelivery {
|
|||
// For each 'Send' request,
|
||||
// calculate how much gas the relay provider can pay for on 'request.targetChain' using 'request.newTransactionFee',
|
||||
// and calculate how much value the relay provider will pass into 'request.targetAddress'
|
||||
DeliveryInstructionsContainer memory container =
|
||||
DeliveryInstructionsContainer memory instructionsContainer =
|
||||
convertMultichainSendToDeliveryInstructionsContainer(sendContainer);
|
||||
|
||||
// For each 'Send' request,
|
||||
// Check that the total amount of value the relay provider needs to use for this send is <= the relayProvider's maximum budget for 'targetChain'
|
||||
// and check that the calculated gas is greater than 0
|
||||
checkInstructions(container, IRelayProvider(sendContainer.relayProviderAddress));
|
||||
checkInstructions(instructionsContainer, IRelayProvider(sendContainer.relayProviderAddress));
|
||||
|
||||
// Save information about the forward in state, so it can be processed after the execution of 'receiveWormholeMessages',
|
||||
// because we will then know how much of the 'maxTransactionFee' of the current delivery is still available for use in this forward
|
||||
setForwardInstruction(
|
||||
ForwardInstruction({
|
||||
container: container,
|
||||
container: instructionsContainer,
|
||||
nonce: nonce,
|
||||
msgValue: msg.value,
|
||||
totalFee: totalFee,
|
||||
|
|
|
@ -85,6 +85,10 @@ contract CoreRelayerMessages is CoreRelayerStructs, CoreRelayerGetters {
|
|||
instruction.targetChain = send.targetChain;
|
||||
instruction.targetAddress = send.targetAddress;
|
||||
instruction.refundAddress = send.refundAddress;
|
||||
bytes32 deliveryAddress = relayProvider.getDeliveryAddress(send.targetChain);
|
||||
if (deliveryAddress == bytes32(0x0)) {
|
||||
revert IWormholeRelayer.RelayProviderDoesNotSupportTargetChain();
|
||||
}
|
||||
instruction.maximumRefundTarget =
|
||||
calculateTargetDeliveryMaximumRefund(send.targetChain, send.maxTransactionFee, relayProvider);
|
||||
instruction.receiverValueTarget =
|
||||
|
@ -92,7 +96,7 @@ contract CoreRelayerMessages is CoreRelayerStructs, CoreRelayerGetters {
|
|||
instruction.executionParameters = ExecutionParameters({
|
||||
version: 1,
|
||||
gasLimit: calculateTargetGasDeliveryAmount(send.targetChain, send.maxTransactionFee, relayProvider),
|
||||
providerDeliveryAddress: relayProvider.getDeliveryAddress(send.targetChain)
|
||||
providerDeliveryAddress: deliveryAddress
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1314,6 +1314,36 @@ contract TestCoreRelayer is Test {
|
|||
);
|
||||
}
|
||||
|
||||
function testRevertTargetNotSupported(
|
||||
GasParameters memory gasParams,
|
||||
FeeParameters memory feeParams,
|
||||
bytes memory message
|
||||
) public {
|
||||
StandardSetupTwoChains memory setup = standardAssumeAndSetupTwoChains(gasParams, feeParams, 1000000);
|
||||
|
||||
vm.recordLogs();
|
||||
|
||||
// estimate the cost based on the intialized values
|
||||
uint256 maxTransactionFee = setup.source.coreRelayer.quoteGas(
|
||||
setup.targetChainId, gasParams.targetGasLimit, address(setup.source.relayProvider)
|
||||
);
|
||||
|
||||
uint256 wormholeFee = setup.source.wormhole.messageFee();
|
||||
|
||||
vm.expectRevert(abi.encodeWithSignature("RelayProviderDoesNotSupportTargetChain()"));
|
||||
setup.source.integration.sendMessageWithRefundAddress{value: maxTransactionFee + uint256(3) * wormholeFee}(
|
||||
message, 32, address(setup.target.integration), address(setup.target.refundAddress)
|
||||
);
|
||||
|
||||
setup.source.relayProvider.updateDeliveryAddress(
|
||||
setup.targetChainId, setup.source.relayProvider.getDeliveryAddress(32)
|
||||
);
|
||||
vm.expectRevert(abi.encodeWithSignature("RelayProviderDoesNotSupportTargetChain()"));
|
||||
setup.source.integration.sendMessageWithRefundAddress{value: maxTransactionFee + uint256(3) * wormholeFee}(
|
||||
message, setup.targetChainId, address(setup.target.integration), address(setup.target.refundAddress)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue