@@ -211,6 +211,30 @@ func (m *MockTransferVerifier[E, C]) Addrs() *txverifier.TVAddresses {
211211 }
212212}
213213
214+ // TestVerifyDoesNotMutateOriginalMessage checks that verify() does not modify
215+ // the original MessagePublication passed to it.
216+ func TestVerifyDoesNotMutateOriginalMessage (t * testing.T ) {
217+ tbAddr , err := vaa .BytesToAddress ([]byte {0x01 })
218+ require .NoError (t , err )
219+
220+ msg := & common.MessagePublication {
221+ EmitterAddress : tbAddr ,
222+ }
223+ require .Equal (t , common .NotVerified .String (), msg .VerificationState ().String ())
224+
225+ successMock := & MockTransferVerifier [ethclient.Client , connectors.Connector ]{true }
226+ ctx := context .TODO ()
227+
228+ result , err := verify (ctx , msg , eth_common.Hash {}, & types.Receipt {}, successMock )
229+ require .NoError (t , err )
230+
231+ // The returned copy should have the updated verification state.
232+ require .Equal (t , common .Valid .String (), result .VerificationState ().String ())
233+
234+ // The original message must remain unmodified.
235+ require .Equal (t , common .NotVerified .String (), msg .VerificationState ().String ())
236+ }
237+
214238func TestConsistencyLevelMatches (t * testing.T ) {
215239 // Success cases.
216240 assert .True (t , consistencyLevelMatches (vaa .ConsistencyLevelPublishImmediately , vaa .ConsistencyLevelPublishImmediately ))
0 commit comments