public async Task NonparallelContractCodeSetAndGet_Test() { var chain = await _blockchainService.GetChainAsync(); var blockExecutedDataKey = $"BlockExecutedData/NonparallelContractCode/{SampleAddress.AddressList[0]}"; var blockStateSet = await _blockStateSetManger.GetBlockStateSetAsync(chain.BestChainHash); blockStateSet.BlockExecutedData.ShouldNotContainKey(blockExecutedDataKey); var nonparallelContractCode = new NonparallelContractCode { CodeHash = HashHelper.ComputeFrom(blockExecutedDataKey) }; var dictionary = new Dictionary <Address, NonparallelContractCode> { { SampleAddress.AddressList[0], nonparallelContractCode } }; await _nonparallelContractCodeProvider.SetNonparallelContractCodeAsync(new BlockIndex { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }, dictionary); blockStateSet = await _blockStateSetManger.GetBlockStateSetAsync(chain.BestChainHash); blockStateSet.BlockExecutedData.ShouldContainKey(blockExecutedDataKey); _blockchainExecutedDataCacheProvider.TryGetChangeHeight(blockExecutedDataKey, out _).ShouldBeTrue(); var nonparallelContractCodeFromState = await _nonparallelContractCodeProvider.GetNonparallelContractCodeAsync( new ChainContext { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }, SampleAddress.AddressList[0]); nonparallelContractCodeFromState.ShouldBe(nonparallelContractCode); await _cleanBlockExecutedDataChangeHeightEventHandler.HandleEventAsync( new CleanBlockExecutedDataChangeHeightEventData { IrreversibleBlockHeight = chain.BestChainHeight }); _blockchainExecutedDataCacheProvider.TryGetChangeHeight(blockExecutedDataKey, out _).ShouldBeFalse(); }
public async Task NonparallelContractCodeSetAndGet_Test() { var chain = await _blockchainService.GetChainAsync(); var blockExecutedDataKey = $"BlockExecutedData/NonparallelContractCode/{SampleAddress.AddressList[0]}"; var blockStateSet = await _blockStateSetManger.GetBlockStateSetAsync(chain.BestChainHash); blockStateSet.BlockExecutedData.ShouldNotContainKey(blockExecutedDataKey); var nonparallelContractCode = new NonparallelContractCode { CodeHash = Hash.FromString(blockExecutedDataKey) }; var dictionary = new Dictionary <Address, NonparallelContractCode> { { SampleAddress.AddressList[0], nonparallelContractCode } }; await _nonparallelContractCodeProvider.SetNonparallelContractCodeAsync(new BlockIndex { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }, dictionary); blockStateSet = await _blockStateSetManger.GetBlockStateSetAsync(chain.BestChainHash); blockStateSet.BlockExecutedData.ShouldContainKey(blockExecutedDataKey); var nonparallelContractCodeFromState = await _nonparallelContractCodeProvider.GetNonparallelContractCodeAsync( new ChainContext { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }, SampleAddress.AddressList[0]); nonparallelContractCodeFromState.ShouldBe(nonparallelContractCode); }