Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mole-rpc-autotester

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mole-rpc-autotester

Automatic tester for mole-rpc transport packages

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

mole-rpc-autotester

Automatic tester for Mole-RPC (JSON-RPC library) transports.

If you writes own transport for Mole-RPC then use this module to be sure that your transport covers as expected.

This module does end-to-end testing and will:

  • Run simple positive tests for simpleClient
  • Run simple positive notification tests for simpleClient
  • Run positive batch tests for simpleClient
  • Run simple positive tests for proxifiedClient
  • Run simple positive notification tests for proxifiedClient
  • Run proxy positive tests for proxifiedClient
  • Run proxy positive notification tests for proxifiedClient
  • Run simple negative tests for simpleClient
  • Run simple negative tests for proxifiedClient
  • Run proxy negative tests for proxifiedClient
  • It will test both sync and async calls
  • Will test method execution errors

This modules covers a lot of cases but it does not help you with detecting memory leaks, reconnection problems etc.

How to use it?

This example covers almose all of the API of the module.

Do not forget to add 'mole-rpc' and 'mole-rpc-autotester' to devDependencies of your transport's package.json.

const AutoTester = require('mole-rpc-autotester');

const MoleClient = require('mole-rpc/MoleClient');
const MoleClientProxified = require('mole-rpc/MoleClientProxified');
const MoleServer = require('mole-rpc/MoleServer');
const X = require('mole-rpc/X');

// Import your transport
const TransportClient = require('./TransportClient');
const TransportServer = require('./TransportServer');

async function main() {
  const server = await prepareServer();
  const clients = await prepareClients();

  const autoTester = new AutoTester({
    X,
    server,
    simpleClient: clients.simpleClient,
    proxifiedClient: clients.proxifiedClient
  });

  await autoTester.runAllTests();
}

async function prepareServer() {
  return new MoleServer({
    transports: [
        // initialize your transports
        new TransportServer(...)
    ]
  });
}

async function prepareClients() {
  const simpleClient = new MoleClient({
    requestTimeout: 1000, // autotester expects this value
    transport: new TransportClient(...) // initialize your transport
  });

  const proxifiedClient = new MoleClientProxified({
    requestTimeout: 1000, // autotester expects this value
    transport: new TransportClient(...) // initialize your transport
  });

  return { simpleClient, proxifiedClient };
}

main().then(console.log, console.error);

Real examples

You can find more tranports here

Keywords

FAQs

Package last updated on 26 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc