@xyo-network/sentinel-wrapper 5.1.21 → 5.1.23
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": "5.1.
|
|
3
|
+
"version": "5.1.23",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -30,34 +30,37 @@
|
|
|
30
30
|
"types": "dist/neutral/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
32
|
"dist",
|
|
33
|
-
"src"
|
|
33
|
+
"src",
|
|
34
|
+
"!**/*.bench.*",
|
|
35
|
+
"!**/*.spec.*",
|
|
36
|
+
"!**/*.test.*"
|
|
34
37
|
],
|
|
35
38
|
"dependencies": {
|
|
36
|
-
"@xyo-network/account-model": "~5.1.
|
|
37
|
-
"@xyo-network/archivist-model": "~5.1.
|
|
38
|
-
"@xyo-network/module-model": "~5.1.
|
|
39
|
-
"@xyo-network/module-wrapper": "~5.1.
|
|
40
|
-
"@xyo-network/payload-model": "~5.1.
|
|
41
|
-
"@xyo-network/sentinel-model": "~5.1.
|
|
42
|
-
"@xyo-network/witness-model": "~5.1.
|
|
39
|
+
"@xyo-network/account-model": "~5.1.23",
|
|
40
|
+
"@xyo-network/archivist-model": "~5.1.23",
|
|
41
|
+
"@xyo-network/module-model": "~5.1.23",
|
|
42
|
+
"@xyo-network/module-wrapper": "~5.1.23",
|
|
43
|
+
"@xyo-network/payload-model": "~5.1.23",
|
|
44
|
+
"@xyo-network/sentinel-model": "~5.1.23",
|
|
45
|
+
"@xyo-network/witness-model": "~5.1.23"
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
45
|
-
"@xylabs/creatable": "~5.0.
|
|
46
|
-
"@xylabs/delay": "~5.0.
|
|
48
|
+
"@xylabs/creatable": "~5.0.33",
|
|
49
|
+
"@xylabs/delay": "~5.0.33",
|
|
47
50
|
"@xylabs/ts-scripts-yarn3": "~7.2.8",
|
|
48
51
|
"@xylabs/tsconfig": "~7.2.8",
|
|
49
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
50
|
-
"@xyo-network/abstract-witness": "~5.1.
|
|
51
|
-
"@xyo-network/account": "~5.1.
|
|
52
|
-
"@xyo-network/archivist-memory": "~5.1.
|
|
53
|
-
"@xyo-network/boundwitness-model": "~5.1.
|
|
54
|
-
"@xyo-network/module-model": "~5.1.
|
|
55
|
-
"@xyo-network/node-memory": "~5.1.
|
|
56
|
-
"@xyo-network/payload-builder": "~5.1.
|
|
57
|
-
"@xyo-network/sentinel-memory": "~5.1.
|
|
58
|
-
"@xyo-network/witness-adhoc": "~5.1.
|
|
52
|
+
"@xylabs/vitest-extended": "~5.0.33",
|
|
53
|
+
"@xyo-network/abstract-witness": "~5.1.23",
|
|
54
|
+
"@xyo-network/account": "~5.1.23",
|
|
55
|
+
"@xyo-network/archivist-memory": "~5.1.23",
|
|
56
|
+
"@xyo-network/boundwitness-model": "~5.1.23",
|
|
57
|
+
"@xyo-network/module-model": "~5.1.23",
|
|
58
|
+
"@xyo-network/node-memory": "~5.1.23",
|
|
59
|
+
"@xyo-network/payload-builder": "~5.1.23",
|
|
60
|
+
"@xyo-network/sentinel-memory": "~5.1.23",
|
|
61
|
+
"@xyo-network/witness-adhoc": "~5.1.23",
|
|
59
62
|
"typescript": "~5.9.3",
|
|
60
|
-
"vitest": "~4.0.
|
|
63
|
+
"vitest": "~4.0.9"
|
|
61
64
|
},
|
|
62
65
|
"publishConfig": {
|
|
63
66
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Sentinel.Wrapper.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/Sentinel.Wrapper.spec.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAA"}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import '@xylabs/vitest-extended'
|
|
2
|
-
|
|
3
|
-
import type { CreatableName } from '@xylabs/creatable'
|
|
4
|
-
import { delay } from '@xylabs/delay'
|
|
5
|
-
import type { AbstractWitness } from '@xyo-network/abstract-witness'
|
|
6
|
-
import { Account } from '@xyo-network/account'
|
|
7
|
-
import { MemoryArchivist } from '@xyo-network/archivist-memory'
|
|
8
|
-
import type { Archivist, AttachableArchivistInstance } from '@xyo-network/archivist-model'
|
|
9
|
-
import { BoundWitnessSchema } from '@xyo-network/boundwitness-model'
|
|
10
|
-
import type { AttachableModuleInstance } from '@xyo-network/module-model'
|
|
11
|
-
import { MemoryNode } from '@xyo-network/node-memory'
|
|
12
|
-
import { PayloadBuilder } from '@xyo-network/payload-builder'
|
|
13
|
-
import type { Payload } from '@xyo-network/payload-model'
|
|
14
|
-
import { PayloadSchema } from '@xyo-network/payload-model'
|
|
15
|
-
import type { MemorySentinelParams } from '@xyo-network/sentinel-memory'
|
|
16
|
-
import { MemorySentinel } from '@xyo-network/sentinel-memory'
|
|
17
|
-
import type { ReportEndEventArgs, SentinelConfig } from '@xyo-network/sentinel-model'
|
|
18
|
-
import { SentinelConfigSchema } from '@xyo-network/sentinel-model'
|
|
19
|
-
import { AdhocWitness, AdhocWitnessConfigSchema } from '@xyo-network/witness-adhoc'
|
|
20
|
-
import {
|
|
21
|
-
beforeEach,
|
|
22
|
-
describe, expect,
|
|
23
|
-
it, test,
|
|
24
|
-
} from 'vitest'
|
|
25
|
-
|
|
26
|
-
import { SentinelWrapper } from '../Wrapper.ts'
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* @group sentinel
|
|
30
|
-
* @group module
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
describe('Sentinel', () => {
|
|
34
|
-
test('all [simple sentinel report]', async () => {
|
|
35
|
-
const node = await MemoryNode.create({ account: 'random' })
|
|
36
|
-
const archivist = await MemoryArchivist.create({ account: 'random' })
|
|
37
|
-
await node.register(archivist)
|
|
38
|
-
await node.attach(archivist.address)
|
|
39
|
-
|
|
40
|
-
const witnesses: AbstractWitness[] = [await AdhocWitness.create({ account: 'random', config: { schema: AdhocWitnessConfigSchema } })]
|
|
41
|
-
|
|
42
|
-
await Promise.all(
|
|
43
|
-
witnesses.map(async (witness) => {
|
|
44
|
-
await node.register(witness)
|
|
45
|
-
await node.attach(witness.address)
|
|
46
|
-
}),
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
const config: SentinelConfig = {
|
|
50
|
-
archiving: { archivists: [archivist.address] },
|
|
51
|
-
schema: SentinelConfigSchema,
|
|
52
|
-
synchronous: true,
|
|
53
|
-
tasks: witnesses.map(witness => ({ mod: witness.address })),
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const sentinel = (await MemorySentinel.create({ account: 'random', config })) as MemorySentinel
|
|
57
|
-
await node.register(sentinel)
|
|
58
|
-
await node.attach(sentinel.address)
|
|
59
|
-
|
|
60
|
-
const report1Result = await sentinel.report()
|
|
61
|
-
const report1 = report1Result.at(0)
|
|
62
|
-
expect(report1?.schema).toBe(BoundWitnessSchema)
|
|
63
|
-
})
|
|
64
|
-
describe('report', () => {
|
|
65
|
-
describe('reports witnesses when supplied in', () => {
|
|
66
|
-
let archivistA: AttachableArchivistInstance
|
|
67
|
-
let archivistB: AttachableArchivistInstance
|
|
68
|
-
let witnessA: AbstractWitness
|
|
69
|
-
let witnessB: AbstractWitness
|
|
70
|
-
const assertPanelReport = (panelReport: Payload[]) => {
|
|
71
|
-
expect(panelReport).toBeArrayOfSize(3)
|
|
72
|
-
}
|
|
73
|
-
const assertArchivistStateMatchesPanelReport = async (payloads: Payload[], archivists: Archivist[]) => {
|
|
74
|
-
// delay to wait for archiving to happen
|
|
75
|
-
await delay(1000)
|
|
76
|
-
for (const archivist of archivists) {
|
|
77
|
-
const archivistPayloads = await archivist.all?.()
|
|
78
|
-
expect(archivistPayloads).toBeArrayOfSize(payloads.length + 1)
|
|
79
|
-
const panelPayloads = await Promise.all(
|
|
80
|
-
payloads.map((payload) => {
|
|
81
|
-
return PayloadBuilder.omitStorageMeta(payload)
|
|
82
|
-
}),
|
|
83
|
-
)
|
|
84
|
-
const archivistDataHashes = await PayloadBuilder.dataHashes(archivistPayloads)
|
|
85
|
-
const panelDataHashes = await PayloadBuilder.dataHashes(panelPayloads)
|
|
86
|
-
expect(archivistDataHashes).toContainValues(panelDataHashes)
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
beforeEach(async () => {
|
|
90
|
-
const paramsA = {
|
|
91
|
-
account: 'random' as const,
|
|
92
|
-
config: {
|
|
93
|
-
payload: { nonce: Date.now() * 8, schema: 'network.xyo.test' },
|
|
94
|
-
schema: AdhocWitnessConfigSchema,
|
|
95
|
-
targetSchema: PayloadSchema,
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
const paramsB = {
|
|
99
|
-
account: 'random' as const,
|
|
100
|
-
config: {
|
|
101
|
-
payload: { nonce: Date.now() * 9, schema: 'network.xyo.test' },
|
|
102
|
-
schema: AdhocWitnessConfigSchema,
|
|
103
|
-
targetSchema: PayloadSchema,
|
|
104
|
-
},
|
|
105
|
-
}
|
|
106
|
-
witnessA = await AdhocWitness.create(paramsA)
|
|
107
|
-
witnessB = await AdhocWitness.create(paramsB)
|
|
108
|
-
archivistA = await MemoryArchivist.create({ account: 'random' })
|
|
109
|
-
archivistB = await MemoryArchivist.create({ account: 'random' })
|
|
110
|
-
})
|
|
111
|
-
it('config', async () => {
|
|
112
|
-
const node = await MemoryNode.create({ account: 'random' })
|
|
113
|
-
const modules: AttachableModuleInstance[] = [witnessA, witnessB, archivistA, archivistB]
|
|
114
|
-
await Promise.all(
|
|
115
|
-
modules.map(async (mod) => {
|
|
116
|
-
await node.register(mod)
|
|
117
|
-
await node.attach(mod.address, true)
|
|
118
|
-
}),
|
|
119
|
-
)
|
|
120
|
-
const params: MemorySentinelParams<SentinelConfig> = {
|
|
121
|
-
name: 'TestSentinel' as CreatableName,
|
|
122
|
-
account: 'random',
|
|
123
|
-
config: {
|
|
124
|
-
archiving: { archivists: [archivistA.address, archivistB.address] },
|
|
125
|
-
schema: SentinelConfigSchema,
|
|
126
|
-
synchronous: true,
|
|
127
|
-
tasks: [{ mod: witnessA.address }, { mod: witnessB.address }],
|
|
128
|
-
},
|
|
129
|
-
}
|
|
130
|
-
const sentinel = await MemorySentinel.create(params)
|
|
131
|
-
sentinel.on('reportEnd', (args) => {
|
|
132
|
-
const { outPayloads } = args as ReportEndEventArgs
|
|
133
|
-
expect(outPayloads?.length).toBeGreaterThan(0)
|
|
134
|
-
})
|
|
135
|
-
await node.register(sentinel)
|
|
136
|
-
await node.attach(sentinel.address)
|
|
137
|
-
// using a wrapper to trigger archiving
|
|
138
|
-
const wrapper = SentinelWrapper.wrap(sentinel, await Account.random())
|
|
139
|
-
const result = await wrapper.report()
|
|
140
|
-
assertPanelReport(result)
|
|
141
|
-
await assertArchivistStateMatchesPanelReport(result, [archivistA, archivistB])
|
|
142
|
-
})
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
})
|