public async Task Simulation_Originate() { var monitor = ConnectIdentity("IdentityID"); simulation.SetBalance("IdentityID", 100); var task = new CreateContractTask { ManagerID = "IdentityID", SourceID = "IdentityID", Name = "Identity", TransferAmount = TransferAmount, NetworkFee = NetworkFee, StorageFee = StorageFee, ServiceFee = ServiceFee, }; task = simulation.PrepareCreateContract(task); await simulation.Hub.WhenPendingSent; monitor.AssertCount(0); task = simulation.CreateContract(task, "InstanceID"); await simulation.Hub.WhenPendingSent; monitor.AssertCount(2); var transferPending = monitor.Single <TransactionPendingEvent>(); Assert.AreEqual( -task.TotalAmount, transferPending.Amount ); var originatePending = monitor.Single <OriginatePendingEvent>(); Assert.AreEqual( task.TransferAmount, originatePending.Amount ); monitor.Clear(); simulation.CreateBlock(); await simulation.Hub.WhenPendingSent; monitor.AssertCount(2); // Source var balanceChanged = monitor.Single <BalanceChangedEvent>(); var expectedBalance = StartBalance - task.TotalAmount; Assert.AreEqual(expectedBalance, balanceChanged.Balance); var entry = balanceChanged.Entry; Assert.IsNotNull(entry); // Destination var originate = monitor.Single <OriginateEvent>(); Assert.AreEqual( task.TransferAmount, originate.Balance ); entry = originate.Entry; Assert.IsNotNull(entry); }
public async Task <CreateContractTask> PrepareCreateContract(CreateContractTask task) { await CallService(); return(simulation.PrepareCreateContract(PrepareTask(task))); }