public void Cannot_mark_as_failed_when_actions_stacked() { ParityLikeTxTracer tracer = new ParityLikeTxTracer(Build.A.Block.TestObject, Build.A.Transaction.TestObject, ParityTraceTypes.All); tracer.ReportAction(1000L, 10, Address.Zero, Address.Zero, Bytes.Empty, ExecutionType.Call, false); Assert.Throws <InvalidOperationException>(() => tracer.MarkAsFailed(TestItem.AddressA, 21000, Bytes.Empty, "Error")); }
public void Cannot_mark_as_success_when_actions_stacked() { ParityLikeTxTracer tracer = new ParityLikeTxTracer(Build.A.Block.TestObject, Build.A.Transaction.TestObject, ParityTraceTypes.All); tracer.ReportAction(1000L, 10, Address.Zero, Address.Zero, Array.Empty <byte>(), ExecutionType.Call, false); Assert.Throws <InvalidOperationException>(() => tracer.MarkAsSuccess(TestItem.AddressA, 21000, Array.Empty <byte>(), new LogEntry[] { })); }
public void Throw_operation_canceled_after_given_timeout() { var timeout = TimeSpan.FromMilliseconds(100); Transaction transactionMock = Substitute.For <Transaction>(); ParityTraceTypes type = ParityTraceTypes.Trace; Address address = new Address(new byte[] { 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1 }); CancellationToken cancellationToken = new CancellationTokenSource(timeout).Token; ParityLikeTxTracer tracer = new ParityLikeTxTracer(_blockTree.Head, transactionMock, type, cancellationToken); Thread.Sleep(timeout.Add(TimeSpan.FromMilliseconds(100))); Assert.Throws <OperationCanceledException>(() => tracer.StartOperation(0, 0, default(Instruction), 0)); Assert.Throws <OperationCanceledException>(() => tracer.ReportAction(0, 0, address, address, new byte[] { 0, 0, 0 }, ExecutionType.Transaction)); Assert.Throws <OperationCanceledException>(() => tracer.ReportAction(0, 0, address, address, new byte[] { 0, 0, 0 }, ExecutionType.Transaction)); Assert.Throws <OperationCanceledException>(() => tracer.ReportSelfDestruct(address, 0, address)); Assert.Throws <OperationCanceledException>(() => tracer.ReportStackPush(null)); }