public void EnqueueTime_Test()
        {
            var testQueueName   = "TestQueue";
            var testEnqueueTime = TimestampHelper.GetUtcNow();

            var enqueueTime = _blockSyncStateProvider.GetEnqueueTime(testQueueName);

            enqueueTime.ShouldBeNull();

            _blockSyncStateProvider.SetEnqueueTime(testQueueName, testEnqueueTime);

            enqueueTime = _blockSyncStateProvider.GetEnqueueTime(testQueueName);
            enqueueTime.ShouldBe(testEnqueueTime);
        }
예제 #2
0
        public bool ValidateQueueAvailability(string queueName)
        {
            bool isAvailable;
            var  enqueueTime = _blockSyncStateProvider.GetEnqueueTime(queueName);

            switch (queueName)
            {
            case OSConstants.BlockFetchQueueName:
                isAvailable = CheckAgeLimit(enqueueTime, BlockSyncConstants.BlockSyncFetchBlockAgeLimit);
                break;

            case OSConstants.BlockSyncAttachQueueName:
                isAvailable = CheckAgeLimit(enqueueTime, BlockSyncConstants.BlockSyncAttachBlockAgeLimit);
                break;

            case KernelConstants.UpdateChainQueueName:
                isAvailable = CheckAgeLimit(enqueueTime, BlockSyncConstants.BlockSyncAttachAndExecuteBlockAgeLimit);
                break;

            default:
                throw new InvalidOperationException($"invalid queue name: {queueName}");
            }

            return(isAvailable);
        }
        public void Enqueue_Test()
        {
            var result = false;

            _blockSyncQueueService.Enqueue(() =>
            {
                result = true;
                return(Task.CompletedTask);
            }, OSConstants.BlockFetchQueueName);

            result.ShouldBeTrue();

            _blockSyncStateProvider.GetEnqueueTime(OSConstants.BlockFetchQueueName).ShouldBeNull();
        }