开发者社区> 镜像站> NPM> tape-parity
tape-parity
Tape extension that adds a Parity dev chain and Nanoeth helpers
Last updated 4 months ago by emilbayes .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tape-parity 
SYNC missed versions from official npm registry.

tape-parity

Build Status

Tape extension that adds a Parity dev chain and Nanoeth helpers

Usage

var test = require('tape-parity')

test('fund', async function (t) {
  await t.fund('0xd27E44f7F4118DB2c7812A363f5B76859c20e0b3', 10000)

  console.log(parseInt(await t.eth.getBalance('0xd27E44f7F4118DB2c7812A363f5B76859c20e0b3')))
})

API

A fresh Parity dev chain will created before each test and closed after all tests finish.

test([description], async t => {})

Create a new test just like in tape. t is extended with extra methods specified below:

t.eth

This is a nanoeth instance connected to the Parity dev chain.

await t.fund(address, value, [data])

Fund address with value wei and optional data. Await the transaction to be mined. value can be Number, BigInt or hex encoded string.

const receipt = await t.mined(txHash)

Await txHash to be mined and return the transaction receipt.

const account = await t.keygen([privateKey])

Generate a new account of { publicKey, privateKey, address }. Uses the current chainId.

const account = await t.keygenSeed(seed)

Generate a new account of { publicKey, privateKey, address } from a seed, which can be either a Buffer or string. Useful for deterministic tests and debugging traces. Uses the current chainId.

const txHash = await t.send({ from, to, data, nonce, value = 0, gasPrice = 1, gas = 8e6 }, privateKey)

Sign and send a new transaction with the above parameters. Note the privateKey at the end required for signing.

Examples:

  • To deploy a contract, send with { from, data }.
  • To transfer funds, send with { to, value }.
  • To call a smart contract, send with { to, data }.

const json = await t.trace(rawTx, [opts])

Trace a raw transaction, returning the various diagnostics. opts defaults to ['trace', 'vmTrace', 'stateDiff']. Requires that parity has been started with the tracing module enabled. The output is a JSON object, and can be stringified and persisted to disk for further analysis.

Install

npm install tape-parity

License

ISC

Current Tags

  • 1.2.0                                ...           latest (4 months ago)

3 Versions

  • 1.2.0                                ...           4 months ago
  • 1.1.0                                ...           6 months ago
  • 1.0.0                                ...           6 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (12)
Dev Dependencies (0)
None
Dependents (0)
None