This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: generate a expectedTransformData.json (#1329)
* feat: generate expectedTransformData.json and fix test * fix: comment * fix: fmt * fix: comment and hardcoded path * fix: testConstant
- Loading branch information
Showing
6 changed files
with
215,970 additions
and
31,622 deletions.
There are no files selected for viewing
42,314 changes: 42,314 additions & 0 deletions
42,314
indexer/src/test-data/expectedTransformData.json
Large diffs are not rendered by default.
Oops, something went wrong.
205,124 changes: 173,523 additions & 31,601 deletions
205,124
indexer/src/test-data/transactionsData.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Path to the JSON file containing real transaction data | ||
export const TRANSACTIONS_DATA_FILE = | ||
"indexer/src/test-data/transactionsData.json"; | ||
|
||
// Path to the JSON file containing the expected data trasformed with transform function and toTypedEthTx | ||
export const EXPECTED_TRANSFORM_DATA_FILE = | ||
"indexer/src/test-data/expectedTransformData.json"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,22 @@ import { | |
import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts"; | ||
import { Common } from "https://esm.sh/v135/@ethereumjs/[email protected]/denonext/common.mjs"; | ||
import { ExtendedJsonRpcTx } from "./interfaces.ts"; | ||
import { | ||
EXPECTED_TRANSFORM_DATA_FILE, | ||
TRANSACTIONS_DATA_FILE, | ||
} from "../testConstants.ts"; | ||
|
||
// Transaction data including headers, events, and transactions | ||
const jsonTransactionsData = await Deno.readTextFile( | ||
TRANSACTIONS_DATA_FILE, | ||
); | ||
const transactionsData = JSON.parse(jsonTransactionsData); | ||
|
||
const jsonData = await Deno.readTextFile( | ||
"indexer/src/test-data/transactionsData.json", | ||
// Expected output after transform and toTypedEthTx transformation for comparison in tests | ||
const jsonExpectedTransformData = await Deno.readTextFile( | ||
EXPECTED_TRANSFORM_DATA_FILE, | ||
); | ||
const transactionsData = JSON.parse(jsonData); | ||
const expectedTransformData = JSON.parse(jsonExpectedTransformData); | ||
|
||
// Utility functions | ||
function createReceipt( | ||
|
@@ -551,11 +562,19 @@ Deno.test("toTypedEthTx EIP2930 Transaction before release with 31 bytes chunks | |
|
||
Deno.test("toTypedEthTx with real data", () => { | ||
transactionsData.transactionsList.forEach( | ||
(transactions: TransactionWithReceipt[]) => { | ||
const ethTx = toTypedEthTx({ | ||
transaction: transactions[0].transaction, | ||
}) as LegacyTransaction; | ||
assertExists(ethTx); | ||
(transactions: TransactionWithReceipt[], outerIndex: number) => { | ||
transactions.map((transaction, innerIndex) => { | ||
const ethTx = toTypedEthTx({ | ||
transaction: transaction.transaction, | ||
}); | ||
assertEquals( | ||
JSON.stringify(ethTx), | ||
JSON.stringify( | ||
expectedTransformData | ||
.expectedToTypedEthTxTransactions[outerIndex][innerIndex], | ||
), | ||
); | ||
}); | ||
}, | ||
); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters