|
| 1 | +import { type PXE, createCompatibleClient } from '@aztec/aztec.js'; |
| 2 | +import { RollupContract, getPublicClient } from '@aztec/ethereum'; |
| 3 | +import { createLogger } from '@aztec/foundation/log'; |
| 4 | + |
| 5 | +import type { ChildProcess } from 'child_process'; |
| 6 | +import { foundry } from 'viem/chains'; |
| 7 | + |
| 8 | +// import { isK8sConfig, setupEnvironment, startPortForward } from './utils.js'; |
| 9 | + |
| 10 | +// const config = setupEnvironment(process.env); |
| 11 | + |
| 12 | +const debugLogger = createLogger('e2e:spartan-test:smoke'); |
| 13 | + |
| 14 | +describe('smoke test', () => { |
| 15 | + let pxe: PXE; |
| 16 | + const forwardProcesses: ChildProcess[] = []; |
| 17 | + beforeAll(async () => { |
| 18 | + pxe = await createCompatibleClient('http://localhost:8080', debugLogger); |
| 19 | + }); |
| 20 | + |
| 21 | + afterAll(() => { |
| 22 | + forwardProcesses.forEach(p => p.kill()); |
| 23 | + }); |
| 24 | + |
| 25 | + it('should be able to get node enr', async () => { |
| 26 | + const info = await pxe.getNodeInfo(); |
| 27 | + |
| 28 | + debugLogger.info(`info: ${JSON.stringify(info)}`); |
| 29 | + expect(info).toBeDefined(); |
| 30 | + // expect enr to be a string starting with 'enr:-' |
| 31 | + expect(info.enr).toMatch(/^enr:-/); |
| 32 | + }); |
| 33 | + |
| 34 | + // Leaving this test skipped commented out because it requires the ethereum node |
| 35 | + // to be running and forwarded, e.g. |
| 36 | + // kubectl port-forward -n smoke service/spartan-aztec-network-eth-execution 8545:8545 |
| 37 | + // also because it assumes foundry. |
| 38 | + |
| 39 | + it.skip('should be able to get rollup info', async () => { |
| 40 | + // docs:start:get_node_info_pub_client |
| 41 | + const info = await pxe.getNodeInfo(); |
| 42 | + const publicClient = getPublicClient({ |
| 43 | + l1RpcUrls: ['http://localhost:8545'], |
| 44 | + l1ChainId: foundry.id, |
| 45 | + }); |
| 46 | + // docs:end:get_node_info_pub_client |
| 47 | + |
| 48 | + const rollupContract = new RollupContract(publicClient, info.l1ContractAddresses.rollupAddress); |
| 49 | + |
| 50 | + // eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 51 | + const [pendingBlockNum, pendingArchive, provenBlockNum, provenArchive, myArchive, provenEpochNumber] = |
| 52 | + await rollupContract.status(60n); |
| 53 | + // console.log('pendingBlockNum', pendingBlockNum.toString()); |
| 54 | + // console.log('pendingArchive', pendingArchive.toString()); |
| 55 | + // console.log('provenBlockNum', provenBlockNum.toString()); |
| 56 | + // console.log('provenArchive', provenArchive.toString()); |
| 57 | + // console.log('myArchive', myArchive.toString()); |
| 58 | + // console.log('provenEpochNumber', provenEpochNumber.toString()); |
| 59 | + }); |
| 60 | +}); |
0 commit comments