Ejemplo n.º 1
0
        public void MatchesEventSignature()
        {
            var eventSubscription = new EventSubscription <TestData.Contracts.StandardContract.TransferEvent>();

            var transferLog     = TestData.Contracts.StandardContract.SampleTransferLog();
            var notATransferLog = new FilterLog();

            Assert.True(eventSubscription.IsLogForEvent(transferLog));
            Assert.False(eventSubscription.IsLogForEvent(notATransferLog));
        }
Ejemplo n.º 2
0
        public void FromEventAbis()
        {
            var eventsToMatch     = TestData.Contracts.StandardContract.ContractAbi.Events;
            var eventSubscription = new EventSubscription(eventsToMatch);

            Assert.Equal(eventsToMatch, eventSubscription.Matcher.Abis);

            var transferLog = TestData.Contracts.StandardContract.SampleTransferLog();
            var genericLog  = new FilterLog();

            Assert.True(eventSubscription.IsLogForEvent(transferLog));
            Assert.False(eventSubscription.IsLogForEvent(genericLog));
        }
Ejemplo n.º 3
0
        public void MatchesEventSignatureAndContractAddress()
        {
            var contractAddresses = new[] { "0x243e72b69141f6af525a9a5fd939668ee9f2b354" };
            var eventSubscription = new EventSubscription <TestData.Contracts.StandardContract.TransferEvent>(
                contractAddressesToMatch: contractAddresses);

            var transferLog = TestData.Contracts.StandardContract.SampleTransferLog();
            var transferLogForAnotherContract = TestData.Contracts.StandardContract.SampleTransferLog();

            transferLogForAnotherContract.Address = "0x343e72b69141f6af525a9a5fd939668ee9f2b354";

            Assert.True(eventSubscription.IsLogForEvent(transferLog));
            Assert.False(eventSubscription.IsLogForEvent(transferLogForAnotherContract));
        }
Ejemplo n.º 4
0
        public void MatchesEventSignatureAndParameterCondition()
        {
            var fromCondition = ParameterCondition.Create(
                1, ParameterConditionOperator.Equals, "0x12890d2cce102216644c59dae5baed380d84830c");

            var eventSubscription = new EventSubscription <TestData.Contracts.StandardContract.TransferEvent>(
                parameterConditions: new IParameterCondition[] { fromCondition });

            var transferLog = TestData.Contracts.StandardContract.SampleTransferLog();
            var transferWithDifferentFromAddress = TestData.Contracts.StandardContract.SampleTransferLog();

            transferWithDifferentFromAddress.Topics[1] = "0x00000000000000000000000013f022d72158410433cbd66f5dd8bf6d2d129924";

            Assert.True(eventSubscription.IsLogForEvent(transferLog));
            Assert.False(eventSubscription.IsLogForEvent(transferWithDifferentFromAddress));
        }
Ejemplo n.º 5
0
        public void InvokesMatcher(bool match)
        {
            var log = new FilterLog();

            _matcher.Setup(m => m.IsMatch(log)).Returns(match);

            Assert.Equal(match, _eventSubscription.IsLogForEvent(log));
        }