|
| 1 | +import { describe, expect, it } from 'vitest' |
| 2 | + |
| 3 | +import { Arweave, Reader, Sequence } from '../../../src/state/index' |
| 4 | + |
| 5 | +const tests: { [method in keyof Reader]: { [description: string]: Parameters<Reader[method]> } } = { |
| 6 | + getConfiguration: { |
| 7 | + 'image hash: 0xfd32e01d7e814292f49f57e79722ca66423833acf8f25eba770faf3483ff3e78': ['0xfd32e01d7e814292f49f57e79722ca66423833acf8f25eba770faf3483ff3e78'] |
| 8 | + }, |
| 9 | + getDeploy: { |
| 10 | + 'wallet: 0x47E0e44DE649B35Cf7863998Be6C5a7D5d8c63bE': ['0x47E0e44DE649B35Cf7863998Be6C5a7D5d8c63bE'] |
| 11 | + }, |
| 12 | + getWallets: { |
| 13 | + 'signer: 0x94835215CaA1aD3E304F9A7E2148623fe661dEB7': ['0x94835215CaA1aD3E304F9A7E2148623fe661dEB7'] |
| 14 | + }, |
| 15 | + getWalletsForSapient: { |
| 16 | + 'signer: 0x000000000000AB36D17eB1150116371520565205, image hash: 0xeef69774e1cb488a71f6d235c858fa564134ee7c3acda9ff116b6c9d42b3cee3': ['0x000000000000AB36D17eB1150116371520565205', '0xeef69774e1cb488a71f6d235c858fa564134ee7c3acda9ff116b6c9d42b3cee3'] |
| 17 | + }, |
| 18 | + getWitnessFor: { |
| 19 | + 'wallet: 0x47E0e44DE649B35Cf7863998Be6C5a7D5d8c63bE, signer: 0x94835215CaA1aD3E304F9A7E2148623fe661dEB7': ['0x47E0e44DE649B35Cf7863998Be6C5a7D5d8c63bE', '0x94835215CaA1aD3E304F9A7E2148623fe661dEB7'] |
| 20 | + }, |
| 21 | + getWitnessForSapient: { |
| 22 | + 'wallet: 0x47E0e44DE649B35Cf7863998Be6C5a7D5d8c63bE, signer: 0x000000000000AB36D17eB1150116371520565205, image hash: 0xeef69774e1cb488a71f6d235c858fa564134ee7c3acda9ff116b6c9d42b3cee3': ['0x47E0e44DE649B35Cf7863998Be6C5a7D5d8c63bE', '0x000000000000AB36D17eB1150116371520565205', '0xeef69774e1cb488a71f6d235c858fa564134ee7c3acda9ff116b6c9d42b3cee3'] |
| 23 | + }, |
| 24 | + getConfigurationUpdates: {}, |
| 25 | + getTree: { |
| 26 | + 'image hash: 0xeef69774e1cb488a71f6d235c858fa564134ee7c3acda9ff116b6c9d42b3cee3': ['0xeef69774e1cb488a71f6d235c858fa564134ee7c3acda9ff116b6c9d42b3cee3'] |
| 27 | + }, |
| 28 | + getPayload: {}, |
| 29 | +} |
| 30 | + |
| 31 | +function normalize(value: any): any { |
| 32 | + return value |
| 33 | +} |
| 34 | + |
| 35 | +describe('Arweave state reader', () => { |
| 36 | + const arweave = new Arweave.Reader() |
| 37 | + const sequence = new Sequence.Provider() |
| 38 | + |
| 39 | + const methods = Object.entries(tests).filter(([, methodTests]) => Object.keys(methodTests).length > 0) |
| 40 | + if (methods.length === 0) { |
| 41 | + it.skip('no configured test cases', () => {}) |
| 42 | + } |
| 43 | + |
| 44 | + for (const [method, methodTests] of methods) { |
| 45 | + describe(method, () => { |
| 46 | + for (const [description, args] of Object.entries(methodTests)) { |
| 47 | + it(description, async () => { |
| 48 | + const [actual, expected] = await Promise.all([arweave[method](...args), sequence[method](...args)]) |
| 49 | + expect(normalize(actual)).toEqual(normalize(expected)) |
| 50 | + }) |
| 51 | + } |
| 52 | + }) |
| 53 | + } |
| 54 | +}) |
0 commit comments