В прошлом я делал для этого запись транзакции с именем setup
, которую разрешено запускать только администратору.Эта функция инициализирует вашу цепочку приличным количеством фиктивных данных, которые вы можете использовать для тестирования.Например:
Модель:
transaction Setup {
}
Сценарий транзакции:
/**
* Seed chain with mock data for testing
* @param {com.your.namespace} tx - set up request
* @transaction
*/
async function setup(tx) {
const factory = getFactory();
const exampleRegistry = await getParticipantRegistry(`${namespace}.example`);
const exampleResource= factory.newResource(namespace, "Example", "ExampleResourceName");
example.exampleProperty = 2000;
await exampleRegistry.add(exampleResource);
const otherExample = factory.newResource(namespace, "OtherExample", "OtherExampleName");
otherExample.exampleProperty = 0;
const otherExampleRef = factory.newRelationship(namespace, "OtherExample", "OtherExampleName");
await otherExampleRegistry.addAll([otherExample]);
const thirdExample = factory.newResource(namespace, "ThirdExample", "ThirdExampleName");
thirdExample.exampleRelationshipProperty = otherExampleRef
thirdExample.exampleProperty = 0;
await thirdExampleRegistry.addAll([thirdExample]);
}
Затем ваш .ACL
:
rule SetupTransaction {
description: "Deny anyone but admin access to call Setup transaction"
participant: "com.your.namespace.**"
operation: ALL
resource: "com.your.namespace.Setup"
action: DENY
}