Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
moraleinside committed Sep 16, 2022
1 parent 1b69488 commit 2481799
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
37 changes: 27 additions & 10 deletions test/RPC/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
// import './getViteFromWorld';
const assert = require('assert');

import walletTest from './wallet';
import dexTest from './dex';
import receiveAccountBlock from './receiveAccountBlock';

async function TestFunc() {
await walletTest();
await dexTest();
await receiveAccountBlock();
}
describe('RPC Test', function () {
it('wallet test', async () => {
await walletTest();
assert.ok(true);
}).timeout(600000);

TestFunc().then(() => {
console.log("Wallet Happy Ending, yes!");
}).catch(err => {
console.log("Oooooh, Got Error!", err);
it('dex test', async () => {
await dexTest();
assert.ok(true);
}).timeout(600000);

it('receive txs', async () => {
await receiveAccountBlock();
assert.ok(true);
}).timeout(600000);
});

// async function TestFunc() {
// await walletTest();
// await dexTest();
// await receiveAccountBlock();
// }

// TestFunc().then(() => {
// console.log("Wallet Happy Ending, yes!");
// }).catch(err => {
// console.log("Oooooh, Got Error!", err);
// });
5 changes: 4 additions & 1 deletion test/RPC/receiveAccountBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export default async function start() {
console.log('success', result);
if(!result.accountBlockList) {
ReceiveTask.stop();
if (viteProvider.subscribe) {
viteProvider._provider.destroy();
}
}
});
ReceiveTask.onError((error) => {
Expand All @@ -42,7 +45,7 @@ export default async function start() {

async function SendTxToMyself(previousAccountBlock) {
const accountBlock = await tx.send({
toAddress: address,
toAddress: address,
tokenId: Vite_TokenId,
amount: '10000000000000000000'
});
Expand Down
8 changes: 6 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ describe('ViteAPI Test: src/viteAPI', function () {
require('./packages/viteAPI/ws');
});

require('./packages/accountBlock/account');
describe('AccountBlock Test', function () {
require('./packages/accountBlock/account');
});

// viteAPI
// http
// ipc
// ws
require('./RPC/index.js');
describe('RPC Test', function () {
require('./RPC/index.js');
});
6 changes: 4 additions & 2 deletions test/packages/viteAPI/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Provider, {
import WS_RPC from '../../../src/WS';
import HTTP_RPC from '../../../src/HTTP';
import IPC_RPC from '../../../src/IPC';
import {sleep, tx, waitUntil} from '../../RPC/utils';
import {sleep, tx, viteProvider, waitUntil} from '../../RPC/utils';
import {Vite_TokenId} from '../../../src/constant/index';

const abi = require('../../../src/abi/index');
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('test provider and connect handlers', () => {
}, new NoReconnectHandler());
tx.setProvider(_provider);

const event = await newOnroadBlocksByAddr(config.address, _provider);
const event = await newAccountBlockByAddress(config.address, _provider);
event.on(result => {
console.log(result);
assert.fail(); // we should not receive event
Expand Down Expand Up @@ -327,6 +327,8 @@ describe('test provider and connect handlers', () => {

after(() => {
wsServer.destroy();
// reset provider
tx.setProvider(viteProvider);
});
});

Expand Down

0 comments on commit 2481799

Please sign in to comment.