@@ -626,7 +626,8 @@ contract MessageTransmitterV2Test is TestUtils {
626
626
address _destinationCaller ,
627
627
uint32 _minFinalityThreshold ,
628
628
uint32 _finalityThresholdExecuted ,
629
- bytes calldata _messageBody
629
+ bytes calldata _messageBody ,
630
+ address _randomCaller
630
631
) public {
631
632
bytes memory _message = _formatMessageForReceive (
632
633
version,
@@ -641,7 +642,7 @@ contract MessageTransmitterV2Test is TestUtils {
641
642
_messageBody
642
643
);
643
644
bytes memory _signature = _sign1of1Message (_message);
644
- _receiveMessage (_message, _signature);
645
+ _receiveMessage (_message, _signature, _randomCaller );
645
646
646
647
// Try again
647
648
vm.prank (_destinationCaller);
@@ -690,7 +691,8 @@ contract MessageTransmitterV2Test is TestUtils {
690
691
address _destinationCaller ,
691
692
uint32 _minFinalityThreshold ,
692
693
uint32 _finalityThresholdExecuted ,
693
- bytes calldata _messageBody
694
+ bytes calldata _messageBody ,
695
+ address _randomCaller
694
696
) public {
695
697
bytes memory _message = _formatMessageForReceive (
696
698
version,
@@ -705,7 +707,7 @@ contract MessageTransmitterV2Test is TestUtils {
705
707
_messageBody
706
708
);
707
709
bytes memory _signature = _sign1of1Message (_message);
708
- _receiveMessage (_message, _signature);
710
+ _receiveMessage (_message, _signature, _randomCaller );
709
711
}
710
712
711
713
function testReceiveMessage_succeedsWith2of2Signing (
@@ -716,7 +718,8 @@ contract MessageTransmitterV2Test is TestUtils {
716
718
address _destinationCaller ,
717
719
uint32 _minFinalityThreshold ,
718
720
uint32 _finalityThresholdExecuted ,
719
- bytes calldata _messageBody
721
+ bytes calldata _messageBody ,
722
+ address _randomCaller
720
723
) public {
721
724
_setup2of2Multisig ();
722
725
@@ -733,7 +736,7 @@ contract MessageTransmitterV2Test is TestUtils {
733
736
_messageBody
734
737
);
735
738
bytes memory _signature = _sign2OfNMultisigMessage (_message);
736
- _receiveMessage (_message, _signature);
739
+ _receiveMessage (_message, _signature, _randomCaller );
737
740
}
738
741
739
742
function testReceiveMessage_succeedsWith2of3Signing (
@@ -744,7 +747,8 @@ contract MessageTransmitterV2Test is TestUtils {
744
747
address _destinationCaller ,
745
748
uint32 _minFinalityThreshold ,
746
749
uint32 _finalityThresholdExecuted ,
747
- bytes calldata _messageBody
750
+ bytes calldata _messageBody ,
751
+ address _randomCaller
748
752
) public {
749
753
_setup2of3Multisig ();
750
754
@@ -761,7 +765,7 @@ contract MessageTransmitterV2Test is TestUtils {
761
765
_messageBody
762
766
);
763
767
bytes memory _signature = _sign2OfNMultisigMessage (_message);
764
- _receiveMessage (_message, _signature);
768
+ _receiveMessage (_message, _signature, _randomCaller );
765
769
}
766
770
767
771
function testReceiveMessage_succeedsWithFinalizedMessage (
@@ -772,7 +776,8 @@ contract MessageTransmitterV2Test is TestUtils {
772
776
address _destinationCaller ,
773
777
uint32 _minFinalityThreshold ,
774
778
uint32 _finalityThresholdExecuted ,
775
- bytes calldata _messageBody
779
+ bytes calldata _messageBody ,
780
+ address _randomCaller
776
781
) public {
777
782
vm.assume (
778
783
_finalityThresholdExecuted >=
@@ -791,7 +796,7 @@ contract MessageTransmitterV2Test is TestUtils {
791
796
_messageBody
792
797
);
793
798
bytes memory _signature = _sign1of1Message (_message);
794
- _receiveMessage (_message, _signature);
799
+ _receiveMessage (_message, _signature, _randomCaller );
795
800
}
796
801
797
802
function testReceiveMessage_succeedsWithUnfinalizedMessage (
@@ -802,7 +807,8 @@ contract MessageTransmitterV2Test is TestUtils {
802
807
address _destinationCaller ,
803
808
uint32 _minFinalityThreshold ,
804
809
uint32 _finalityThresholdExecuted ,
805
- bytes calldata _messageBody
810
+ bytes calldata _messageBody ,
811
+ address _randomCaller
806
812
) public {
807
813
vm.assume (
808
814
_finalityThresholdExecuted <
@@ -821,7 +827,7 @@ contract MessageTransmitterV2Test is TestUtils {
821
827
_messageBody
822
828
);
823
829
bytes memory _signature = _sign1of1Message (_message);
824
- _receiveMessage (_message, _signature);
830
+ _receiveMessage (_message, _signature, _randomCaller );
825
831
}
826
832
827
833
function testReceiveMessage_succeedsWithNonZeroDestinationCaller (
@@ -848,7 +854,7 @@ contract MessageTransmitterV2Test is TestUtils {
848
854
_messageBody
849
855
);
850
856
bytes memory _signature = _sign1of1Message (_message);
851
- _receiveMessage (_message, _signature);
857
+ _receiveMessage (_message, _signature, _destinationCaller );
852
858
}
853
859
854
860
function testReceiveMessage_succeedsWithZeroDestinationCaller (
@@ -858,8 +864,10 @@ contract MessageTransmitterV2Test is TestUtils {
858
864
address _recipient ,
859
865
uint32 _minFinalityThreshold ,
860
866
uint32 _finalityThresholdExecuted ,
861
- bytes calldata _messageBody
867
+ bytes calldata _messageBody ,
868
+ address _randomCaller
862
869
) public {
870
+ vm.assume (_randomCaller != address (0 ));
863
871
bytes memory _message = _formatMessageForReceive (
864
872
version,
865
873
_sourceDomain,
@@ -873,7 +881,7 @@ contract MessageTransmitterV2Test is TestUtils {
873
881
_messageBody
874
882
);
875
883
bytes memory _signature = _sign1of1Message (_message);
876
- _receiveMessage (_message, _signature);
884
+ _receiveMessage (_message, _signature, _randomCaller );
877
885
}
878
886
879
887
function testSendMaxMessageBodySize_revertsOnNonOwner (
@@ -1009,9 +1017,12 @@ contract MessageTransmitterV2Test is TestUtils {
1009
1017
vm.stopPrank ();
1010
1018
}
1011
1019
1020
+ // Calls receiveMessage with msg.destinationCaller if set; otherwise
1021
+ // with `_randomCaller`
1012
1022
function _receiveMessage (
1013
1023
bytes memory _message ,
1014
- bytes memory _signature
1024
+ bytes memory _signature ,
1025
+ address _randomCaller
1015
1026
) internal {
1016
1027
bytes29 _msg = _message.ref (0 );
1017
1028
address _recipient = AddressUtils.bytes32ToAddress (
@@ -1034,10 +1045,17 @@ contract MessageTransmitterV2Test is TestUtils {
1034
1045
vm.mockCall (_recipient, _encodedMessageHandlerCall, abi.encode (true ));
1035
1046
vm.expectCall (_recipient, _encodedMessageHandlerCall, 1 );
1036
1047
1037
- // Spoof the destination caller
1038
- address _caller = AddressUtils.bytes32ToAddress (
1039
- _msg._getDestinationCaller ()
1040
- );
1048
+ // Spoof the destination caller if needed
1049
+ address _caller;
1050
+ if (_msg._getDestinationCaller () == bytes32 (0 )) {
1051
+ // Don't spoof the 0-address; defeats the purpose of the test
1052
+ vm.assume (_randomCaller != address (0 ));
1053
+ _caller = _randomCaller;
1054
+ } else {
1055
+ _caller = AddressUtils.bytes32ToAddress (
1056
+ _msg._getDestinationCaller ()
1057
+ );
1058
+ }
1041
1059
1042
1060
// assert that a MessageReceive event was logged with expected message bytes
1043
1061
vm.expectEmit (true , true , true , true );
0 commit comments