public async Task Should_Add_Account_Filter_With_Block_Address() { var company = Account.GenerateNewAccount(Fixture.NetworkType); var blocked = Account.GenerateNewAccount(Fixture.NetworkType); var addressFilter = ModifyAccountPropertyTransaction <Address> .CreateForAddress( Deadline.Create(), (ulong)0, PropertyType.BLOCK_ADDRESS, new List <AccountPropertyModification <Address> >() { new AccountPropertyModification <Address>(PropertyModificationType.ADD, blocked.Address) }, Fixture.NetworkType); Log.WriteLine($"Going to filter the address {company.Address} "); await Fixture.SiriusWebSocketClient.Listener.Open(); var tx = Fixture.SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(company.Address).Take(1) .Timeout(TimeSpan.FromSeconds(1000)); var signedTransaction = addressFilter.SignWith(company, Fixture.GenerationHash); Log.WriteLine($"Going to announce transaction {signedTransaction.Hash}"); await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction); var result = await tx; Log.WriteLine($"Request confirmed with transaction {result.TransactionInfo.Hash}"); var accountProperties = await Fixture.SiriusClient.AccountHttp.GetAccountProperty(company.PublicAccount); accountProperties.Should().NotBeNull(); var blockAddressProperty = accountProperties.AccountProperties.Properties.Single(ap => ap.PropertyType == PropertyType.BLOCK_ADDRESS); blockAddressProperty.Should().NotBeNull(); var blockedAddress = blockAddressProperty.Values.Single(a => Address.CreateFromHex(a.ToString()).Plain == blocked.Address.Plain); blockedAddress.Should().NotBeNull(); }
public async Task Should_Add_Account_Filter_With_Allow_Entity_Type() { var company = Account.GenerateNewAccount(Fixture.NetworkType); var allowedTransType = EntityType.MODIFY_ACCOUNT_PROPERTY_ENTITY_TYPE; var accountFilter = ModifyAccountPropertyTransaction <EntityType> .CreateForEntityType( Deadline.Create(), (ulong)0, PropertyType.ALLOW_TRANSACTION, new List <AccountPropertyModification <EntityType> >() { new AccountPropertyModification <EntityType>(PropertyModificationType.ADD, allowedTransType) }, Fixture.NetworkType); Log.WriteLine($"Going to filter the address {company.Address} "); await Fixture.SiriusWebSocketClient.Listener.Open(); var tx = Fixture.SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(company.Address).Take(1) .Timeout(TimeSpan.FromSeconds(1000)); var signedTransaction = accountFilter.SignWith(company, Fixture.GenerationHash); Log.WriteLine($"Going to announce transaction {signedTransaction.Hash}"); await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction); var result = await tx; Log.WriteLine($"Request confirmed with transaction {result.TransactionInfo.Hash}"); var accountProperties = await Fixture.SiriusClient.AccountHttp.GetAccountProperty(company.PublicAccount); accountProperties.Should().NotBeNull(); var allowedTransactionProperty = accountProperties.AccountProperties.Properties.Single(ap => ap.PropertyType == PropertyType.ALLOW_TRANSACTION); var allowedTxType = allowedTransactionProperty.Values.Select(p => EntityTypeExtension.GetRawValue((int)p) == allowedTransType); allowedTxType.Should().NotBeNull(); }
public async Task Should_Add_Account_Filter_With_Allow_Entity_Type() { // var company = await Fixture.GenerateAccountWithCurrency(10000); var company = Account.CreateFromPrivateKey("101a4dfcffe3d5abddee535c0c7fa7bb386b99eb7c19f0c73cdc3837c5844477", Fixture.NetworkType); Log.WriteLine($"Company Account {company.Address.Plain} \r\n Private Key: {company.PrivateKey} \r\n Public Key {company.PublicKey}"); // var allowedMosaic = await Fixture.CreateMosaic(company); var allowedTransType = EntityType.TRANSFER; var accountFilter = ModifyAccountPropertyTransaction <EntityType> .CreateForEntityType( Deadline.Create(), (ulong)0, PropertyType.BLOCK_TRANSACTION, new List <AccountPropertyModification <EntityType> >() { new AccountPropertyModification <EntityType>(PropertyModificationType.ADD, allowedTransType) }, Fixture.NetworkType); Log.WriteLine($"Going to filter the address {company.Address} "); // await Fixture.SiriusWebSocketClient.Listener.Open(); // var tx = Fixture.SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(company.Address).Take(1).Timeout(TimeSpan.FromSeconds(5000)); var signedTransaction = accountFilter.SignWith(Fixture.SeedAccount, Fixture.GenerationHash); Log.WriteLine($"Going to announce transaction {signedTransaction.Hash}"); Log.WriteLine($"Transaction Payload {signedTransaction.Payload}"); await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction); // var result = await tx; // Log.WriteLine($"Request confirmed with transaction {result.TransactionInfo.Hash}"); var accountProperties = await Fixture.SiriusClient.AccountHttp.GetAccountProperty(company.Address); accountProperties.Should().NotBeNull(); var allowedTransactionProperty = accountProperties.AccountProperties.Properties.Single(ap => ap.PropertyType == PropertyType.BLOCK_TRANSACTION); var allowedTxType = allowedTransactionProperty.Values.Select(p => EntityTypeExtension.GetRawValue((int)p) == allowedTransType); allowedTxType.Should().NotBeNull(); }
public async Task Should_Add_Account_Filter_With_Allow_Mosaic() { var company = await Fixture.GenerateAccountWithCurrency(10000); Log.WriteLine($"Company Account {company.Address.Plain} \r\n Private Key: {company.PrivateKey} \r\n Public Key {company.PublicKey}"); var allowedMosaic = await Fixture.CreateMosaic(company); Log.WriteLine($"Mosaic Id: {allowedMosaic.HexId} "); var accountFilter = ModifyAccountPropertyTransaction <IUInt64Id> .CreateForMosaic( Deadline.Create(), (ulong)0, PropertyType.ALLOW_MOSAIC, new List <AccountPropertyModification <IUInt64Id> >() { new AccountPropertyModification <IUInt64Id>(PropertyModificationType.ADD, allowedMosaic) }, Fixture.NetworkType); Log.WriteLine($"Going to filter the address {company.Address} "); await Fixture.SiriusWebSocketClient.Listener.Open(); var tx = Fixture.SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(company.Address).Take(1).Timeout(TimeSpan.FromSeconds(1000)); var signedTransaction = accountFilter.SignWith(company, Fixture.GenerationHash); Log.WriteLine($"Going to announce transaction {signedTransaction.Hash}"); await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction); var result = await tx; Log.WriteLine($"Request confirmed with transaction {result.TransactionInfo.Hash}"); var accountProperties = await Fixture.SiriusClient.AccountHttp.GetAccountProperty(company.Address); accountProperties.Should().NotBeNull(); var allowMosaicProperty = accountProperties.AccountProperties.Properties.Single(ap => ap.PropertyType == PropertyType.ALLOW_MOSAIC); allowMosaicProperty.Should().NotBeNull(); bool hasAllowMosaic = false; foreach (var am in allowMosaicProperty.Values) { var m = JsonConvert.DeserializeObject <UInt64DTO>(am.ToString()); var mId = new MosaicId(m.FromUInt8Array()); if (mId.Id.ToHex().Equals(allowedMosaic.HexId)) { hasAllowMosaic = true; } } hasAllowMosaic.Should().Be(true); var allowMosaic = allowMosaicProperty.Values .Single(a => { var m = JsonConvert.DeserializeObject <UInt64DTO>(a.ToString()); return((new MosaicId(m.ToUInt64())).HexId == allowedMosaic.HexId); }); allowMosaic.Should().NotBeNull(); }