Skip to content

Commit

Permalink
Revert test sript
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Oct 26, 2023
1 parent 9eecf44 commit 81c5f08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
36 changes: 19 additions & 17 deletions l1-verifier/scripts/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { fork, spawn, execSync } = require('node:child_process');
const { fork } = require('node:child_process');
const ganache = require('ganache');
const options = {
logging: {
Expand All @@ -10,34 +10,36 @@ async function main() {
const server = ganache.server(options);
console.log('Starting server');
const port = await new Promise((resolve, reject) => {
server.listen(8888, async (err) => {
server.listen(0, async (err) => {
console.log(`Listening on port ${server.address().port}`);
if (err) reject(err);
resolve(server.address().port);
});
});

console.log('Starting hardhat');

const code = await new Promise((resolve, reject) => {
const hh = spawn('hardhat', ['test', '--network', 'ganache'], {
stdio: 'inherit'
});
hh.on('close', (code) => {
console.log('Shutting down');
server.close();
if (code === 0) {
resolve(code);
process.exit(code);
} else {
reject(code);
const code = await new Promise((resolve) => {
const hh = fork(
'node_modules/.bin/hardhat',
['test', '--network', 'ganache'],
{
stdio: 'inherit',
env: {
RPC_PORT: port.toString(),
},
}
});
);
hh.on('close', (code) => resolve(code));
});

console.log('Shutting down');
server.close();
process.exit(code);
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
process.exit(error);
console.error(error);
process.exitCode = 1;
});
5 changes: 3 additions & 2 deletions l1-verifier/test/testL1Verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/
import type { HardhatEthersHelpers } from '@nomicfoundation/hardhat-ethers/types';
import { expect } from 'chai';
import {
BrowserProvider,
Contract,
FetchRequest,
JsonRpcProvider,
Expand All @@ -29,15 +30,15 @@ declare module 'hardhat/types/runtime' {
}

describe('L1Verifier', () => {
let provider: JsonRpcProvider;
let provider: BrowserProvider;
let signer: Signer;
let verifier: Contract;
let target: Contract;

before(async () => {
// Hack to get a 'real' ethers provider from hardhat. The default `HardhatProvider`
// doesn't support CCIP-read.
provider = new ethers.JsonRpcProvider('http://localhost:8888');
provider = new ethers.BrowserProvider(ethers.provider._hardhatProvider);
// provider.on("debug", (x: any) => console.log(JSON.stringify(x, undefined, 2)));
signer = await provider.getSigner(0);
const gateway = makeL1Gateway(provider as unknown as JsonRpcProvider);
Expand Down

0 comments on commit 81c5f08

Please sign in to comment.