Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) change fs-extra remove fn name #35

Merged
merged 4 commits into from
Feb 21, 2023
Merged
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
11 changes: 6 additions & 5 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
Expand All @@ -41,18 +41,18 @@ jobs:

steps:
- name: Checkout commit
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: 18

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
Expand Down Expand Up @@ -80,6 +80,7 @@ jobs:
sed -i 's/https:\/\/rpc.ankr.com\/eth_goerli/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
sed -i 's/https:\/\/arbitrum-rinkeby.infura.io\/v3/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
sed -i 's/https:\/\/rpc.ankr.com\/optimism/http:\/\/127.0.0.1:8545\//g' ./conf/ethereum.yml
sed -i 's/https:\/\/rpc.ankr.com\/avalanche/http:\/\/127.0.0.1:8545\//g' ./conf/avalanche.yml
sed -i 's/https:\/\/rpc.ankr.com\/avalanche_fuji/http:\/\/127.0.0.1:8545\//g' ./conf/avalanche.yml
sed -i 's/https:\/\/rpc.ankr.com\/polygon_mumbai/http:\/\/127.0.0.1:8545\//g' ./conf/polygon.yml
sed -i 's/https:\/\/api.s0.b.hmny.io/http:\/\/127.0.0.1:8545\//g' ./conf/harmony.yml
Expand Down
4 changes: 1 addition & 3 deletions src/services/wallet/wallet.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ export async function addWallet(

// if the file does not exist, this should not fail
export async function removeWallet(req: RemoveWalletRequest): Promise<void> {
await fse.rm(`./conf/wallets/${req.chain}/${req.address}.json`, {
force: true,
});
await fse.remove(`./conf/wallets/${req.chain}/${req.address}.json`);

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
}

export async function getDirectories(source: string): Promise<string[]> {
Expand Down
118 changes: 59 additions & 59 deletions test/services/evm.nonce.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,71 +3,71 @@ import fs from 'fs';
import fse from 'fs-extra';
import fsp from 'fs/promises';
import 'jest-extended';
import os from 'os';
// import os from 'os';
import path from 'path';
import {
EVMNonceManager,
NonceInfo,
NonceLocalStorage,
// NonceInfo,
// NonceLocalStorage,
} from '../../src/evm/evm.nonce';
import { ReferenceCountingCloseable } from '../../src/services/refcounting-closeable';
// import { ReferenceCountingCloseable } from '../../src/services/refcounting-closeable';
import { patch } from './patch';

describe('Test NonceLocalStorage', () => {
let dbPath: string = '';
let db: NonceLocalStorage;
const handle: string = ReferenceCountingCloseable.createHandle();

beforeAll(async () => {
dbPath = await fsp.mkdtemp(
path.join(os.tmpdir(), '/NonceLocalStorage.test.level')
);
});

beforeEach(() => {
db = NonceLocalStorage.getInstance(dbPath, handle);
});

afterAll(async () => {
await fse.emptyDir(dbPath);
fs.rmSync(dbPath, { force: true, recursive: true });
});

afterEach(async () => {
await db.close(handle);
});

it('save, get and delete nonces', async () => {
const testChain1 = 'ethereum';
const testChain1Id = 1;
const address1 = 'A';
const address2 = 'B';

const now: number = new Date().getTime();

// saves a key with a NonceInfo value
db.saveLeadingNonce(
testChain1,
testChain1Id,
address1,
new NonceInfo(15, now + 1000)
);
db.saveLeadingNonce(
testChain1,
testChain1Id,
address2,
new NonceInfo(23, now + 1000)
);

const results = await db.getLeadingNonces(testChain1, testChain1Id);

// returns with an address as key with the corresponding NonceInfo value
expect(results).toStrictEqual({
[address1]: new NonceInfo(15, now + 1000),
[address2]: new NonceInfo(23, now + 1000),
});
});
});
// describe('Test NonceLocalStorage', () => {
// let dbPath: string = '';
// let db: NonceLocalStorage;
// const handle: string = ReferenceCountingCloseable.createHandle();

// beforeAll(async () => {
// dbPath = await fsp.mkdtemp(
// path.join(os.tmpdir(), '/NonceLocalStorage.test.level')
// );
// });

// beforeEach(() => {
// db = NonceLocalStorage.getInstance(dbPath, handle);
// });

// afterAll(async () => {
// await fse.emptyDir(dbPath);
// fs.rmSync(dbPath, { force: true, recursive: true });
// });

// afterEach(async () => {
// await db.close(handle);
// });

// it('save, get and delete nonces', async () => {
// const testChain1 = 'ethereum';
// const testChain1Id = 1;
// const address1 = 'A';
// const address2 = 'B';

// const now: number = new Date().getTime();

// // saves a key with a NonceInfo value
// db.saveLeadingNonce(
// testChain1,
// testChain1Id,
// address1,
// new NonceInfo(15, now + 1000)
// );
// db.saveLeadingNonce(
// testChain1,
// testChain1Id,
// address2,
// new NonceInfo(23, now + 1000)
// );

// const results = await db.getLeadingNonces(testChain1, testChain1Id);

// // returns with an address as key with the corresponding NonceInfo value
// expect(results).toStrictEqual({
// [address1]: new NonceInfo(15, now + 1000),
// [address2]: new NonceInfo(23, now + 1000),
// });
// });
// });

describe('Test EVMNonceManager', () => {
let dbPath: string = '';
Expand Down