public async Task ListStreamTxItemsTestAsync()
        {
            // Stage
            var txid = await _wallet.PublishAsync("root", ChainEntity.GetUUID(), "Some Stream Item Data".ToHex(), "");

            /*
             * Explicit blockchain name test
             */

            // Act
            var expActual = await _wallet.ListStreamTxItemsAsync(_chainName, UUID.NoHyphens, "root", txid.Result, true);

            // Assert
            Assert.IsTrue(expActual.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <IList <object> > >(expActual);

            /*
             * Inferred blockchain name test
             */

            // Act
            var infActual = await _wallet.ListStreamTxItemsAsync("root", txid.Result, true);

            // Assert
            Assert.IsTrue(infActual.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <IList <object> > >(infActual);
        }
Example #2
0
        public async Task GetStreamKeySummaryTestAsync()
        {
            // Stage
            var streamKey = ChainEntity.GetUUID();
            await _wallet.PublishFromAsync(_address, "root", streamKey, "Stream item data".ToHex(), "");

            /*
             * Explicit blockchain name test
             */

            // Act
            var expActual = await _wallet.GetStreamKeySummaryAsync(_chainName, UUID.NoHyphens, "root", streamKey, "jsonobjectmerge,ignore,recursive");

            // Assert
            Assert.IsTrue(expActual.IsSuccess());
            Assert.IsInstanceOf <RpcResponse>(expActual);

            /*
             * Inferred blockchain name test
             */

            // Act
            var infActual = await _wallet.GetStreamKeySummaryAsync("root", streamKey, "jsonobjectmerge,ignore,recursive");

            // Assert
            Assert.IsTrue(infActual.IsSuccess());
            Assert.IsInstanceOf <RpcResponse>(infActual);
        }
Example #3
0
        public async Task GetWalletTransactionTestAsync()
        {
            // Stage
            var publish = await _wallet.PublishFromAsync(_address, "root", ChainEntity.GetUUID(), "Stream item data".ToHex(), "");

            /*
             * Explicit blockchain name test
             */

            // Act
            var expActual = await _wallet.GetWalletTransactionAsync(_chainName, UUID.NoHyphens, publish.Result, true, true);

            // Assert
            Assert.IsTrue(expActual.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <GetWalletTransactionResult> >(expActual);

            /*
             * Inferred blockchain name test
             */

            // Act
            var infActual = await _wallet.GetWalletTransactionAsync(publish.Result, true, true);

            // Assert
            Assert.IsTrue(infActual.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <GetWalletTransactionResult> >(infActual);
        }
        public async Task TxOutToBinaryCacheTestAsync()
        {
            /*
             * Explicit blockchain name test
             */

            // Stage
            var expBinaryCache = await _utility.CreateBinaryCacheAsync(_chainName, UUID.NoHyphens);

            var expPublish = await _wallet.PublishFromAsync(_chainName, UUID.NoHyphens, _address, "root", ChainEntity.GetUUID(), "A bunch of text data that will be transcribed to this this publish event and this one is async brotato chip".ToHex(), "");

            var expTransaction = await _wallet.GetAddressTransactionAsync(_chainName, UUID.NoHyphens, _address, expPublish.Result, true);

            // Act
            var exp = await _wallet.TxOutToBinaryCacheAsync(_chainName, UUID.NoHyphens, expBinaryCache.Result, expTransaction.Result.Txid, expTransaction.Result.Vout[0].N, 100000, 0);

            // Clean-up
            await _utility.DeleteBinaryCacheAsync(_chainName, UUID.NoHyphens, expBinaryCache.Result);

            // Assert
            Assert.IsTrue(exp.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <double> >(exp);

            /*
             * Inferred blockchain name test
             */

            // Stage
            var infBinaryCache = await _utility.CreateBinaryCacheAsync();

            var infPublish = await _wallet.PublishFromAsync(_address, "root", ChainEntity.GetUUID(), "A bunch of text data that will be transcribed to this this publish event and this one is async brotato chip".ToHex(), "");

            var infTransaction = await _wallet.GetAddressTransactionAsync(_address, infPublish.Result, true);

            // Act
            var inf = await _wallet.TxOutToBinaryCacheAsync(infBinaryCache.Result, infTransaction.Result.Txid, infTransaction.Result.Vout[0].N, 100000, 0);

            // Clean-up
            await _utility.DeleteBinaryCacheAsync(infBinaryCache.Result);

            // Assert
            Assert.IsTrue(inf.IsSuccess());
            Assert.IsInstanceOf <RpcResponse <double> >(inf);
        }
Example #5
0
        /// <summary>
        /// Given an entry it will check to see if the entry needs to be automatically moved onto the next state.
        /// </summary>
        /// <param name="entry">The entry to check</param>
        /// <param name="chain">The chain instance the entry belongs too.</param>
        /// <param name="saveChanges">If true any entry entity changes to state will be saved to the database.
        /// Set this to false if you are going to call SaveChanges on the db context yourself.</param>
        /// <returns>Returns true if the entryEntity state has changed.</returns>
        private async Task <bool> ProcessEntryStateAsync(EntryEntity entry, ChainEntity chain, bool saveChanges)
        {
            // get entry
            // get the event its in
            // is the event a timed event? if so does the entry need to move on?
            var currentEvent = await _context.Events.FirstAsync(x => x.Id == entry.State);

            if (currentEvent.TransitionType == TransitionType.Timed &&
                currentEvent.ManualAdvance == false) // if manual advance is false then we can try and move it.
            {
                var datetimeNow = DateTime.UtcNow;

                if (currentEvent.EndDate < datetimeNow) // the event it sits in now has expired...
                {
                    // then if valid this entry should move on to the next event state.
                    // first check the pass round
                    var successeventId = chain.SuccessEvent ?? 0;
                    var faileventId    = chain.FailEvent ?? 0;

                    // CHECK IF ITS A MODERATE EVENT TYPE THE ENTRY IS CURRENTLY IN THEN IT NEEDS TO EITHER STAY WHERE IT IS
                    // OR MOVE TO THE FALSE EVENT.
                    // CUSTOM EVENTS CAN ONLY BE MOVED MANUALLY BY CALLING ADVANCE OR UPDATING ENTRIES MANUALLY.
                    // CURRENTLY ALL OTHER EVENTS ARE ACTION ONLY SO ARE NOT AFFECTED BY THIS.

                    if (currentEvent.Type == EventType.Moderate)
                    {
                        // then move to false event.. or keep where it is
                        var ok = await ValidateMove(entry, faileventId);

                        if (ok)
                        {
                            entry.State = faileventId;
                            if (saveChanges)
                            {
                                await _context.SaveChangesAsync();
                            }
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }