@cpchain-tools/dapps-test-helpers

0.0.3 • Public • Published

CPChain Test Helpers

This is a library for CPChain smart contract testing.

Overview

Installation

npm install --save-dev @cpchain-tools/dapps-test-helpers

Usage

const {
    BN,
    expect
} = require('@cpchain-tools/dapps-test-helpers');

contract("SafeMathMock", () => {
  let instance = null

  async function testCommutative(fn, lhs, rhs, expected) {
    expect(await fn(lhs, rhs)).to.be.bignumber.equal(expected);
    expect(await fn(rhs, lhs)).to.be.bignumber.equal(expected);
  }

  beforeEach(async ()=> {
    instance = await SafeMathMock.new()
    assert.ok(instance)
  })
  
  it('adds correctly', async function () {
    const a = new BN('5678');
    const b = new BN('1234');

    await testCommutative(instance.add, a, b, a.add(b));
  });
})

Package Sidebar

Install

npm i @cpchain-tools/dapps-test-helpers

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

1.59 kB

Total Files

3

Last publish

Collaborators

  • zhangkai-cpchain
  • cpchain_tech