Esempio n. 1
0
 public void CreateApiClientInstance()
 {
     _iotaAPI = new IotaAPI()
     {
         IotaClient = new IotaClient("https://nodes.devnet.iota.org:443")
     };
 }
Esempio n. 2
0
        public void PublishPublicTest()
        {
            var iota = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };
            var mam = new Mam(iota);
            string seed = "CNHIRWBWVPDBGHKYZDJEZVIRDBSEDTCRBESFXOGRSWWDQVRNQATQUKIVDUDINJKKNCULQFCWWIG9LAEHQ";

            // ReSharper disable once RedundantArgumentDefaultValue
            var mamState = mam.InitMamState(seed, 2);
            
            // Create MAM Payload
            var mamMessage = mam.CreateMamMessage(mamState, TrytesConverter.AsciiToTrytes("POTATO"));

            Console.WriteLine($"Root: {mamMessage.Root}");
            Console.WriteLine($"Address: {mamMessage.Address}");

            // Attach the payload
            mam.Attach(mamMessage.Payload, mamMessage.Address);

            // Fetch Stream Async to Test
            var result = mam.Fetch(mamMessage.Root, MamMode.Public);

            Console.WriteLine("Fetch result:");
            foreach (var message in result.Item1)
            {
                Console.WriteLine(message);
            }

            Console.WriteLine($"NextRoot:{result.Item2}");

        }
Esempio n. 3
0
        public void PublishRestrictedTest()
        {
            var iota = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };
            var mam = new Mam(iota);
            string sideKey = "IREALLYENJOYPOTATORELATEDPRODUCTS";

            // Initialise MAM State
            var mamState = mam.InitMamState();
            mamState.ChangeMode(MamMode.Restricted, sideKey);

            // Create MAM Payload
            var mamMessage = mam.CreateMamMessage(mamState, "POTATO");

            Console.WriteLine($"Root: {mamMessage.Root}");
            Console.WriteLine($"Address: {mamMessage.Address}");

            // Attach the payload
            mam.Attach(mamMessage.Payload, mamMessage.Address);

            // Fetch Stream Async to Test
            var result = mam.Fetch(mamMessage.Root, MamMode.Restricted, sideKey);

            Console.WriteLine("Fetch result:");
            foreach (var message in result.Item1)
            {
                Console.WriteLine(message);
            }

            Console.WriteLine($"NextRoot:{result.Item2}");
        }
Esempio n. 4
0
        public void SingleLeafTree()
        {
            var iota = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };
            var mam = new Mam(iota);
            string seed = "TX9XRR9SRCOBMTYDTMKNEIJCSZIMEUPWCNLC9DPDZKKAEMEFVSTEVUFTRUZXEHLULEIYJIEOWIC9STAHW";
            string message = "POTATO";

            var mamState = mam.InitMamState(seed, 1);
            mamState.Channel.Security = 1;
            mamState.Channel.Start = 0;
            mamState.Channel.Count = 1;
            mamState.Channel.NextCount = 1;

            var mamMessage = mam.CreateMamMessage(mamState, message);

            // parse
            var unmaskedMessage =
                mam.DecodeMessage(mamMessage.Payload,
                    mamMessage.State.Channel.SideKey,
                    mamMessage.Root);

            // compare
            Assert.AreEqual(message, unmaskedMessage.Item1);
        }
Esempio n. 5
0
 public void CreateProxyInstance()
 {
     _iotaApi = new IotaAPI()
     {
         IotaClient = new IotaClient(DevNetProvider),
         LocalPoW   = new PearlDiverLocalPoW()
     };
 }
Esempio n. 6
0
        public void ShouldFailBeforeSnapshotTimeStamp()
        {
            var iotaApi = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };

            Assert.ThrowsException <ArgumentException>(() => { iotaApi.BroadcastAndStore(TEST_TRYTES); },
                                                       "Transaction did not fail on old timestamp value");
        }
Esempio n. 7
0
        public void ShouldReplayBundle()
        {
            var iotaApi = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };

            ReplayBundleResponse rbr = iotaApi.ReplayBundle(TEST_HASH, DEPTH, MIN_WEIGHT_MAGNITUDE, null);

            Assert.IsNotNull(rbr, "Bundle should be replayed");
        }
Esempio n. 8
0
        public void ShouldGetBundle()
        {
            var iotaApi = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };

            GetBundleResponse gbr = iotaApi.GetBundle(TEST_HASH);

            Assert.IsNotNull(gbr, "GetBundleResponse should not return null on failure");
        }
        public void CreateProxyInstance()
        {
            _iotaClient = new IotaClient("https://nodes.devnet.thetangle.org:443");
            _localPoW   = new PearlDiverLocalPoW();

            _iotaApi = new IotaAPI()
            {
                IotaClient = _iotaClient,
                LocalPoW   = _localPoW
            };
        }
Esempio n. 10
0
        public void ShouldGetTransfers()
        {
            var iotaApi = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };

            GetTransferResponse gtr = iotaApi.GetTransfers(TEST_SEED3, 2, 0, 10, false);

            Assert.IsNotNull(gtr.TransferBundles, "GetTransfers should return GetTransferResponse object on success");
            Assert.IsTrue(gtr.TransferBundles.Length > 0, "GetTransfers should return more than 0 transfers");
        }
Esempio n. 11
0
        public void ShouldGetLastInclusionState()
        {
            var iotaApi = new IotaAPI
            {
                IotaClient = new IotaClient(Provider)
            };

            GetInclusionStatesResponse res = iotaApi.GetLatestInclusion(new[]
            {
                TEST_HASH
            });

            Assert.IsNotNull(res.States, "States should be an array of booleans");
            Assert.IsTrue(res.States[0], "Hash should have been seen as confirmed");
        }
Esempio n. 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="iota"></param>
 public Mam(IotaAPI iota)
 {
     Iota = iota;
 }