示例#1
0
        public void UnpackPackedMessageWithMultipleRecipientsSucceeds()
        {
            ICrypto     crypto     = IndyDotNet.Crypto.Factory.GetCrypto(_wallet);
            List <IDid> recipients = new List <IDid>();

            IdentitySeed seed = new IdentitySeed()
            {
                Seed = "00000000000000000000000000000My2"
            };

            recipients.Add(IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed));

            seed = new IdentitySeed()
            {
                Seed = "00000000000000000000000000000My3"
            };
            recipients.Add(IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed));


            PackedMessage   packedMessage   = crypto.PackMessage(recipients, _senderDid, MESSAGE_TO_SEND);
            UnpackedMessage unpackedMessage = crypto.UnpackMessage(packedMessage);

            Assert.IsNotNull(unpackedMessage, $"did not get back an unpacked message");
            Assert.AreEqual(MESSAGE_TO_SEND, unpackedMessage.Message, "unpacked message is not the same as what was sent");
        }
示例#2
0
        public void Roundtrip()
        {
            Console.WriteLine("Starting...");
            var client = new MemoryClient();
            var passed = false;
            var pager  = new PagedClient(client, "test");

            using (var s = new CancellationTokenSource(TimeSpan.FromSeconds(10))) {
                var unpackedMessage = new UnpackedMessage(GetBytes(Constants.MaxKeySize),
                                                          GetBytes(Constants.MaxValueSize * 5 + 1));
                Console.WriteLine("Pub...");
                pager.Publish(new[] { unpackedMessage }).Wait(s.Token);
                Console.WriteLine("Waiting...");

                pager.ChaseEventsForever(s.Token, (id, subscription) => {
                    CollectionAssert.AreEqual(unpackedMessage.Value, id.Value);
                    CollectionAssert.AreEqual(unpackedMessage.Key, id.Key);
                    passed = true;
                    Console.WriteLine("Got it" + id);
                    s.Cancel();
                });
            }

            if (!passed)
            {
                Assert.Fail("Failed");
            }
        }
示例#3
0
        public void UnpackPackedMessageSucceeds()
        {
            ICrypto         crypto          = IndyDotNet.Crypto.Factory.GetCrypto(_wallet);
            PackedMessage   packedMessage   = crypto.PackMessage(_senderDid, _senderDid, MESSAGE_TO_SEND);
            UnpackedMessage unpackedMessage = crypto.UnpackMessage(packedMessage);

            Assert.IsNotNull(unpackedMessage, $"did not get back an unpacked message");
            Assert.AreEqual(MESSAGE_TO_SEND, unpackedMessage.Message, "unpacked message is not the same as what was sent");
        }
 public static void OverrideContext(UnpackedMessage message)
 {
     if (message == null) throw new ArgumentNullException("message");
     _current = message;
 }
 /// <summary>
 /// Clears the context.
 /// </summary>
 public static void ClearContext()
 {
     _current = null;
 }