private void ExecuteTransaction(IServerCallHandler handler) { try { var tx = CurrentTransactionContext.Transaction; var retVal = handler.Execute(tx.Params.ToByteArray()); if (retVal != null) { CurrentTransactionContext.Trace.ReturnValue = ByteString.CopyFrom(retVal); CurrentTransactionContext.Trace.ReadableReturnValue = handler.ReturnBytesToString(retVal); } CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.Executed; } catch (TargetInvocationException ex) { CurrentTransactionContext.Trace.Error += ex; CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError; } catch (AssertionException ex) { CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError; CurrentTransactionContext.Trace.Error += "\n" + ex; } catch (Exception ex) { // TODO: Simplify exception CurrentTransactionContext.Trace.ExecutionStatus = ExecutionStatus.ContractError; CurrentTransactionContext.Trace.Error += "\n" + ex; } }
public void ReturnBytesToString_Test() { var output = new StringOutput() { StringValue = "test-out" }; var objString = _callHandler.ReturnBytesToString(output.ToByteArray()); objString.ShouldNotBeNullOrEmpty(); objString.Contains("test-out").ShouldBeTrue(); }