Skip to content
This repository was archived by the owner on Feb 4, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions tsscripts/makeDiff.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import * as fs from 'fs';
import csvParser from 'csv-parser';

const ACTUAL_FILE = 'output_actual_view.csv'
const EXPECTED_FILE = 'output_expected_view.csv'
const OUT_TOTALDIFF_FILE = 'totalDiff.json'

const readCSV = async (filePath: string): Promise<any[]> => {
return new Promise((resolve, reject) => {
const results: any[] = [];
fs.createReadStream(filePath)
.pipe(csvParser())
.on('data', (data) => results.push(data))
.on('end', () => {
resolve(results);
})
.on('error', (error) => {
reject(error);
});
});
};

async function makeDiff() {

const actualData = await readCSV(ACTUAL_FILE);
const expectedData = await readCSV(EXPECTED_FILE);

if (actualData.length != expectedData.length) throw "DATA LENGTH DIFFERENT"

let totalDiff : any[] = [];
let indexDiffWhereItShouldnt : any[] = [];

for(let i=0; i<actualData.length; i++) {
if (actualData[i].asset != expectedData[i].asset || actualData[i].reward != expectedData[i].reward || actualData[i].user != expectedData[i].user) {
throw `DATA (user, asset, reward) NOT EQUAL for row ${i}`
}

if (actualData[i].userAccrued != expectedData[i].userAccrued || actualData[i].userIndex != expectedData[i].userIndex) {
totalDiff.push({
actualData: actualData[i],
expectedData: expectedData[i]
})

if (actualData[i].userAccrued != expectedData[i].userAccrued) {
// if (expectedData[i].userAccrued > actualData[i].userAccrued) throw "EXPECTED ACCRUED > ACTUAL ACCRUED"

if (expectedData[i].userIndex != actualData[i].userIndex) {
indexDiffWhereItShouldnt.push({
actualData: actualData[i],
expectedData: expectedData[i]
})

// throw "BOTH INDEX AND ACCRUED DIFFERENT"
}

// todo: add to accruedDiff
}
}
}

console.log(JSON.stringify(indexDiffWhereItShouldnt, null, 2));

fs.writeFileSync(OUT_TOTALDIFF_FILE, JSON.stringify(totalDiff, null, 2));
}

makeDiff();
80 changes: 80 additions & 0 deletions tsscripts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tsscripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "tsscripts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^20.12.12",
"csv-parser": "^3.0.0"
}
}