Skip to content

Commit e0ea4d6

Browse files
Add test
1 parent 7e41ef7 commit e0ea4d6

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

packages/snaps-controllers/src/snaps/registry/json.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,49 @@ describe('JsonSnapsRegistry', () => {
376376
expect(result).toBe('1.0.0');
377377
});
378378

379+
it('resolves to a compatible allowlisted version', async () => {
380+
fetchMock
381+
.mockResponseOnce(
382+
JSON.stringify({
383+
verifiedSnaps: {
384+
[MOCK_SNAP_ID]: {
385+
id: MOCK_SNAP_ID,
386+
metadata: {
387+
name: 'Mock Snap',
388+
},
389+
versions: {
390+
['1.0.0' as SemVerVersion]: {
391+
checksum: DEFAULT_SNAP_SHASUM,
392+
},
393+
['1.1.0' as SemVerVersion]: {
394+
checksum: DEFAULT_SNAP_SHASUM,
395+
clientVersions: {
396+
extension: '>=15.0.0',
397+
},
398+
},
399+
},
400+
},
401+
},
402+
}),
403+
)
404+
.mockResponseOnce(
405+
JSON.stringify({
406+
...MOCK_SIGNATURE_FILE,
407+
signature:
408+
'0x3045022100e17cf0f34e4d521d984ed8f8492ce8a51b65178e7ba5508e01b179c5dd013c52022025e4a4008232a883048c8174e585cd89b9054eadc37330e00fd2f07a65c9bbb4',
409+
}),
410+
);
411+
412+
const { messenger } = getRegistry();
413+
const result = await messenger.call(
414+
'SnapsRegistry:resolveVersion',
415+
MOCK_SNAP_ID,
416+
'^1.0.0' as SemVerRange,
417+
);
418+
419+
expect(result).toBe('1.0.0');
420+
});
421+
379422
it('returns version range if snap is not on the allowlist', async () => {
380423
fetchMock
381424
.mockResponseOnce(

0 commit comments

Comments
 (0)