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

lopt-test

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lopt-test

Mocking framework for Solidity contracts

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

lopt

NPM Package

lopt is a utility package that can generate mock Solidity contracts in the form of fakes and mocks.

lopt is based in @eth-optimism/smock, sinon and sinon-chai.

Some benefits of using lopt:

  • Test syntax is easy to understand, just like sinon-chai
  • Supports both chai expect and should syntax
  • Fully typed objects, that will extend your contract functions when using typechain (highly recommended)
  • Mock and assert contract calls, without the need of even deploying it by using fakes
  • If you need your contract logic, just wrap it in a mock and start asserting calls or changing behaviour
  • Fully tested library

Documentation

Documentation is available here.


Installation

You can easily install lopt via npm:

npm install --save-dev @defi-wonderland/lopt

Or via yarn:

yarn add --dev @defi-wonderland/lopt

How to use

...
import { FakeContract, lopt } from '@defi-wonderland/lopt';

chai.should(); // if you like should syntax
chai.use(lopt.matchers);

describe('MyContract', () => {
    let myContractFake: FakeContract<MyContract>;

    beforeEach(async () => {
        ...
        myContractFake = await lopt.fake<MyContract>('MyContract');
    });

    it('some test', () => {
        ...
        myContractFake.bark.atCall(0).should.be.calledWith('Hello World');
    });
});

Why the name lopt?

Loki's alternative name is Lopt, and Loki was obviously taken.

Loki is the God of Mischief, a trickster, and the purpose of mocking libraries is basically to trick the tests.

Keywords

FAQs

Package last updated on 21 Jul 2021

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