mirror of
https://github.com/alexgo-io/xverse-stacks-transaction-sponsor.git
synced 2026-01-12 17:02:16 +08:00
fix: add test dependencies
This commit is contained in:
7
jest.config.js
Normal file
7
jest.config.js
Normal file
@@ -0,0 +1,7 @@
|
||||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
|
||||
module.exports = {
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "node",
|
||||
setupFilesAfterEnv: ["<rootDir>/tests/jest.setup.ts"],
|
||||
roots: ["<rootDir>/tests"],
|
||||
};
|
||||
5654
package-lock.json
generated
5654
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -26,6 +26,7 @@
|
||||
"node-cache": "^5.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.3",
|
||||
"@types/node": "^12.12.6",
|
||||
"@typescript-eslint/eslint-plugin": "^5.58.0",
|
||||
"@typescript-eslint/parser": "^5.58.0",
|
||||
@@ -35,9 +36,11 @@
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"jest": "^29.6.1",
|
||||
"nock": "^13.2.0",
|
||||
"nodemon": "^2.0.15",
|
||||
"prettier": "^2.8.7",
|
||||
"ts-jest": "^29.1.1",
|
||||
"ts-node": "^10.8.1",
|
||||
"typescript": "^4.2.3"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { PayloadType, ContractCallPayload, getAbi, addressToString, StacksTransa
|
||||
|
||||
// rules for transaction sponsorship eligibility
|
||||
// customize this if you are forking this repo
|
||||
export async function validateTransaction(transaction: StacksTransaction) {
|
||||
export async function validateTransaction(transaction: StacksTransaction): Promise<boolean> {
|
||||
if (transaction.payload.payloadType !== PayloadType.ContractCall) {
|
||||
throw new Error('Transaction is not a contract call');
|
||||
}
|
||||
|
||||
19
tests/jest.setup.ts
Normal file
19
tests/jest.setup.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
//mocking the use of env variables, even if .env file changes, it won't affect tests
|
||||
jest.mock("../config/config", () => {
|
||||
return {
|
||||
seed: "xxx",
|
||||
password: "xxx",
|
||||
numAddresses: 3,
|
||||
maxFee: 10,
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock("@stacks/transactions", () => {
|
||||
return Object.assign(
|
||||
{},
|
||||
{
|
||||
...jest.requireActual("@stacks/transactions"),
|
||||
callReadOnlyFunction: jest.fn(),
|
||||
}
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user