@@ -2,6 +2,7 @@ package executable
22
33import (
44 "testing"
5+ "time"
56
67 "github.com/stretchr/testify/require"
78 "google.golang.org/protobuf/types/known/anypb"
@@ -106,6 +107,31 @@ func TestSimpleHasher_ExcludesSpendLimits(t *testing.T) {
106107 require .NotEqual (t , hash1 , hash3 ) // different data should produce different hash
107108}
108109
110+ func TestSimpleHasher_ExcludesExecutionTimestamp (t * testing.T ) {
111+ ts1 := time .Date (2025 , 6 , 15 , 12 , 0 , 0 , 0 , time .UTC )
112+ ts2 := time .Date (2025 , 7 , 20 , 8 , 30 , 0 , 0 , time .UTC )
113+ req1 := getRequestWithMetadata (t , []byte ("testdata" ), capabilities.RequestMetadata {
114+ WorkflowID : "wf1" , WorkflowExecutionID : "exec1" , ExecutionTimestamp : ts1 ,
115+ })
116+ req2 := getRequestWithMetadata (t , []byte ("testdata" ), capabilities.RequestMetadata {
117+ WorkflowID : "wf1" , WorkflowExecutionID : "exec1" , ExecutionTimestamp : ts2 ,
118+ })
119+ req3 := getRequestWithMetadata (t , []byte ("otherdata" ), capabilities.RequestMetadata {
120+ WorkflowID : "wf1" , WorkflowExecutionID : "exec1" , ExecutionTimestamp : ts1 ,
121+ })
122+
123+ hasher := NewSimpleHasher ()
124+ hash1 , err := hasher .Hash (req1 )
125+ require .NoError (t , err )
126+ hash2 , err := hasher .Hash (req2 )
127+ require .NoError (t , err )
128+ hash3 , err := hasher .Hash (req3 )
129+ require .NoError (t , err )
130+
131+ require .Equal (t , hash1 , hash2 ) // same data, different ExecutionTimestamp should produce same hash
132+ require .NotEqual (t , hash1 , hash3 ) // different data should produce different hash
133+ }
134+
109135func TestWriteReportExcludeSignaturesHasher_ExcludesSpendLimits (t * testing.T ) {
110136 // Create two requests with identical payloads but different SpendLimits
111137 req1 := getWriteReportRequestWithSpendLimits (t , []byte ("testdata" ), [][]byte {[]byte ("sig1" ), []byte ("sig2" )}, []capabilities.SpendLimit {
@@ -161,6 +187,27 @@ func getRequest(t *testing.T, data []byte, sigs [][]byte) *types.MessageBody {
161187 }
162188}
163189
190+ func getRequestWithMetadata (t * testing.T , data []byte , md capabilities.RequestMetadata ) * types.MessageBody {
191+ report := & sdk.ReportResponse {
192+ RawReport : data ,
193+ Sigs : []* sdk.AttributedSignature {},
194+ }
195+ wrReq := & evmcappb.WriteReportRequest {
196+ Report : report ,
197+ }
198+ wrAny , err := anypb .New (wrReq )
199+ require .NoError (t , err )
200+ capReq := capabilities.CapabilityRequest {
201+ Payload : wrAny ,
202+ Metadata : md ,
203+ }
204+ capReqBytes , err := pb .MarshalCapabilityRequest (capReq )
205+ require .NoError (t , err )
206+ return & types.MessageBody {
207+ Payload : capReqBytes ,
208+ }
209+ }
210+
164211func getRequestWithSpendLimits (t * testing.T , data []byte , spendLimits []capabilities.SpendLimit ) * types.MessageBody {
165212 report := & sdk.ReportResponse {
166213 RawReport : data ,
0 commit comments