Skip to content

Commit

Permalink
Merge pull request #35 from hummingbot/fix/fix-remove-wallet-test
Browse files Browse the repository at this point in the history
(fix) change fs-extra remove fn name
  • Loading branch information
fengtality authored Feb 21, 2023
2 parents dc32d6d + 0843db6 commit fef921a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 67 deletions.
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`);
}

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

0 comments on commit fef921a

Please sign in to comment.