public void RegisterNewChain_NotNull() { int chainId = 123; _crossChainMemoryCacheService.RegisterNewChainCache(chainId, 1); var count = _crossChainMemoryCacheService.GetCachedChainCount(); Assert.True(1 == count); }
public async Task RegisterNewChainsAsync(Hash blockHash, long blockHeight) { var dict = await _crossChainContractReader.GetAllChainsIdAndHeightAsync(blockHash, blockHeight); foreach (var chainIdHeight in dict) { _crossChainMemoryCacheService.RegisterNewChainCache(chainIdHeight.Key, chainIdHeight.Value + 1); } }
public void TryTake_After_RegisterNewChain() { int chainId = 123; _crossChainMemoryCacheService.RegisterNewChainCache(chainId, 1); var blockInfoCache = MultiChainBlockInfoCacheProvider.GetBlockInfoCache(chainId); Assert.NotNull(blockInfoCache); var expectedBlockInfo = new SideChainBlockData { SideChainId = chainId, SideChainHeight = 1 }; blockInfoCache.TryAdd(expectedBlockInfo); var actualBlockInfo = _crossChainDataConsumer.TryTake <SideChainBlockData>(chainId, 1, false); Assert.Equal(expectedBlockInfo, actualBlockInfo); }
protected void AddFakeCacheData(Dictionary <int, List <IBlockInfo> > fakeCache) { foreach (var(crossChainId, blockInfos) in fakeCache) { _crossChainMemoryCacheService.RegisterNewChainCache(crossChainId, blockInfos.First().Height); foreach (var blockInfo in blockInfos) { _crossChainDataProducer.AddNewBlockInfo(blockInfo); } } }