@@ -74,6 +74,7 @@ func TestHandleDefinitionIdentityUpdateOk(t *testing.T) {
7474
7575 mim := dh .identity .(* identitymanagermocks.Manager )
7676 mim .On ("CachedIdentityLookupByID" , ctx , org1 .ID ).Return (org1 , nil )
77+ mim .On ("VerifyIdentityChain" , ctx , mock .Anything ).Return (nil , false , nil )
7778
7879 mdi := dh .database .(* databasemocks.Plugin )
7980 mdi .On ("UpsertIdentity" , ctx , mock .MatchedBy (func (identity * fftypes.Identity ) bool {
@@ -105,6 +106,7 @@ func TestHandleDefinitionIdentityUpdateUpsertFail(t *testing.T) {
105106
106107 mim := dh .identity .(* identitymanagermocks.Manager )
107108 mim .On ("CachedIdentityLookupByID" , ctx , org1 .ID ).Return (org1 , nil )
109+ mim .On ("VerifyIdentityChain" , ctx , mock .Anything ).Return (nil , false , nil )
108110
109111 mdi := dh .database .(* databasemocks.Plugin )
110112 mdi .On ("UpsertIdentity" , ctx , mock .Anything , database .UpsertOptimizationExisting ).Return (fmt .Errorf ("pop" ))
@@ -127,6 +129,7 @@ func TestHandleDefinitionIdentityInvalidIdentity(t *testing.T) {
127129
128130 mim := dh .identity .(* identitymanagermocks.Manager )
129131 mim .On ("CachedIdentityLookupByID" , ctx , org1 .ID ).Return (org1 , nil )
132+ mim .On ("VerifyIdentityChain" , ctx , mock .Anything ).Return (nil , false , nil )
130133
131134 action , err := dh .HandleDefinitionBroadcast (ctx , bs , updateMsg , fftypes.DataArray {updateData }, fftypes .NewUUID ())
132135 assert .Equal (t , HandlerResult {Action : ActionReject }, action )
@@ -136,6 +139,44 @@ func TestHandleDefinitionIdentityInvalidIdentity(t *testing.T) {
136139 bs .assertNoFinalizers ()
137140}
138141
142+ func TestHandleDefinitionVerifyFail (t * testing.T ) {
143+ dh , bs := newTestDefinitionHandlers (t )
144+ ctx := context .Background ()
145+
146+ org1 , updateMsg , updateData , _ := testIdentityUpdate (t )
147+ updateMsg .Header .Author = "wrong"
148+
149+ mim := dh .identity .(* identitymanagermocks.Manager )
150+ mim .On ("CachedIdentityLookupByID" , ctx , org1 .ID ).Return (org1 , nil )
151+ mim .On ("VerifyIdentityChain" , ctx , mock .Anything ).Return (nil , true , fmt .Errorf ("pop" ))
152+
153+ action , err := dh .HandleDefinitionBroadcast (ctx , bs , updateMsg , fftypes.DataArray {updateData }, fftypes .NewUUID ())
154+ assert .Equal (t , HandlerResult {Action : ActionRetry }, action )
155+ assert .Regexp (t , "pop" , err )
156+
157+ mim .AssertExpectations (t )
158+ bs .assertNoFinalizers ()
159+ }
160+
161+ func TestHandleDefinitionVerifyWait (t * testing.T ) {
162+ dh , bs := newTestDefinitionHandlers (t )
163+ ctx := context .Background ()
164+
165+ org1 , updateMsg , updateData , _ := testIdentityUpdate (t )
166+ updateMsg .Header .Author = "wrong"
167+
168+ mim := dh .identity .(* identitymanagermocks.Manager )
169+ mim .On ("CachedIdentityLookupByID" , ctx , org1 .ID ).Return (org1 , nil )
170+ mim .On ("VerifyIdentityChain" , ctx , mock .Anything ).Return (nil , false , fmt .Errorf ("pop" ))
171+
172+ action , err := dh .HandleDefinitionBroadcast (ctx , bs , updateMsg , fftypes.DataArray {updateData }, fftypes .NewUUID ())
173+ assert .Equal (t , HandlerResult {Action : ActionWait }, action )
174+ assert .NoError (t , err )
175+
176+ mim .AssertExpectations (t )
177+ bs .assertNoFinalizers ()
178+ }
179+
139180func TestHandleDefinitionIdentityNotFound (t * testing.T ) {
140181 dh , bs := newTestDefinitionHandlers (t )
141182 ctx := context .Background ()
0 commit comments