Ejemplo n.º 1
0
        public async Task DecodesEventFromAbi()
        {
            var subscription = CreateMockSubscription(out List <DecodedEvent> eventsHandled);
            var mockEventHandlerHistoryDb = CreateMockHistoryDb(out _);

            var coordinator = new EventHandlerManager(
                mockEventHandlerHistoryDb.Object);

            var logs = new[] { TestContract.SampleTransferLog() };
            await coordinator.HandleAsync(subscription, new[] { TestContract.TransferEventAbi }, logs);

            Assert.Single(eventsHandled);
        }
Ejemplo n.º 2
0
        public async Task IgnoresEventsWithInvalidNumberOfIndexes()
        {
            var subscription = CreateMockSubscription(out List <DecodedEvent> eventsHandled);

            var mockEventHandlerHistoryDb = CreateMockHistoryDb(out List <IEventHandlerHistoryDto> history);

            var coordinator = new EventHandlerManager(
                mockEventHandlerHistoryDb.Object);

            var log = TestContract.SampleTransferLog();

            // deliberately make topic count inconsistent with abi
            log.Topics = log.Topics.Take(log.Topics.Length - 1).ToArray();
            var logs = new[] { log };

            var eventAbi = TestContract.TransferEventAbi;

            await coordinator.HandleAsync(subscription, new[] { eventAbi }, logs);

            Assert.Empty(eventsHandled);
        }
Ejemplo n.º 3
0
        public async Task WithMultipleAbis_DecodesToFirstMatchingAbi()
        {
            var subscription = CreateMockSubscription(out List <DecodedEvent> eventsHandled);
            var mockEventHandlerHistoryDb = CreateMockHistoryDb(out _);

            var coordinator = new EventHandlerManager(
                mockEventHandlerHistoryDb.Object);

            var logs = new[] { TestContract.SampleTransferLog() };

            var abis = new[] {
                TestContract.ApprovalEventAbi,
                TestContract.TransferEventAbi
            };

            await coordinator.HandleAsync(subscription, abis, logs);

            Assert.Single(eventsHandled);
            Assert.Equal(
                TestContract.TransferEventAbi.InputParameters.Length,
                eventsHandled[0].Event.Count);
        }