public async Task GetIndexedCrossChainBlockData_WithIndex_Test() { var chainId = _chainOptions.ChainId; var fakeMerkleTreeRoot1 = Hash.FromString("fakeMerkleTreeRoot1"); var fakeSideChainBlockData = new SideChainBlockData { Height = 1, ChainId = chainId, TransactionStatusMerkleTreeRoot = fakeMerkleTreeRoot1 }; var fakeIndexedCrossChainBlockData = new CrossChainBlockData(); fakeIndexedCrossChainBlockData.SideChainBlockData.AddRange(new [] { fakeSideChainBlockData }); _crossChainTestHelper.AddFakeIndexedCrossChainBlockData(fakeSideChainBlockData.Height, fakeIndexedCrossChainBlockData); _crossChainTestHelper.AddFakeSideChainIdHeight(chainId, 0); AddFakeCacheData(new Dictionary <int, List <IBlockCacheEntity> > { { chainId, new List <IBlockCacheEntity> { fakeSideChainBlockData } } }); var res = await _crossChainIndexingDataService.GetIndexedCrossChainBlockDataAsync( fakeSideChainBlockData.BlockHeaderHash, 1); Assert.True(res.SideChainBlockData[0].Height == fakeSideChainBlockData.Height); Assert.True(res.SideChainBlockData[0].ChainId == chainId); }
public async Task Validate_WithoutCache() { var fakeMerkleTreeRoot1 = Hash.FromString("fakeMerkleTreeRoot1"); int chainId = 123; var sideChainBlockData = new SideChainBlockData { SideChainHeight = 1, TransactionMerkleTreeRoot = fakeMerkleTreeRoot1, SideChainId = chainId }; var sideChainTxMerkleTreeRoot = ComputeRootHash(new [] { sideChainBlockData }); var block = CreateFilledBlock(sideChainTxMerkleTreeRoot); var fakeIndexedCrossChainData = new CrossChainBlockData(); fakeIndexedCrossChainData.SideChainBlockData.Add(sideChainBlockData); _crossChainTestHelper.AddFakeIndexedCrossChainBlockData(2, fakeIndexedCrossChainData); await Assert.ThrowsAsync <ValidateNextTimeBlockValidationException>(() => _crossChainBlockValidationProvider.ValidateBlockAfterExecuteAsync(block)); }
public async Task Validate_WithoutCache_Test() { var fakeMerkleTreeRoot1 = Hash.FromString("fakeMerkleTreeRoot1"); int chainId = ChainHelper.ConvertBase58ToChainId("2112"); var sideChainBlockData = new SideChainBlockData { Height = 1, TransactionStatusMerkleTreeRoot = fakeMerkleTreeRoot1, ChainId = chainId }; var sideChainTxMerkleTreeRoot = ComputeRootHash(new[] { sideChainBlockData }); var block = CreateFilledBlock(sideChainTxMerkleTreeRoot); block.Header.Bloom = ByteString.CopyFrom(GetSideChainBlockDataIndexedEventBloom().Data); var fakeIndexedCrossChainData = new CrossChainBlockData(); fakeIndexedCrossChainData.SideChainBlockData.Add(sideChainBlockData); _crossChainTestHelper.AddFakeIndexedCrossChainBlockData(2, fakeIndexedCrossChainData); await Assert.ThrowsAsync <BlockValidationException>(() => _crossChainBlockValidationProvider.ValidateBlockAfterExecuteAsync(block)); }