npm.io
1.93.8-next.1 • Published 3 years ago

@hoprnet/hopr-real

Licence
GPL-3.0-only
Version
1.93.8-next.1
Deps
1
Size
23 kB
Vulns
1
Weekly
0
Stars
260
DeprecatedThis package is deprecated

This directory contains Rust WASM modules for HOPR. Each WASM module corresponds to a Rust crate.

Structure

The package itself consists of two parts:

  • the Typescript code - mostly wrappers for JS functions that cannot be called from WASM modules (IO, sockets,...), sometimes called REAL - see #3823.
  • directories containing Rust crates (currently only hopr-real)

During build, all the Rust crates are build first using make all (see Makefile in packages/wasm), then the Typescript sources are built as well.

Usage in Typescript code

Add dependency to @hoprnet/hopr-real to your package.json

import { dummy_get_one } from '@hoprnet/hopr-real'

if (dummy_get_one() === '1') {
  console.log('It works!!')
}

Testing

Each WASM module can have its own unit tests and integration tests.

  • Unit tests are placed within the module file
  • Integration tests are placed in tests/ directory next to src/