@xyo-network/sentinel-wrapper 4.3.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/sentinel-wrapper",
3
- "version": "4.3.0",
3
+ "version": "5.0.0",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -28,29 +28,33 @@
28
28
  },
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/neutral/index.d.ts",
31
+ "files": [
32
+ "dist",
33
+ "src"
34
+ ],
31
35
  "dependencies": {
32
- "@xyo-network/account-model": "^4.3.0",
33
- "@xyo-network/archivist-model": "^4.3.0",
34
- "@xyo-network/module-model": "^4.3.0",
35
- "@xyo-network/module-wrapper": "^4.3.0",
36
- "@xyo-network/payload-model": "^4.3.0",
37
- "@xyo-network/sentinel-model": "^4.3.0",
38
- "@xyo-network/witness-model": "^4.3.0"
36
+ "@xyo-network/account-model": "^5.0.0",
37
+ "@xyo-network/archivist-model": "^5.0.0",
38
+ "@xyo-network/module-model": "^5.0.0",
39
+ "@xyo-network/module-wrapper": "^5.0.0",
40
+ "@xyo-network/payload-model": "^5.0.0",
41
+ "@xyo-network/sentinel-model": "^5.0.0",
42
+ "@xyo-network/witness-model": "^5.0.0"
39
43
  },
40
44
  "devDependencies": {
41
- "@xylabs/delay": "^4.15.0",
42
- "@xylabs/ts-scripts-yarn3": "^7.0.1",
43
- "@xylabs/tsconfig": "^7.0.1",
44
- "@xylabs/vitest-extended": "^4.15.0",
45
- "@xyo-network/abstract-witness": "^4.3.0",
46
- "@xyo-network/account": "^4.3.0",
47
- "@xyo-network/archivist-memory": "^4.3.0",
48
- "@xyo-network/boundwitness-model": "^4.3.0",
49
- "@xyo-network/module-model": "^4.3.0",
50
- "@xyo-network/node-memory": "^4.3.0",
51
- "@xyo-network/payload-builder": "^4.3.0",
52
- "@xyo-network/sentinel-memory": "^4.3.0",
53
- "@xyo-network/witness-adhoc": "^4.3.0",
45
+ "@xylabs/delay": "^5.0.0",
46
+ "@xylabs/ts-scripts-yarn3": "^7.0.2",
47
+ "@xylabs/tsconfig": "^7.0.2",
48
+ "@xylabs/vitest-extended": "^5.0.0",
49
+ "@xyo-network/abstract-witness": "^5.0.0",
50
+ "@xyo-network/account": "^5.0.0",
51
+ "@xyo-network/archivist-memory": "^5.0.0",
52
+ "@xyo-network/boundwitness-model": "^5.0.0",
53
+ "@xyo-network/module-model": "^5.0.0",
54
+ "@xyo-network/node-memory": "^5.0.0",
55
+ "@xyo-network/payload-builder": "^5.0.0",
56
+ "@xyo-network/sentinel-memory": "^5.0.0",
57
+ "@xyo-network/witness-adhoc": "^5.0.0",
54
58
  "typescript": "^5.8.3",
55
59
  "vitest": "^3.2.4"
56
60
  },
@@ -0,0 +1,144 @@
1
+ import '@xylabs/vitest-extended'
2
+
3
+ import { delay } from '@xylabs/delay'
4
+ import type { AbstractWitness } from '@xyo-network/abstract-witness'
5
+ import { Account } from '@xyo-network/account'
6
+ import { MemoryArchivist } from '@xyo-network/archivist-memory'
7
+ import type { Archivist, AttachableArchivistInstance } from '@xyo-network/archivist-model'
8
+ import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'
9
+ import type { AttachableModuleInstance } from '@xyo-network/module-model'
10
+ import { MemoryNode } from '@xyo-network/node-memory'
11
+ import { PayloadBuilder } from '@xyo-network/payload-builder'
12
+ import type { Payload } from '@xyo-network/payload-model'
13
+ import { PayloadSchema } from '@xyo-network/payload-model'
14
+ import type { MemorySentinelParams } from '@xyo-network/sentinel-memory'
15
+ import { MemorySentinel } from '@xyo-network/sentinel-memory'
16
+ import type { ReportEndEventArgs, SentinelConfig } from '@xyo-network/sentinel-model'
17
+ import { SentinelConfigSchema } from '@xyo-network/sentinel-model'
18
+ import { AdhocWitness, AdhocWitnessConfigSchema } from '@xyo-network/witness-adhoc'
19
+ import {
20
+ beforeEach,
21
+ describe, expect,
22
+ it, test,
23
+ } from 'vitest'
24
+
25
+ import { SentinelWrapper } from '../Wrapper.ts'
26
+
27
+ /**
28
+ * @group sentinel
29
+ * @group module
30
+ */
31
+
32
+ describe('Sentinel', () => {
33
+ test('all [simple sentinel report]', async () => {
34
+ const node = await MemoryNode.create({ account: 'random' })
35
+ const archivist = await MemoryArchivist.create({ account: 'random' })
36
+ await node.register(archivist)
37
+ await node.attach(archivist.address)
38
+
39
+ const witnesses: AbstractWitness[] = [await AdhocWitness.create({ account: 'random', config: { schema: AdhocWitnessConfigSchema } })]
40
+
41
+ await Promise.all(
42
+ witnesses.map(async (witness) => {
43
+ await node.register(witness)
44
+ await node.attach(witness.address)
45
+ }),
46
+ )
47
+
48
+ const config: SentinelConfig = {
49
+ archiving: { archivists: [archivist.address] },
50
+ schema: SentinelConfigSchema,
51
+ synchronous: true,
52
+ tasks: witnesses.map(witness => ({ mod: witness.address })),
53
+ }
54
+
55
+ const sentinel = (await MemorySentinel.create({ account: 'random', config })) as MemorySentinel
56
+ await node.register(sentinel)
57
+ await node.attach(sentinel.address)
58
+
59
+ const report1Result = await sentinel.report()
60
+ const report1 = report1Result.at(0)
61
+ expect(report1?.schema).toBe(BoundWitnessSchema)
62
+ })
63
+ describe('report', () => {
64
+ describe('reports witnesses when supplied in', () => {
65
+ let archivistA: AttachableArchivistInstance
66
+ let archivistB: AttachableArchivistInstance
67
+ let witnessA: AbstractWitness
68
+ let witnessB: AbstractWitness
69
+ const assertPanelReport = (panelReport: Payload[]) => {
70
+ expect(panelReport).toBeArrayOfSize(3)
71
+ }
72
+ const assertArchivistStateMatchesPanelReport = async (payloads: Payload[], archivists: Archivist[]) => {
73
+ // delay to wait for archiving to happen
74
+ await delay(1000)
75
+ for (const archivist of archivists) {
76
+ const archivistPayloads = await archivist.all?.()
77
+ expect(archivistPayloads).toBeArrayOfSize(payloads.length + 1)
78
+ const panelPayloads = await Promise.all(
79
+ payloads.map((payload) => {
80
+ return PayloadBuilder.omitStorageMeta(payload)
81
+ }),
82
+ )
83
+ const archivistDataHashes = await PayloadBuilder.dataHashes(archivistPayloads)
84
+ const panelDataHashes = await PayloadBuilder.dataHashes(panelPayloads)
85
+ expect(archivistDataHashes).toContainValues(panelDataHashes)
86
+ }
87
+ }
88
+ beforeEach(async () => {
89
+ const paramsA = {
90
+ account: 'random' as const,
91
+ config: {
92
+ payload: { nonce: Date.now() * 8, schema: 'network.xyo.test' },
93
+ schema: AdhocWitnessConfigSchema,
94
+ targetSchema: PayloadSchema,
95
+ },
96
+ }
97
+ const paramsB = {
98
+ account: 'random' as const,
99
+ config: {
100
+ payload: { nonce: Date.now() * 9, schema: 'network.xyo.test' },
101
+ schema: AdhocWitnessConfigSchema,
102
+ targetSchema: PayloadSchema,
103
+ },
104
+ }
105
+ witnessA = await AdhocWitness.create(paramsA)
106
+ witnessB = await AdhocWitness.create(paramsB)
107
+ archivistA = await MemoryArchivist.create({ account: 'random' })
108
+ archivistB = await MemoryArchivist.create({ account: 'random' })
109
+ })
110
+ it('config', async () => {
111
+ const node = await MemoryNode.create({ account: 'random' })
112
+ const modules: AttachableModuleInstance[] = [witnessA, witnessB, archivistA, archivistB]
113
+ await Promise.all(
114
+ modules.map(async (mod) => {
115
+ await node.register(mod)
116
+ await node.attach(mod.address, true)
117
+ }),
118
+ )
119
+ const params: MemorySentinelParams<SentinelConfig> = {
120
+ name: 'TestSentinel',
121
+ account: 'random',
122
+ config: {
123
+ archiving: { archivists: [archivistA.address, archivistB.address] },
124
+ schema: SentinelConfigSchema,
125
+ synchronous: true,
126
+ tasks: [{ mod: witnessA.address }, { mod: witnessB.address }],
127
+ },
128
+ }
129
+ const sentinel = await MemorySentinel.create(params)
130
+ sentinel.on('reportEnd', (args) => {
131
+ const { outPayloads } = args as ReportEndEventArgs
132
+ expect(outPayloads?.length).toBeGreaterThan(0)
133
+ })
134
+ await node.register(sentinel)
135
+ await node.attach(sentinel.address)
136
+ // using a wrapper to trigger archiving
137
+ const wrapper = SentinelWrapper.wrap(sentinel, await Account.random())
138
+ const result = await wrapper.report()
139
+ assertPanelReport(result)
140
+ await assertArchivistStateMatchesPanelReport(result, [archivistA, archivistB])
141
+ })
142
+ })
143
+ })
144
+ })
package/xy.config.ts DELETED
@@ -1,10 +0,0 @@
1
- import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
- const config: XyTsupConfig = {
3
- compile: {
4
- browser: {},
5
- neutral: { src: true },
6
- node: {},
7
- },
8
- }
9
-
10
- export default config