Esempio n. 1
0
        public async void ShouldIssueTokens()
        {
            var donor = "0x6C547791C3573c2093d81b919350DB1094707011";
            //Using ropsten infura if wanted for only a tests
            //var web3 = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Ropsten);
            var web3 = _ethereumClientIntegrationFixture.GetWeb3();

            var erc20TokenDeployment = new ERC20TokenDeployment()
            {
                DecimalUnits = 18, TokenName = "Homeless", TokenSymbol = "Homeless"
            };

            //Deploy our custom token
            var tokenDeploymentReceipt = await ERC20TokenService.DeployContractAndWaitForReceiptAsync(web3, erc20TokenDeployment);

            //Creating a new service
            var tokenService = new ERC20TokenService(web3, tokenDeploymentReceipt.ContractAddress);

            var donorIssuance = new DonorIssuance()
            {
                Donor           = donor,
                Value           = Web3.Convert.ToWei(10),
                TxnHashDonation = "0x30912b7fa14ccf619f8cfbff4ada42aabbccaa0d6373ffdbe0f0b509ac8883d9".HexToByteArray()
            };

            var issueTokensReceipt = await tokenService.IssueTokenToDonorRequestAndWaitForReceiptAsync(new List <DonorIssuance> {
                donorIssuance
            });

            //validate the current balance
            var balance = await tokenService.BalanceOfQueryAsync(donor);

            Assert.Equal(10, Web3.Convert.FromWei(balance));

            //retrieving the event from the receipt
            var eventTransfer = issueTokensReceipt.DecodeAllEvents <IssueToDonorEventDTO>()[0];

            Assert.Equal(10, Web3.Convert.FromWei(eventTransfer.Event.Value));
            Assert.True(donor.IsTheSameAddress(eventTransfer.Event.Donor));
            Assert.True(donorIssuance.TxnHashDonation.ToHex().IsTheSameHex(eventTransfer.Event.TxnHash.ToHex()));
        }
Esempio n. 2
0
        public async void ShouldTransferAsUsual()
        {
            var donor = EthereumClientIntegrationFixture.AccountAddress; // we are the donors
            //Using ropsten infura if wanted for only a tests
            //var web3 = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Ropsten);
            var web3 = _ethereumClientIntegrationFixture.GetWeb3();

            var erc20TokenDeployment = new ERC20TokenDeployment()
            {
                DecimalUnits = 18, TokenName = "Homeless", TokenSymbol = "Homeless"
            };

            //Deploy our custom token
            var tokenDeploymentReceipt = await ERC20TokenService.DeployContractAndWaitForReceiptAsync(web3, erc20TokenDeployment);

            //Creating a new service
            var tokenService = new ERC20TokenService(web3, tokenDeploymentReceipt.ContractAddress);

            var donorIssuance = new DonorIssuance()
            {
                Donor           = donor,
                Value           = Web3.Convert.ToWei(10),
                TxnHashDonation = "0x30912b7fa14ccf619f8cfbff4ada42aabbccaa0d6373ffdbe0f0b509ac8883d9".HexToByteArray()
            };

            var issueTokensReceipt = await tokenService.IssueTokenToDonorRequestAndWaitForReceiptAsync(new List <DonorIssuance> {
                donorIssuance
            });

            //validate the current balance
            var balance = await tokenService.BalanceOfQueryAsync(donor);

            Assert.Equal(10, Web3.Convert.FromWei(balance));


            var transferToken = await tokenService.TransferRequestAndWaitForReceiptAsync("0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe", Web3.Convert.ToWei(1));

            balance = await tokenService.BalanceOfQueryAsync(donor);

            Assert.Equal(9, Web3.Convert.FromWei(balance));
        }