Exemple #1
0
        public async Task Should_1_SetAttributes()
        {
            var web3             = _deployedContractFixture.GetWeb3();
            var workService      = GetWorkService(web3);
            var dataChangedEvent = workService.GetStandardDataChangedEvent();
            var filter           = await dataChangedEvent.CreateFilterAsync();

            var schemaAddress = await workService.GetSchemaAddress();

            var receipt = await _txHelper.SendAndMineTransactionAsync(web3, DefaultSettings.AddressFrom, DefaultSettings.Password,
                                                                      () => workService.SetAttributeAsync(DefaultSettings.AddressFrom, WorkSchema.name, "Hello", true, _defaultGas));

            var eventLogs = await dataChangedEvent.GetFilterChanges <DataChangedEvent>(filter);

            Assert.Equal(WorkSchema.name.ToString(), eventLogs[0].Event.Key);
            Assert.Equal("Hello", eventLogs[0].Event.Value);

            var value = await workService.GetWorkAttributeAsyncCall(WorkSchema.name);

            Assert.Equal("Hello", value);
        }
        public async Task Should_1_RegisterContract()
        {
            var web3 = deployedContractFixture.GetWeb3();
            var contractRegistryService = GetRegistryService(web3);
            var registeredEvent         = contractRegistryService.GetRegisteredEvent();
            var filter = await registeredEvent.CreateFilterAsync();

            await txHelper.SendAndMineTransactionAsync(web3, DefaultSettings.AddressFrom, DefaultSettings.Password,
                                                       () => contractRegistryService.RegisterAsync(DefaultSettings.AddressFrom, DefaultSettings.AddressFrom, defaultGas));

            var eventLogs = await registeredEvent.GetFilterChanges <RegisteredEvent>(filter);

            Assert.Equal(1, eventLogs[0].Event.Id);
            Assert.Equal(DefaultSettings.AddressFrom, eventLogs[0].Event.RegisteredAddress);
            Assert.Equal(DefaultSettings.AddressFrom, eventLogs[0].Event.Owner);
            var address = await contractRegistryService.GetAddressRegisteredAsyncCall(1);

            Assert.Equal(DefaultSettings.AddressFrom, address);
        }