Beispiel #1
0
        public async Task EconomicSystem_ChargeMethodTransactionFee_MultipleSymbol_Test()
        {
            var feeAmount = await EconomistSystem_SetMethodTransactionFee_MultipleSymbol_Test();

            var chosenOneKeyPair = CoreDataCenterKeyPairs.First();
            var chosenOneAddress = Address.FromPublicKey(chosenOneKeyPair.PublicKey);
            {
                var balance = await TokenContractStub.GetBalance.CallAsync(new GetBalanceInput
                {
                    Owner  = chosenOneAddress,
                    Symbol = EconomicSystemTestConstants.TransactionFeeChargingContractTokenSymbol
                });

                balance.Balance.ShouldBe(0);
            }

            // The chosen one decide to buy some TFCC tokens.
            var chosenOneTokenContractStub =
                GetTester <TokenContractContainer.TokenContractStub>(TokenContractAddress, chosenOneKeyPair);
            await chosenOneTokenContractStub.Approve.SendAsync(new ApproveInput
            {
                Spender = TokenConverterContractAddress,
                Symbol  = EconomicSystemTestConstants.NativeTokenSymbol,
                Amount  = 100_000_00000000// Enough,
            });
Beispiel #2
0
        public async Task EconomicSystem_ChargeMethodTransactionFeeEvenExecutionFailed()
        {
            const long feeAmount = 10L;
            await TransactionFeeChargingContractStub.SetMethodFee.SendAsync(new MethodFees
            {
                MethodName = nameof(TransactionFeeChargingContractStub.SupposedToFail),
                Fees       =
                {
                    new MethodFee {
                        Symbol = EconomicSystemTestConstants.NativeTokenSymbol, BasicFee = feeAmount
                    }
                }
            });

            var chosenOneKeyPair = CoreDataCenterKeyPairs.First();
            var chosenOneAddress = Address.FromPublicKey(chosenOneKeyPair.PublicKey);
            var balanceBefore    = await TokenContractStub.GetBalance.CallAsync(new GetBalanceInput
            {
                Owner  = chosenOneAddress,
                Symbol = EconomicSystemTestConstants.NativeTokenSymbol
            });

            var tycoon            = GetTransactionFeeChargingContractTester(chosenOneKeyPair);
            var transactionResult = await tycoon.SupposedToFail.SendAsync(new Empty());

            transactionResult.TransactionResult.Status.ShouldBe(TransactionResultStatus.Failed);
            var balanceAfter = await TokenContractStub.GetBalance.CallAsync(new GetBalanceInput
            {
                Owner  = chosenOneAddress,
                Symbol = EconomicSystemTestConstants.NativeTokenSymbol
            });

            balanceAfter.Balance.ShouldBe(balanceBefore.Balance - feeAmount);
        }
Beispiel #3
0
        public async Task EconomistSystem_ChargeMethodTransactionFee_Test()
        {
            await EconomistSystem_SetMethodTransactionFee_Test();

            var chosenOneKeyPair = CoreDataCenterKeyPairs.First();
            var chosenOneAddress = Address.FromPublicKey(chosenOneKeyPair.PublicKey);
            var balanceBefore    = await TokenContractStub.GetBalance.CallAsync(new GetBalanceInput
            {
                Owner  = chosenOneAddress,
                Symbol = EconomicSystemTestConstants.NativeTokenSymbol
            });

            var tycoon = GetTransactionFeeChargingContractTester(chosenOneKeyPair);
            await tycoon.SendForFun.SendAsync(new Empty());

            var balanceAfter = await TokenContractStub.GetBalance.CallAsync(new GetBalanceInput
            {
                Owner  = chosenOneAddress,
                Symbol = EconomicSystemTestConstants.NativeTokenSymbol
            });

            balanceAfter.Balance.ShouldBeLessThan(balanceBefore.Balance);
        }