protected override async Task ProcessParameters(TransactionOperation transaction, JsonElement param) { var(rawEp, rawParam) = (param.RequiredString("entrypoint"), Micheline.FromJson(param.Required("value"))); if (transaction.Target is Contract contract) { var schema = contract.Kind > ContractKind.DelegatorContract ? (await Cache.Schemas.GetAsync(contract)) : Script.ManagerTz; try { var(normEp, normParam) = schema.NormalizeParameter(rawEp, rawParam); transaction.Entrypoint = normEp; transaction.RawParameters = normParam.ToBytes(); transaction.JsonParameters = schema.HumanizeParameter(normEp, normParam); } catch (Exception ex) { transaction.Entrypoint ??= rawEp; transaction.RawParameters ??= rawParam.ToBytes(); if (transaction.Status == OperationStatus.Applied) { Logger.LogError($"Failed to humanize tx {transaction.OpHash} parameters: {ex.Message}"); } } } else { transaction.Entrypoint = rawEp; transaction.RawParameters = rawParam.ToBytes(); } }
public void Operations_are_executed_in_a_transaction() { var operation = new TransactionOperation(); var sut = new AtomicBehavior().AttachTo(operation); sut.Execute(); Assert.True(operation.ExecutedInTransaction); }
public void Transactions_are_not_committed_for_failed_operations() { var operation = new TransactionOperation { ThrowOnExecute = new Exception() }; var sut = new AtomicBehavior().AttachTo(operation); ExecuteIgnoringErrors(sut.Execute); Assert.False(operation.TransactionCommitted); }
public void Transactions_are_committed_for_successful_operations() { var operation = new TransactionOperation(); var sut = new AtomicBehavior().AttachTo(operation); sut.Execute(); Assert.True(operation.TransactionCommitted); }
public void InitUserObject() { transaction = new List <TransactionLogs>() { new TransactionLogs() { Amount = 200, IsIncome = true, UserId = 1 }, new TransactionLogs() { Amount = 100, IsIncome = false, UserId = 2 } }.AsQueryable(); users = new List <User>() { new User() { Login = "******", Password = "******", UserId = 1 }, new User() { Login = "******", Password = "******", UserId = 2 } }.AsQueryable(); mockSetUser = Substitute.For <DbSet <User>, IQueryable <User> >(); ((IQueryable <User>)mockSetUser).Provider.Returns(users.Provider); ((IQueryable <User>)mockSetUser).Expression.Returns(users.Expression); ((IQueryable <User>)mockSetUser).ElementType.Returns(users.ElementType); ((IQueryable <User>)mockSetUser).GetEnumerator().Returns(users.GetEnumerator()); mockSetTransaction = Substitute.For <DbSet <TransactionLogs>, IQueryable <TransactionLogs> >(); ((IQueryable <TransactionLogs>)mockSetTransaction).Provider.Returns(transaction.Provider); ((IQueryable <TransactionLogs>)mockSetTransaction).Expression.Returns(transaction.Expression); ((IQueryable <TransactionLogs>)mockSetTransaction).ElementType.Returns(transaction.ElementType); db = Substitute.For <IEFDbContext>(); db.transactionLogs.Returns(mockSetTransaction); db.users.Returns(mockSetUser); transactionOperations = new TransactionOperation(db); }
protected override IEnumerable <BigMapDiff> ParseBigMapDiffs(TransactionOperation transaction, JsonElement result) { if (!result.TryGetProperty("big_map_diff", out var diffs)) { return(null); } return(diffs.RequiredArray().EnumerateArray().Select(x => new UpdateDiff { Ptr = transaction.Target.Id, KeyHash = x.RequiredString("key_hash"), Key = Micheline.FromJson(x.Required("key")), Value = x.TryGetProperty("value", out var value) ? Micheline.FromJson(value) : null, }));
public static void Execute(Executor executor, OpenTransactionCommand openTransactionCommand) { var containsTransaction = executor.ProcessContext.Connection.ContainsItemInBag(BagNames.TRANSACTION); if (containsTransaction) { executor.HandleExecuteError(new Exception("Invalid open transaction!")); } var transaction = new TransactionOperation { }; executor.ProcessContext.Connection.SetItemInBag(BagNames.TRANSACTION, transaction); executor.ExecuteNextCommand(); }
public Operation CreateOperation(Guid logGuid, TransactionOperation transactionOperation, IOperationProvider operationProvider) { Operation operation = null; if (operationProvider != null) { OperationProvider = operationProvider; } else { throw new ArgumentException("Provider cann't be null"); } switch (transactionOperation) { case TransactionOperation.CheckPayment: operation = new CheckOperation(logGuid, OperationProvider); break; case TransactionOperation.IPayment: operation = new IPaymentOperation(logGuid, OperationProvider); break; case TransactionOperation.ICommit: operation = new ICommitOperation(logGuid, OperationProvider); break; case TransactionOperation.Cancel: operation = new CancelOperation(logGuid, OperationProvider); break; default: string msg = $"TransactionOperation {OperationProvider} not supported"; Logger.WriteLoggerError(msg); throw new ArgumentOutOfRangeException(msg); } return(operation); }
protected override Task ResetGracePeriod(TransactionOperation transaction) => Task.CompletedTask;
public TransactionInformation(System.Deployment.Internal.Isolation.StoreTransactionOperation[] storeOperations, uint[] rgDispositions, int[] rgResults, DateTime time) : base(null, time) { this._operations = new ArrayList(); int num = Math.Min(Math.Min(storeOperations.Length, rgDispositions.Length), rgResults.Length); int index = 0; for (index = 0; index < num; index++) { TransactionOperation operation = new TransactionOperation(storeOperations[index], rgDispositions[index], rgResults[index]); this._operations.Add(operation); if (operation.Failed) { this._failed = true; } } }
public void cleanUpTest() { transaction = null; transactionOperations = null; mockSetTransaction = null; }
protected override IEnumerable <BigMapDiff> ParseBigMapDiffs(TransactionOperation transaction, JsonElement result) { return(result.TryGetProperty("big_map_diff", out var diffs) ? diffs.RequiredArray().EnumerateArray().Select(BigMapDiff.Parse) : null); }
protected override IMicheline NormalizeStorage(TransactionOperation transaction, IMicheline storage, Netezos.Contracts.ContractScript schema) { return(storage); }
public TransactionType AddRule(PositionType positionType, TransactionOperation operation) { TransactionRules.Add(new TransactionRuleType(positionType, operation)); return(this); }
public TransactionRuleType(PositionType posititonType, TransactionOperation operation) { PositionTypeName = posititonType.PropertyName; TransactionOperation = operation; }