11import type { Script } from '@ckb-lumos/lumos'
22import LightSynchronizer from '../../src/block-sync-renderer/sync/light-synchronizer'
33import AddressMeta from '../../src/database/address/meta'
4+ import { computeScriptHash } from '@ckb-lumos/lumos/utils'
45
56const getSyncStatusMock = jest . fn ( )
67const getCurrentWalletMinSyncedBlockNumberMock = jest . fn ( )
@@ -12,7 +13,7 @@ const getWalletMinLocalSavedBlockNumberMock = jest.fn()
1213const removeByHashesAndAddressType = jest . fn ( )
1314const getOtherTypeSyncProgressMock = jest . fn ( )
1415const getOtherTypeSyncBlockNumberMock = jest . fn ( )
15- const getExistingSyncArgsesMock = jest . fn ( )
16+ const getExistingSyncScriptsMock = jest . fn ( )
1617
1718const setScriptsMock = jest . fn ( )
1819const getScriptsMock = jest . fn ( )
@@ -65,7 +66,7 @@ jest.mock('../../src/services/sync-progress', () => {
6566
6667 static getOtherTypeSyncProgress : any = ( ) => getOtherTypeSyncProgressMock ( )
6768 static getOtherTypeSyncBlockNumber : any = ( ) => getOtherTypeSyncBlockNumberMock ( )
68- static getExistingSyncArgses : any = ( ) => getExistingSyncArgsesMock ( )
69+ static getExistingSyncScripts : any = ( ) => getExistingSyncScriptsMock ( )
6970 }
7071} )
7172
@@ -145,7 +146,7 @@ describe('test light synchronizer', () => {
145146 it ( 'when syncing script in the local DB' , async ( ) => {
146147 getScriptsMock . mockResolvedValue ( [ { script, blockNumber : '0xaa' } ] )
147148 walletGetAllMock . mockReturnValue ( [ { id : 'walletId' } ] )
148- getExistingSyncArgsesMock . mockResolvedValue ( new Set ( [ script . args ] ) )
149+ getExistingSyncScriptsMock . mockResolvedValue ( new Set ( [ computeScriptHash ( script ) ] ) )
149150 const addressMeta = AddressMeta . fromObject ( {
150151 walletId : 'walletId' ,
151152 address,
@@ -195,7 +196,7 @@ describe('test light synchronizer', () => {
195196 it ( 'when syncing script not in the local DB' , async ( ) => {
196197 getScriptsMock . mockResolvedValue ( [ { script, blockNumber : '0xaa' } ] )
197198 walletGetAllMock . mockReturnValue ( [ { id : 'walletId' } ] )
198- getExistingSyncArgsesMock . mockResolvedValue ( new Set ( ) )
199+ getExistingSyncScriptsMock . mockResolvedValue ( new Set ( ) )
199200 const addressMeta = AddressMeta . fromObject ( {
200201 walletId : 'walletId' ,
201202 address,
@@ -397,7 +398,7 @@ describe('test light synchronizer', () => {
397398 }
398399 const getScriptsResult = [ { script : script2 , blockNumber : '0xaa' , scriptType : 'lock' } ]
399400 getScriptsMock . mockResolvedValue ( getScriptsResult )
400- getExistingSyncArgsesMock . mockResolvedValue ( new Set ( [ script2 . args ] ) )
401+ getExistingSyncScriptsMock . mockResolvedValue ( new Set ( [ computeScriptHash ( script2 ) ] ) )
401402 const addressMeta2 = AddressMeta . fromObject ( {
402403 walletId : 'walletId2' ,
403404 address,
@@ -481,7 +482,7 @@ describe('test light synchronizer', () => {
481482 }
482483 const getScriptsResult = [ { script : script2 , blockNumber : '0xab' , scriptType : 'lock' } ]
483484 getScriptsMock . mockResolvedValue ( getScriptsResult )
484- getExistingSyncArgsesMock . mockResolvedValue ( new Set ( [ script2 . args ] ) )
485+ getExistingSyncScriptsMock . mockResolvedValue ( new Set ( [ computeScriptHash ( script2 ) ] ) )
485486 const addressMeta2 = AddressMeta . fromObject ( {
486487 walletId : 'walletId2' ,
487488 address,
0 commit comments