-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add option to dump txs while triaging * feat: not crashing on invalid IDLs, but returning failures instead
- Loading branch information
Showing
12 changed files
with
196 additions
and
38 deletions.
There are no files selected for viewing
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
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
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,21 @@ | ||
import path from 'path' | ||
import fs from 'fs/promises' | ||
import { TransactionInfo } from '../types' | ||
|
||
async function dumpTx(dirname: string, tx: TransactionInfo) { | ||
const sig = tx.transaction.signatures[0] | ||
const json = JSON.stringify(tx, null, 2) | ||
const filename = path.join(dirname, `${tx.slot}.${sig}.json`) | ||
|
||
return fs.writeFile(filename, json, 'utf8') | ||
} | ||
|
||
export async function dumpTxs(txs: TransactionInfo[]) { | ||
const dumpTxsSubdir = process.env.DUMP_TXS | ||
if (dumpTxsSubdir == null) return | ||
|
||
// NOTE: __dirname is broken when running with esr | ||
const dirname = path.join(process.cwd(), 'txs', dumpTxsSubdir) | ||
await fs.mkdir(dirname, { recursive: true }) | ||
return Promise.all(txs.map((tx) => dumpTx(dirname, tx))) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import spok, { Specifications, TestContext } from 'spok' | ||
import assert from 'assert/strict' | ||
import { IdlFailure } from '../../../../src/mudlands' | ||
|
||
export function checkFailures( | ||
t: TestContext, | ||
expect: { | ||
idlAddress: string | ||
txsFound: boolean | ||
idlAccountFound: boolean | ||
len: number | ||
}, | ||
failures: IdlFailure[] | ||
) { | ||
assert.equal(failures.length, expect.len) | ||
if (!expect.txsFound) { | ||
const failure = failures.shift() | ||
spok(t, failure, <Specifications<IdlFailure>>{ | ||
$topic: 'txsNotFound failure', | ||
err: (err: any) => spok.test(/unable to find transactions/i)(err.message), | ||
}) | ||
} | ||
if (!expect.idlAccountFound) { | ||
const failure = failures.shift() | ||
spok(t, failure, <Specifications<IdlFailure>>{ | ||
$topic: 'idlAccountNotFound failure', | ||
addr: expect.idlAddress, | ||
err: (err: any) => | ||
spok.test(/unable to find idl at address/i)(err.message), | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.