cordaVersion = 4.3
tokens_release_version = '1.1-RC06-PRESIGN'
OS = Windows 10
Using a MockNetwork I was testing TokenPointer’s that point to EvolvableTokenType’s (reference states) using the TokenSDK when I got the following error message:
net.corda.core.node.ZoneVersionTooLowException: Reference states requires all nodes on the Corda compatibility zone to be running at least platform version 4. The current zone is only enforcing a minimum platform version of 1. Please contact your zone operator.
I got the same ZoneVersionTooLowException error when using reference states in my contract and testing the flows using MockNetwork.
I fixed it by changing the minimumPlatformVersion to 4 in the testNetworkParameters class and using that to construct my MockNetwork. Here is the snippet in Kotlin.
import net.corda.testing.common.internal.testNetworkParameters
class AssetCreationFlowTests {
private lateinit var network: MockNetwork
private lateinit var a: StartedMockNode
private lateinit var b: StartedMockNode
#Before
fun setup() {
val myNetworkParameters = testNetworkParameters(minimumPlatformVersion = 4)
network = MockNetwork(MockNetworkParameters(
cordappsForAllNodes = listOf(
TestCordapp.findCordapp(AssetContract::class.packageName)
),
networkParameters = myNetworkParameters
)
)
I looked on stackoverflow and found this but I was determined to get a MockNetwork working because it is so handy for testing.
I had to create my MockNetwork manually versus using the defaults. I extracted all the MockNetwork properties from a default build of a MockNetwork:
MockNetwork mockNet = new MockNetwork(new MockNetworkParameters(getTestCordapps()));
Step 1) Build a NetworkParameters object setting the minimumPlatformVersion to 4:
List<NotaryInfo> notaryinfo = Arrays.asList();
NetworkParameters networkParameters = new NetworkParameters(
4,
notaryinfo,
10485760,
524288000,
java.time.Instant.now(),
1,
Collections.emptyMap()
);
Step 2) Create a MockNetworkParameters object using the new NetworkParameters;
MockNetworkParameters mockNetworkParameters = new MockNetworkParameters(
false,
false,
new InMemoryMessagingNetwork.ServicePeerAllocationStrategy.Random.Random(),
Arrays.asList(new MockNetworkNotarySpec(new CordaX500Name("Notary Service", "Zurich", "CH"), true)),
networkParameters,
getTestCordapps()
);
NB: getTestCordapps() just returns a List<TestCordapp> that I need for the test I am performing i.e.
private List<TestCordapp> getTestCordapps() {
return ImmutableList.of(
TestCordapp.findCordapp("com.template.contracts"),
TestCordapp.findCordapp("com.template.flows"),
TestCordapp.findCordapp("com.r3.corda.lib.tokens.contracts"),
etc.
etc.
)}
Step 3) Build your MockNetwork with your MockNetworkParameters object:
MockNetwork mockNetwork = new MockNetwork(mockNetworkParameters);
I’ve been using it for a few weeks and it seems to work. If there is a better way please let me know.
Related
I'm currently trying to move out from using old Microsoft.Azure.Management.Dns package to the new Azure.ResourceManager.Dns.
However I've been having issues in our code that creates Dns records such as an Arecord.
I've tried to go through the official documentation https://learn.microsoft.com/en-us/dotnet/api/azure.resourcemanager.dns.dnsarecordcollection.createorupdate?view=azure-dotnet
But the classes that represent an Arecord are either read only or private so I have no idea how to update this simple lines:
RecordSet set = DnsManagementClient.client.RecordSets.Get(resourceGroupName, zone, recordSetName, RecordType.A);
set.ARecords = set.ARecords ?? new List<ARecord>();
set.ARecords.Add(new ARecord(ipAddress));
DnsManagementClient.client.RecordSets.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, zone, recordSetName, RecordType.A, set, ifNoneMatch: "*");
Currently documentation only talks about Zones, can an example be added to the official documentation on how to add or update a DNS record (A,CNAME,etc..)
https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/dns/Azure.ResourceManager.Dns
I'm expecting a method to create an A record that let's you specify an IP address, and currently all the classes that potentially can be used to do that are either read-only or internal.
DnsARecordData has an internal list of Arecords, DnsARecordData.DnsARecords is where we can invoke the Add method to create the record. The reason DnsARecordData doesn't have a setter method is due to the .Net framework design guideline..
An example of how to create an A record using Azure.Resourcemanager.Dns can be found here:
// Create or update A record
string myARecordName = "myrecord";
DnsARecordData dnsARecordData = new() {TtlInSeconds = (long)TimeSpan.FromHours(1).TotalSeconds};
dnsARecordData.DnsARecords.Add(new DnsARecordInfo { IPv4Address = IPAddress.Parse("127.0.0.1") });
DnsARecordCollection dnsARecordCollection1 = dnsZoneResource.GetDnsARecords();
dnsARecordCollection1.CreateOrUpdate(WaitUntil.Completed, myARecordName, dnsARecordData);
// Create or update CName pointing to A record
string myCnameName = "mycname";
DnsCnameRecordData dnsCnameRecordData = new() { Cname = $"{myARecordName}.{DnsZone}", TtlInSeconds = (long)TimeSpan.FromMinutes(10).TotalSeconds, };
DnsCnameRecordCollection cnameRecordCollection = dnsZoneResource.GetDnsCnameRecords();
cnameRecordCollection.CreateOrUpdate(WaitUntil.Completed, myCnameName, dnsCnameRecordData);
I tried in my environment and got below results:
You can create A record set using Azure.ResourceManager.Dns package. The version of NuGet package is beta-1.
NuGet Package:
Azure.ResourceManager.Dns 1.0.0 beta-1
Code:
using Azure;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Dns;
using Azure.ResourceManager.Resources;
using System.Net;
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();
// first we need to get the resource group
string rgName = "rg-name";
ResourceGroupResource resourceGroup = await subscription.GetResourceGroups().GetAsync(rgName);
string dnsZoneName = "dns name";
DnsZoneCollection dnsZoneCollection = resourceGroup.GetDnsZones();
DnsZoneData data1 = new DnsZoneData("Global")
{
};
ArmOperation<DnsZoneResource> lro = await dnsZoneCollection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneName, data1);
DnsZoneResource dnsZone = lro.Value;
RecordSetACollection recordSetACollection = dnsZone.GetRecordSetAs();
string name = "cname1";
var parm = new ARecordSetData();
parm.TTL =600;
parm.ARecords = new List<ARecord>();
parm.ARecords.Add(new ARecord("1.2.3.4"));
ArmOperation<RecordSetAResource> recordSetAResource = recordSetACollection.CreateOrUpdate(WaitUntil.Completed, name,parm);
RecordSetAResource recordSetAs = recordSetAResource.Value;
Console:
Portal:
For more reference:
azure-sdk-for-net/Sample2_ManagingRecordSetPtrs.md at dvbb-mgmt-track2-dns-2 · dvbb/azure-sdk-for-net (github.com)
After updating my Xcode to 10.2 which includes Swift 5, I tried building my project and got this error.
dynamic property 'openingHours' must also be '#objc'
on this line of code
dynamic let openingHours = List<ShopHourRealm>()
And before updating to Xcode 10.2, I was able to build and compile my project without any error.
Any thoughts why this is happening?
You don't need to specify dynamic for Realm List types. Just
let openingHours = List<ShopHourRealm>()
will suffice.
Based on the examples here https://realm.io/docs/swift/latest/#models
import RealmSwift
// Dog model
class Dog: Object {
#objc dynamic var name = ""
#objc dynamic var owner: Person? // Properties can be optional
}
// Person model
class Person: Object {
#objc dynamic var name = ""
#objc dynamic var birthdate = Date(timeIntervalSince1970: 1)
let dogs = List<Dog>()
}
I've created a Bluetooth Gatt server on Android : I was able to implement/configure a new service (thanks to the https://github.com/androidthings/sample-bluetooth-le-gattserver), but unfortunately, I am not able to change the "appearance" of the service.
From my understanding, I need to modify the Appearance characteric of the Generic Access Profile (https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile), but I'm stuck as it does not exit, and if try to create it, it fails with a status=133 error. (https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/android-5.1.1_r13/stack/include/gatt_api.h)
final UUID SERVICE_GENERIC_ACCESS = UUID.fromString("00001800-0000-1000-8000-00805f9b34fb");
final UUID CHARACTERISTIC_APPEARANCE = UUID.fromString("00002a01-0000-1000-8000-00805f9b34fb");
BluetoothManager mBluetoothGattServer = mBluetoothManager.openGattServer(this, mGattServerCallback);
BluetoothGattService genericService = mBluetoothGattServer.getService(SERVICE_GENERIC_ACCESS);
BluetoothGattService genericService = new BluetoothGattService(
SERVICE_GENERIC_ACCESS,
BluetoothGattService.SERVICE_TYPE_PRIMARY);
BluetoothGattCharacteristic icon = new BluetoothGattCharacteristic(CHARACTERISTIC_APPEARANCE, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ);
mBluetoothGattServer.addService(genericService);
public void onServiceAdded(int status, BluetoothGattService service) {
// Fails with error 133
}
Any help will be appreciated!
Cheers
D
I'm trying to get a list of the available users from the Core Service. I spend quite some time looking at the available service methods and the most obvious seemed to be this:
TrusteesFilterData trusteesFilterData = new TrusteesFilterData
{
BaseColumns = ListBaseColumns.IdAndTitle,
IsPredefined = false,
ItemType = ItemType.User
};
XElement listTrustees = client.GetSystemWideListXml(trusteesFilterData);
However, the code throws an error when calling GetSystemWideListXml - Unable to create Abstract Class. Am I using the correct approach and, if so what am I doing wrong? If not, what should I be doing instead?
Take a look at the samples in the open source project for workflow notification
http://code.google.com/p/tridion-notification-framework/source/browse/NotificationService/NotificationService/Worker.cs
Lines 22 - 26 in the DoWork() method should do what you need - I think need to use UsersFilterData rather than TrusteesFilterData
var users = client.GetSystemWideList(new UsersFilterData { BaseColumns = ListBaseColumns.IdAndTitle, IsPredefined = false });
Hey folks, i ve got this issue implementing the Factory method.
Following is the snippet of the the main chart class which calls ChartFactory's method to attain the proper object. I Type Cast chartobject so as to be able to call the Show method;i m apprehensive about that as well.
container = new VBox();
container.percentWidth = 100;
container.percentHeight = 100;
super.media.addChild(container);
chartObject = new ChartBase();
chartObject = ChartFactory.CreateChartObject(chartType);
IChart(chartObject).Show(o);
container.addChild(chartObject);
legend = new Legend();
legend.dataProvider = IChart(chartObject);
container.addChild(legend);
Following is the snippet of ChartFactory's method:
public static function CreateChartObject(subType:String):ChartBase
{
switch(subType)
{
case ChartFactory.AREA_CHART:
return new AreaCharts();
break;
case ChartFactory.COLUMN_CHART:
return new ColumnCharts();
break;
case ChartFactory.PIE_CHART:
return new PieCharts();
break;
default:
throw new ArgumentError(subType + ": Chart type is not recognized.");
}
}
And following is Show method of one of the several Charts type classes: AreaCharts, PieCharts etc. All of which implements IChart Interface.
public function Show(o:ObjectProxy):void
{
var grids:GridLines;
var stroke:SolidColorStroke;
var horizontalAxis:CategoryAxis;
var verticalAxis:LinearAxis;
var horizontalAxisRenderer:AxisRenderer;
var verticalAxisRenderer:AxisRenderer;
grids = new GridLines();
if(WidgetStylesheet.instance.LineChart_ShowGrid)
grids.setStyle("gridDirection", "both");
else
grids.setStyle("gridDirection", "");
stroke = new SolidColorStroke(WidgetStylesheet.instance.LineChart_GridLineColor, WidgetStylesheet.instance.LineChart_GridLineThickness);
grids.setStyle("horizontalStroke", stroke);
grids.setStyle("verticalStroke", stroke);
horizontalAxis = new CategoryAxis();
horizontalAxis.categoryField = o.LargeUrl.Chart.xField;
horizontalAxis.title = o.LargeUrl.Chart.xAxisTitle.toString();
verticalAxis = new LinearAxis();
verticalAxis.title = o.LargeUrl.Chart.yAxisTitle.toString();
horizontalAxisRenderer = new AxisRenderer();
horizontalAxisRenderer.axis = horizontalAxis;
horizontalAxisRenderer.setStyle("tickLength", 0);
horizontalAxisRenderer.setStyle("showLine", false);
horizontalAxisRenderer.setStyle("showLabels", true);
horizontalAxisRenderer.setStyle("fontSize", WidgetStylesheet.instance.ComputeChartAxisFontSize(o.HeadlineFontSize));
verticalAxisRenderer = new AxisRenderer();
verticalAxisRenderer.axis = verticalAxis;
verticalAxisRenderer.setStyle("tickLength", 0);
verticalAxisRenderer.setStyle("showLine", false);
verticalAxisRenderer.setStyle("fontSize", WidgetStylesheet.instance.ComputeChartAxisFontSize(o.HeadlineFontSize));
this.series = this.m_createSeries(o);
this.horizontalAxis = horizontalAxis;
this.horizontalAxisRenderers = [horizontalAxisRenderer];
this.verticalAxis = verticalAxis;
this.verticalAxisRenderers = [verticalAxisRenderer];
this.backgroundElements = [grids];
}
I'm afraid that there is more than one issue with this code. Unfortunately it is not obvious why your chart doesn't show up so you may apply some of advices below and use debugger to analyse the issue.
There is no point in creating ChartBase instance if you are going to change value of chartObject reference in the next line
chartObject = new ChartBase();
chartObject = ChartFactory.CreateChartObject(chartType);
If the API of your charts is IChart your factory should return IChart instead of casting.
public static function CreateChartObject(subType:String):IChart
Make sure that you are returning instances of the correct class from the factory. i.e. that you are returning your subclass of standard PieChart. Generally it's not the best idea to extend the class keeping the same name and just changing the package.
Once again, if you are not sure if the program enters some function use the Flash Builder debugger to check this. I can't imagine development without debugger.
Some thoughts:
you call the Show method, pass it some object but nowhere in that method is any child added to a displayObject. What exactly is Show supposed to do?
a lot of member variables in your classes start with UpperCase. The compiler can easily confuse those with class names, in case your classes are named the same. Bad practice to start variable and function names with capitals.
If your casting an instance to another class or interface fails, you will get a runtime error. Those are easy to debug using the Flash Builder debugger.
Hey ppl..
i found out wat wnt wrng..as olwys it wa "I".
I ve a habit of mkin mock ups secluded from the main project n dn integrate it. So in mock up i hd used an xml whch hd a format slightly diff dn d one being used in the main project.
N i hd a conditional chk to return from the prog if certain value doesnt match, n due to faulty xml i did'nt.
So this more a lexical error than a logical one.
Sorry n Thanx evryone for responding.