83 lines
3.5 KiB
TypeScript
83 lines
3.5 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import {
|
|
getUrls, getNetwork, getZooChainId, getLuxChainId,
|
|
ethBlockNumber, ethChainId,
|
|
getNetworkId, getBlockchains,
|
|
benchmarkRpc,
|
|
} from './helpers'
|
|
|
|
const urls = getUrls()
|
|
const network = getNetwork()
|
|
|
|
// -- Cross-Chain: Zoo + Lux both live -------------------------------------
|
|
test.describe('Cross-Chain — Zoo and Lux', () => {
|
|
test('both Zoo and Lux C-Chain produce blocks', async ({ request }) => {
|
|
let zooBlock = 0
|
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
try {
|
|
zooBlock = await ethBlockNumber(request, urls.rpcZoo)
|
|
break
|
|
} catch {
|
|
if (attempt < 2) await new Promise(r => setTimeout(r, 1000))
|
|
}
|
|
}
|
|
const luxBlock = await ethBlockNumber(request, urls.rpcLux)
|
|
console.log(` Zoo=${zooBlock.toLocaleString()} Lux=${luxBlock.toLocaleString()}`)
|
|
expect(zooBlock).toBeGreaterThan(0)
|
|
expect(luxBlock).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('Zoo and Lux have distinct chain IDs', async ({ request }) => {
|
|
const zooId = await ethChainId(request, urls.rpcZoo)
|
|
const luxId = await ethChainId(request, urls.rpcLux)
|
|
console.log(` Zoo chainId=${zooId} Lux chainId=${luxId}`)
|
|
expect(zooId).toBe(getZooChainId())
|
|
expect(luxId).toBe(getLuxChainId())
|
|
expect(zooId).not.toBe(luxId)
|
|
})
|
|
|
|
test('Lux network ID matches expected', async ({ request }) => {
|
|
const nid = await getNetworkId(request, urls.rpcInfo)
|
|
const expected: Record<string, string> = { mainnet: '1', testnet: '2', devnet: '3' }
|
|
console.log(` networkID: ${nid} (expected ${expected[network]})`)
|
|
expect(nid).toBe(expected[network])
|
|
})
|
|
})
|
|
|
|
// -- Platform: Zoo subnet is registered -----------------------------------
|
|
test.describe('Platform — Zoo Subnet Registration', () => {
|
|
test('Zoo appears in registered blockchains', async ({ request }) => {
|
|
// Gateway load balancing may return partial results; retry up to 3 times
|
|
let names: string[] = []
|
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
const chains = await getBlockchains(request, urls.rpcPlatform) as { name: string; subnetID: string }[]
|
|
names = chains.map(c => c.name)
|
|
if (names.some(n => n.toLowerCase().includes('zoo'))) break
|
|
if (attempt < 2) await new Promise(r => setTimeout(r, 1000))
|
|
}
|
|
console.log(` blockchains: ${names.length} (${names.join(', ')})`)
|
|
// Zoo subnet should be registered on the platform
|
|
const hasZoo = names.some(n => n.toLowerCase().includes('zoo'))
|
|
expect(hasZoo).toBe(true)
|
|
})
|
|
|
|
test('>= 3 blockchains registered (P/C/X + subnets)', async ({ request }) => {
|
|
const chains = await getBlockchains(request, urls.rpcPlatform) as { name: string }[]
|
|
console.log(` total blockchains: ${chains.length}`)
|
|
expect(chains.length).toBeGreaterThanOrEqual(3)
|
|
})
|
|
})
|
|
|
|
// -- Cross-Chain Latency Comparison ---------------------------------------
|
|
test.describe('Cross-Chain Latency Comparison', () => {
|
|
test('Zoo vs Lux C-Chain latency', async ({ request }) => {
|
|
const zooBench = await benchmarkRpc(request, urls.rpcZoo, 'eth_blockNumber')
|
|
const luxBench = await benchmarkRpc(request, urls.rpcLux, 'eth_blockNumber')
|
|
console.log(` Zoo: avg=${zooBench.avg}ms p50=${zooBench.p50}ms p99=${zooBench.p99}ms errors=${zooBench.errors}`)
|
|
console.log(` Lux: avg=${luxBench.avg}ms p50=${luxBench.p50}ms p99=${luxBench.p99}ms errors=${luxBench.errors}`)
|
|
// Both should be responsive
|
|
expect(zooBench.errors).toBeLessThanOrEqual(5)
|
|
expect(luxBench.errors).toBeLessThanOrEqual(5)
|
|
})
|
|
})
|