Skip to content

Commit

Permalink
Add missing tests (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw-glogowski authored Jan 26, 2021
1 parent 190e12d commit c876b56
Show file tree
Hide file tree
Showing 59 changed files with 1,420 additions and 55 deletions.
40 changes: 27 additions & 13 deletions .github-pages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,43 @@
[![NPM version][npm-image]][npm-url]

```bash
$ npm i ethers@^5.0.8 reflect-metadata@^0.1.13 rxjs@^6.6.2 -S
$ npm i etherspot -S
$ npm i ws -s # node.js only
```

install `peerDependencies`:
## Usage

```bash
$ npm i ethers@^5.0.8 reflect-metadata@^0.1.13 rxjs@^6.6.2 -S
```
```typescript
import { Sdk, randomPrivateKey } from 'etherspot';

install `ws` (node.js only):
const PRIVATE_KEY = randomPrivateKey();

```bash
$ npm i ws -S
```
async function main() {
const sdk = new Sdk(PRIVATE_KEY);

## Usage
sdk.notifications$.subscribe(notification => console.log('notification:', notification));

```typescript
import { Sdk } from 'etherspot';
import { Wallet } from 'ethers';
await sdk.computeContractAccount();

const { account } = sdk.state;

console.log('contract account:', account);

// top-up contract account (account.address)

// add transaction to gateway batch
await sdk.batchExecuteAccountTransaction({
to: '0xEEb4801FBc9781EEF20801853C1Cb25faB8A7a3b',
value: 100, // 100 wei
});

console.log('gateway batch estimation:', await sdk.estimateGatewayBatch());

const sdk = new Sdk(Wallet.createRandom());
console.log('submitted gateway batch:', await sdk.submitGatewayBatch());
}

main().catch(console.error);
```

## Resources
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/run-linter-and-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run linter and tests
on:
push:
branches-ignore:
- master
- develop
paths:
- '**.js'
- '**.json'
- '**.ts'
jobs:
start:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup node.js
uses: actions/setup-node@v1
with:
node-version: 10.x

- name: Determine npm cache directory
id: npm-cache
run: echo "::set-output name=dir::$(npm config get cache)"

- name: Restore npm cache
uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci

- name: Run linter
run: npm run lint

- name: Run unit tests
run: npm run test:unit
48 changes: 31 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,44 @@

## Installation

```bash
$ npm i etherspot -S
```

install `peerDependencies`:

```bash
$ npm i ethers@^5.0.8 reflect-metadata@^0.1.13 rxjs@^6.6.2 -S
```

install `ws` (node.js only):

```bash
$ npm i ws -S
$ npm i etherspot -S
$ npm i ws -s # node.js only
```

## Usage

```typescript
import { Sdk } from 'etherspot';
import { Wallet } from 'ethers';

const sdk = new Sdk(Wallet.createRandom());

import { Sdk, randomPrivateKey } from 'etherspot';

const PRIVATE_KEY = randomPrivateKey();

async function main() {
const sdk = new Sdk(PRIVATE_KEY);

sdk.notifications$.subscribe(notification => console.log('notification:', notification));

await sdk.computeContractAccount();

const { account } = sdk.state;

console.log('contract account:', account);

// top-up contract account (account.address)

// add transaction to gateway batch
await sdk.batchExecuteAccountTransaction({
to: '0xEEb4801FBc9781EEF20801853C1Cb25faB8A7a3b',
value: 100, // 100 wei
});

console.log('gateway batch estimation:', await sdk.estimateGatewayBatch());

console.log('submitted gateway batch:', await sdk.submitGatewayBatch());
}

main().catch(console.error);
```

## Resources
Expand Down
9 changes: 9 additions & 0 deletions cucumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
default: [
'--publish-quiet', //
'--require-module ts-node/register',
'--require test/world.ts',
'--require test/steps/**/*.ts',
'test/features/**/*.feature',
].join(' '),
};
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Prerequisites

* Start [local backend](https://github.com/etherspot/etherspot-backend-monorepo)
* Start [local infra](https://github.com/etherspot/etherspot-infra)

## Usage

Expand Down
Loading

0 comments on commit c876b56

Please sign in to comment.