diff --git a/test/RPC/index.js b/test/RPC/index.js index 077e528c..6e025a33 100644 --- a/test/RPC/index.js +++ b/test/RPC/index.js @@ -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); +// }); diff --git a/test/RPC/receiveAccountBlock.js b/test/RPC/receiveAccountBlock.js index a655052c..b01e25d8 100644 --- a/test/RPC/receiveAccountBlock.js +++ b/test/RPC/receiveAccountBlock.js @@ -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) => { @@ -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' }); diff --git a/test/index.js b/test/index.js index 73f0c88e..eaade466 100644 --- a/test/index.js +++ b/test/index.js @@ -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'); +}); diff --git a/test/packages/viteAPI/ws.js b/test/packages/viteAPI/ws.js index 8f88cb3b..2793406f 100644 --- a/test/packages/viteAPI/ws.js +++ b/test/packages/viteAPI/ws.js @@ -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'); @@ -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 @@ -327,6 +327,8 @@ describe('test provider and connect handlers', () => { after(() => { wsServer.destroy(); + // reset provider + tx.setProvider(viteProvider); }); });