mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 06:41:50 +01:00
test & fix
This commit is contained in:
parent
af6dcec8f7
commit
d2c2f8d657
@ -188,5 +188,11 @@ namespace Capnp.Net.Runtime.Tests
|
||||
{
|
||||
NewDtbdctTestbed().RunTest(Testsuite.CallAfterFinish2);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LegacyAccess()
|
||||
{
|
||||
NewDtbdctTestbed().RunTest(Testsuite.LegacyAccess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -395,6 +395,44 @@ namespace Capnp.Net.Runtime.Tests
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void InterceptClientSideModifyPipelinedCall()
|
||||
{
|
||||
var policy = new MyPolicy("a");
|
||||
|
||||
(var server, var client) = SetupClientServerPair();
|
||||
|
||||
using (server)
|
||||
using (client)
|
||||
{
|
||||
var counters = new Counters();
|
||||
var impl = new TestMoreStuffImpl(counters);
|
||||
server.Main = impl;
|
||||
using (var main = policy.Attach(client.GetMain<ITestMoreStuff>()))
|
||||
{
|
||||
var req = main.GetNull().Eager().GetCallSequence(0);
|
||||
Assert.IsTrue(policy.Calls.TryReceive(out var ccGetNull));
|
||||
Assert.IsTrue(policy.Calls.TryReceive(out var ccGetCallSequence));
|
||||
|
||||
ccGetNull.ForwardToBob();
|
||||
|
||||
Assert.IsTrue(policy.Returns.ReceiveAsync().Wait(MediumNonDbgTimeout));
|
||||
|
||||
ccGetNull.ReturnToAlice();
|
||||
|
||||
ccGetCallSequence.Bob = Proxy.Share<ITestMoreStuff>(impl);
|
||||
ccGetCallSequence.ForwardToBob();
|
||||
|
||||
Assert.IsTrue(policy.Returns.ReceiveAsync().Wait(MediumNonDbgTimeout));
|
||||
|
||||
ccGetCallSequence.ReturnToAlice();
|
||||
|
||||
Assert.IsTrue(req.IsCompleted && !req.IsFaulted && !req.IsCanceled);
|
||||
Assert.AreEqual(0u, req.Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void InterfaceAndMethodId()
|
||||
{
|
||||
|
@ -140,6 +140,12 @@ namespace Capnp.Net.Runtime.Tests
|
||||
NewLocalTestbed().RunTest(Testsuite.Ownership3);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void LegacyAccess()
|
||||
{
|
||||
NewLocalTestbed().RunTest(Testsuite.LegacyAccess);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void EagerRace()
|
||||
{
|
||||
|
@ -855,5 +855,23 @@ namespace Capnp.Net.Runtime.Tests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void LegacyAccess(ITestbed testbed)
|
||||
{
|
||||
var impl = new TestMoreStuffImpl(new Counters());
|
||||
using (var main = testbed.ConnectMain<ITestMoreStuff>(impl))
|
||||
{
|
||||
var task = main.Echo(new TestCallOrderImpl());
|
||||
var answer = Impatient.TryGetAnswer(task);
|
||||
Assert.IsNotNull(answer);
|
||||
var cap = answer.Access(new MemberAccessPath(0));
|
||||
using (var proxy = (ITestCallOrder)CapabilityReflection.CreateProxy<ITestCallOrder>(cap))
|
||||
{
|
||||
var seq = proxy.GetCallSequence(0);
|
||||
testbed.MustComplete(seq);
|
||||
Assert.AreEqual(0u, seq.Result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
@ -160,9 +161,12 @@ namespace Capnp
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException)
|
||||
catch (Exception exception) when (exception is EndOfStreamException ||
|
||||
exception is IOException ioex &&
|
||||
ioex.InnerException is SocketException sockex &&
|
||||
sockex.SocketErrorCode == SocketError.Interrupted)
|
||||
{
|
||||
Logger.LogWarning("Encountered End of Stream");
|
||||
Logger.LogInformation("Encountered end of stream");
|
||||
}
|
||||
catch (InvalidDataException e)
|
||||
{
|
||||
|
@ -27,13 +27,13 @@ namespace Capnp.Rpc.Interception
|
||||
|
||||
public ConsumedCapability Access(MemberAccessPath access)
|
||||
{
|
||||
return new LocalAnswerCapability(_futureResult.Task, access);
|
||||
return _callContext._censorCapability.Policy.Attach<ConsumedCapability>(new LocalAnswerCapability(_futureResult.Task, access));
|
||||
}
|
||||
|
||||
public ConsumedCapability Access(MemberAccessPath _, Task<IDisposable?> task)
|
||||
{
|
||||
var proxyTask = task.AsProxyTask();
|
||||
return new LocalAnswerCapability(proxyTask);
|
||||
return _callContext._censorCapability.Policy.Attach<ConsumedCapability>(new LocalAnswerCapability(proxyTask));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
Loading…
x
Reference in New Issue
Block a user