File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
packages/snaps-controllers/src/snaps/registry Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -617,6 +617,27 @@ describe('JsonSnapsRegistry', () => {
617617 expect ( fetchMock ) . toHaveBeenCalledTimes ( 2 ) ;
618618 } ) ;
619619
620+ it ( 'skips update if the signature matches the existing one' , async ( ) => {
621+ const spy = jest . spyOn ( globalThis . crypto . subtle , 'digest' ) ;
622+
623+ fetchMock
624+ . mockResponseOnce ( JSON . stringify ( MOCK_DATABASE ) )
625+ . mockResponseOnce ( JSON . stringify ( MOCK_SIGNATURE_FILE ) ) ;
626+
627+ const { messenger } = getRegistry ( {
628+ state : {
629+ database : MOCK_DATABASE ,
630+ signature : MOCK_SIGNATURE ,
631+ lastUpdated : 0 ,
632+ databaseUnavailable : false ,
633+ } ,
634+ } ) ;
635+ await messenger . call ( 'SnapsRegistry:update' ) ;
636+
637+ expect ( fetchMock ) . toHaveBeenCalledTimes ( 2 ) ;
638+ expect ( spy ) . not . toHaveBeenCalled ( ) ;
639+ } ) ;
640+
620641 it ( 'does not fetch if a second call is made under the threshold' , async ( ) => {
621642 fetchMock
622643 . mockResponseOnce ( JSON . stringify ( MOCK_DATABASE ) )
Original file line number Diff line number Diff line change @@ -273,6 +273,7 @@ export class JsonSnapsRegistry extends BaseController<
273273 state . database = JSON . parse ( database ) ;
274274 state . lastUpdated = Date . now ( ) ;
275275 state . databaseUnavailable = false ;
276+ state . signature = signatureJson . signature ;
276277 } ) ;
277278 } catch {
278279 // Ignore
You can’t perform that action at this time.
0 commit comments