Skip to content

Commit

Permalink
Improve build output and export everything
Browse files Browse the repository at this point in the history
  • Loading branch information
guilledk committed Dec 12, 2023
1 parent c983ed2 commit 4eca0f1
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 21 deletions.
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
{
"name": "leap-mock",
"name": "@guilledk/leap-mock",
"repository": "guilledk/leap-mock",
"version": "0.1.0",
"description": "AntelopeIO/leap mocker for advanced indexer testing",
"main": "./build/src/main.js",
"main": "./build/main.js",
"type": "module",
"exports": {
".": {
"import": "./build/src/main.js"
}
".": "./**/*.js"
},
"type": "module",
"scripts": {
"bootstrap": "sh -c 'yarn && cd node_modules/@eosrio/hyperion-sequential-reader && npm i && npx tsc'",
"build": "npm run bootstrap && tsc && node scripts/create-dist-packages.mjs",

"start": "node build/src/main.js",

"test": "mocha build/tests/**/*.spec.js --timeout 120000",

"docker-build": "npm run build && node scripts/docker-build.mjs",
Expand All @@ -31,7 +28,6 @@
"@types/ws": "^8.5.8",
"async": "^3.2.4",
"axios": "^1.6.2",
"chai": "^4.3.10",
"commander": "^11.1.0",
"express": "^4.18.2",
"winston": "^3.11.0",
Expand All @@ -43,6 +39,7 @@
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.4",
"chai": "^4.3.10",
"mocha": "^10.2.0",
"nodemon": "^2.0.22",
"ts-node": "^10.9.2",
Expand Down
2 changes: 1 addition & 1 deletion scripts/create-dist-packages.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import path from 'path';

const currentDir = path.dirname(fileURLToPath(import.meta.url));
const src = path.join(currentDir, '../src/shipAbi.json');
const dest = path.join(currentDir, '../build/src/shipAbi.json');
const dest = path.join(currentDir, '../build/shipAbi.json');

copyFileSync(src, dest);
2 changes: 1 addition & 1 deletion scripts/docker-stop.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {spawn} from "child_process";

// Spawn the process
const process = spawn('docker', ['kill', '--signal=SIGINT', 'leap-mock']);
const process = spawn('docker', ['kill', 'leap-mock']);

// Handle standard output
process.stdout.on('data', (data) => {
Expand Down
2 changes: 1 addition & 1 deletion src/controllerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import controllerRouter from "./controllerRoutes.js";
import * as http from "http";
import process from "process";
import ControllerHTTPClient from "./controllerHTTPClient.js";
import {generateTestChainDescriptor} from "../tests/utils.js";
import {generateTestChainDescriptor} from "./tests/utils.js";
import logger from "./logging.js";

process.on('unhandledRejection', error => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ControllerContext} from "../src/controllerUtils.js";
import {ControllerConfig} from "../src/controller.js";
import {getRandomPort} from "../src/utils.js";
import {ControllerContext} from "../controllerUtils.js";
import {ControllerConfig} from "../controller.js";
import {getRandomPort} from "../utils.js";
import {expectSequence} from "./utils.js";


Expand Down Expand Up @@ -38,7 +38,7 @@ describe('Hyperion In Order Sequence', async function () {
context.registerTestChain(testForkDoubleName, {
jumps: [[5, 3], [6, 6]]});
it(testForkDoubleName, async function () {
const chainInfo = context.getTestChain(testForkName);
const chainInfo = context.getTestChain(testForkDoubleName);
return await expectSequence(
chainInfo,
[
Expand All @@ -59,7 +59,7 @@ describe('Hyperion In Order Sequence', async function () {
context.registerTestChain(testReconMultiName, {
pauses: [[3, 2], [10, 2]]});
it(testReconMultiName, async function () {
const chainInfo = context.getTestChain(testReconName);
const chainInfo = context.getTestChain(testReconMultiName);
return await expectSequence(chainInfo, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]);
});
});
9 changes: 5 additions & 4 deletions tests/utils.ts → src/tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {ChainDescriptor, NewChainInfo} from "../src/controller.js";
import {ChainDescriptor, NewChainInfo} from "../controller.js";
import {HyperionSequentialReader} from "@eosrio/hyperion-sequential-reader";
import {sleep, randomHash} from "../src/utils.js";
import {sleep, randomHash} from "../utils.js";
import {assert} from "chai";
import logging from "../logging.js";

export function generateTestChainDescriptor(
chainId?: string,
Expand Down Expand Up @@ -39,13 +40,13 @@ export async function expectSequence(
blockConcurrency: 1,
outputQueueLimit: 10,
startBlock: 1,
logLevel: 'debug'
logLevel: logging.level
});
reader.onDisconnect = async () => {
if (!isExpectedSequence || reachedEnd)
return;

reader.log('warning', `reader disconnected, restarting in 3 seconds...`);
logging.info(`reader disconnected, restarting in 3 seconds...`);
await sleep(3 * 1000);
reader.restart();
};
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"baseUrl": "src",
"module": "esnext",
"outDir": "build",
"rootDir": "./src",
"target": "esnext",
"moduleResolution": "node",
"declaration": true,
Expand All @@ -27,5 +28,5 @@
},
"compileOnSave": false,
"exclude": ["node_modules", "dist", "build"],
"include": ["src", "tests"]
"include": ["src/**/*.ts"]
}
9 changes: 9 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
enabled "2.0.x"
kuler "^2.0.0"

"@eosrio/hyperion-sequential-reader@https://github.com/eosrio/hyperion-sequential-reader.git#hist_buf_size":
version "1.2.5"
resolved "https://github.com/eosrio/hyperion-sequential-reader.git#87839c6cfa5b2a5df017c36bb65e7edd17ae80ba"
dependencies:
"@greymass/eosio" "0.6.11"
async "^3.2.4"
node-fetch "^3.3.0"
ws "^8.13.0"

"@esbuild/android-arm64@0.18.20":
version "0.18.20"
resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz#984b4f9c8d0377443cc2dfcef266d02244593622"
Expand Down

0 comments on commit 4eca0f1

Please sign in to comment.