import chai from 'chai' import * as ganache from 'ganache' // External import { once } from 'events' import { solidity } from 'ethereum-waffle' import { providers, BigNumber } from 'ethers' import { parseUnits } from 'ethers/lib/utils' // @ts-expect-error import { parseIndexableString } from 'pouchdb-collate' // Local import { ERC20, TornadoInstance } from './deth' import { Files, Onchain, RelayerProperties } from '@tornado/sdk-data' import { Chain, Contracts } from '@tornado/sdk-chain' import { ErrorUtils } from '@tornado/sdk-utils' import { TorProvider } from '@tornado/sdk-web' import { Registry } from '@tornado/sdk-registry' chai.use(solidity) const expect = chai.expect describe('Registry', () => { const torify = process.env.TORIFY === 'true' const debug = process.env.DEBUG === 'true' if (!process.env.ETH_MAINNET_TEST_RPC) throw ErrorUtils.getError('need a mainnet rpc endpoint.') const mainnetProvider: providers.Provider = torify ? new TorProvider(process.env.ETH_MAINNET_TEST_RPC!, { port: +process.env.TOR_PORT! }) : new providers.JsonRpcProvider(process.env.ETH_MAINNET_TEST_RPC) describe('Synchronization', () => { let registry: Registry let logListener = function (...args: any[]) { if (args.length === 3) { console.debug(`\nSync will be started with SB: ${args[0]}, TB: ${args[1]}, BD: ${args[2]}\n`) } else if (args.length == 2) { console.debug(`Syncing from block ${args[0]} to ${args[1]}`) } } before(async function () { this.timeout(0) registry = new Registry() await registry.connect(mainnetProvider) if (debug) registry.on('debug', logListener) }) after(async function () { this.timeout(0) if (debug) registry.off('debug', logListener) }) it('Should be able to sync all registration events', async () => { console.log('\n ♻️ Syncing ' + 'Registrations' + '\n') await registry.syncRegistrations() await registry.exportRegistrationsJson() console.log() }).timeout(0) it('Should be able to sync all stake events', async () => { console.log('\n ♻️ Syncing ' + 'Stakes' + '\n') await registry.syncStakes() await registry.exportStakesJson() console.log() }).timeout(0) it('Should be able to sync all burn events', async () => { console.log('\n ♻️ Syncing ' + 'Burns' + '\n') await registry.syncBurns() await registry.exportBurnsJson() console.log() }).timeout(0) }) })