public async Task Test()
        {
            var preBlockHeader = await _blockchainService.GetBestChainLastBlockHeaderAsync();

            var chainContext = new ChainContext
            {
                BlockHash   = preBlockHeader.GetHash(),
                BlockHeight = preBlockHeader.Height
            };
            var contractMapping = await ContractAddressService.GetSystemContractNameToAddressMappingAsync(chainContext);

            var tokenStub = GetTester <TokenContractContainer.TokenContractStub>(
                contractMapping[TokenSmartContractAddressNameProvider.Name], Accounts[0].KeyPair);
            var balance = await tokenStub.GetBalance.CallAsync(new GetBalanceInput
            {
                Owner  = Accounts[0].Address,
                Symbol = "ELF"
            });

            balance.Balance.ShouldBe(88000000000000000L);

            var electionStub = GetTester <ElectionContractContainer.ElectionContractStub>(
                contractMapping[ElectionSmartContractAddressNameProvider.Name], Accounts[0].KeyPair);
            var minerCount = await electionStub.GetMinersCount.CallAsync(new Empty());

            minerCount.Value.ShouldBe(1);
        }
Esempio n. 2
0
        private Address GetZeroContract()
        {
            if (_zeroAddress != null)
            {
                return(_zeroAddress);
            }

            _zeroAddress = ContractAddressService.GetZeroSmartContractAddress();
            return(_zeroAddress);
        }
        public async Task Test()
        {
            var preBlockHeader = await _blockchainService.GetBestChainLastBlockHeaderAsync();

            var chainContext = new ChainContext
            {
                BlockHash   = preBlockHeader.GetHash(),
                BlockHeight = preBlockHeader.Height
            };
            var contractMapping = await ContractAddressService.GetSystemContractNameToAddressMappingAsync(chainContext);

            var crossChainStub = GetTester <CrossChainContractContainer.CrossChainContractStub>(
                contractMapping[CrossChainSmartContractAddressNameProvider.Name], Accounts[0].KeyPair);
            var parentChainId = await crossChainStub.GetParentChainId.CallAsync(new Empty());

            ChainHelper.ConvertChainIdToBase58(parentChainId.Value).ShouldBe("AELF");
        }