Skip to content

Commit 1e6c692

Browse files
authored
Merge pull request #167 from HathorNetwork/dev
Release v0.11.1
2 parents ac4a34c + 31af56f commit 1e6c692

34 files changed

+4718
-59
lines changed

.eslintrc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"extends": "airbnb-base",
3+
"parser": "@babel/eslint-parser",
4+
"rules": {
5+
"arrow-parens": ["error", "as-needed"],
6+
"import/no-named-as-default": 0,
7+
"import/prefer-default-export": 0,
8+
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
9+
"comma-dangle": 0,
10+
"object-curly-newline": ["error", {"ObjectPattern": { "multiline": true }}],
11+
"eqeqeq": [1, "allow-null"],
12+
"no-continue": 0,
13+
"no-cond-assign": 1,
14+
"no-constant-condition": 0,
15+
"no-control-regex": 1,
16+
"no-debugger": 1,
17+
"no-dupe-keys": 1,
18+
"no-ex-assign": 1,
19+
"no-extra-boolean-cast": 1,
20+
"no-func-assign": 1,
21+
"no-regex-spaces": 1,
22+
"no-unreachable": 1,
23+
"no-fallthrough": 1,
24+
"no-lone-blocks": 1,
25+
"no-delete-var": 1,
26+
"no-shadow": 1,
27+
"no-shadow-restricted-names": 1,
28+
"no-undef": 2,
29+
"no-undef-init": 1,
30+
"no-use-before-define": 0,
31+
"no-unused-vars": [1, {"vars": "all", "args": "none"}],
32+
"no-underscore-dangle": 0,
33+
"no-restricted-syntax": ["error", "LabeledStatement", "WithStatement"],
34+
"no-await-in-loop": "off",
35+
"no-plusplus": "off",
36+
"guard-for-in": "off"
37+
},
38+
"overrides": [
39+
{
40+
"files": [
41+
"**/*.test.js"
42+
],
43+
"env": {
44+
"jest": true
45+
}
46+
}
47+
]
48+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: integration-test
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- dev
7+
tags:
8+
- v*
9+
pull_request:
10+
branches:
11+
- dev
12+
- master
13+
jobs:
14+
itest:
15+
runs-on: ubuntu-20.04
16+
timeout-minutes: 20
17+
18+
strategy:
19+
matrix:
20+
node-version: [14.x]
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Use Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v1
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
- name: Copy config file
34+
run: cp ./__tests__/integration/configuration/config.js.template ./src/config.js
35+
36+
- name: Run the tests
37+
run: npm run test_integration
38+
39+
- name: Upload debug transaction logs
40+
if: always()
41+
uses: actions/upload-artifact@v2
42+
with:
43+
name: test-transacion-logs
44+
path: tmp

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ config.js
55
node_modules/
66

77
coverage
8+
coverage-integration
89

910
.DS_Store

__tests__/__fixtures__/http-fixtures.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,48 @@ export default {
527527
height: 19,
528528
tokens: ["03"]
529529
},
530+
{
531+
tx_id:
532+
"00991cd24536f402ef60d37df3031e0cff1d4e78cdbf6101e3cde4217a7c4cc3",
533+
version: 0,
534+
weight: 21,
535+
timestamp: 1615256216,
536+
is_voided: false,
537+
inputs: [],
538+
outputs: [
539+
{
540+
value: 10,
541+
token_data: 1,
542+
script: "dqkUsmE9zshkgB58piBD7ETUV0e/NgmIrA==",
543+
decoded: {
544+
type: "P2PKH",
545+
address: "WYBwT3xLpDnHNtYZiU52oanupVeDKhAvNp",
546+
},
547+
token: "04",
548+
spent_by: null,
549+
selected_as_input: false,
550+
},
551+
{
552+
value: 10,
553+
token_data: 0,
554+
script: "dqkUsmE9zshkgB58piBD7ETUV0e/NgmIrA==",
555+
decoded: {
556+
type: "P2PKH",
557+
address: "WYBwT3xLpDnHNtYZiU52oanupVeDKhAvNp",
558+
},
559+
token: "00",
560+
spent_by: null,
561+
selected_as_input: false,
562+
},
563+
],
564+
parents: [
565+
"000004e31d32f699cc4d4cda8a31037f2197f2e18b2192f4f9225bf0fbb3760c",
566+
"00975897028ceb037307327c953f5e7ad4d3f42402d71bd3d11ecb63ac39f01a",
567+
"00e161a6b0bee1781ea9300680913fb76fd0fac4acab527cd9626cc1514abdc9",
568+
],
569+
height: 19,
570+
tokens: ["04"]
571+
},
530572
],
531573
},
532574
"/v1a/push_tx": {

__tests__/address.test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { wallet as walletUtils } from "@hathor/wallet-lib";
2-
import TestUtils from "./test-utils";
1+
import { wallet as walletUtils } from '@hathor/wallet-lib';
2+
import TestUtils from './test-utils';
33

44
describe("address api", () => {
55
it("should return 200 with a valid body", async () => {
66
let response = await TestUtils.request
77
.get("/wallet/address")
88
.set({ "x-wallet-id": TestUtils.walletId });
99
expect(response.status).toBe(200);
10-
expect(response.body.address).toBe(TestUtils.addresses[1]);
10+
expect(response.body.address).toBe(TestUtils.addresses[4]);
1111

1212
// Should return the same address for a second call
1313
response = await TestUtils.request
1414
.get("/wallet/address")
1515
.set({ "x-wallet-id": TestUtils.walletId });
1616
expect(response.status).toBe(200);
17-
expect(response.body.address).toBe(TestUtils.addresses[1]);
17+
expect(response.body.address).toBe(TestUtils.addresses[4]);
1818
});
1919

2020
it("should return 200 with a valid body for index = 0", async () => {
@@ -43,7 +43,9 @@ describe("address api", () => {
4343

4444
it("should return a new address with mark_as_used until the gapLimit is reached", async () => {
4545
const gapLimit = walletUtils.getGapLimit();
46-
for (let index = 1; index <= gapLimit; index++) {
46+
const startingIndex = 4; // First unused address
47+
const upperLimit = gapLimit + startingIndex - 1; // Last address within the gap limit
48+
for (let index = startingIndex; index <= upperLimit; index++) {
4749
const response = await TestUtils.request
4850
.get("/wallet/address")
4951
.query({ mark_as_used: true })
@@ -57,6 +59,6 @@ describe("address api", () => {
5759
.get("/wallet/address")
5860
.set({ "x-wallet-id": TestUtils.walletId });
5961
expect(response.status).toBe(200);
60-
expect(response.body.address).toBe(TestUtils.addresses[gapLimit]);
62+
expect(response.body.address).toBe(TestUtils.addresses[upperLimit]);
6163
});
6264
});

__tests__/addresses.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { wallet as walletUtils } from "@hathor/wallet-lib";
2-
import TestUtils from "./test-utils";
1+
import { wallet as walletUtils } from '@hathor/wallet-lib';
2+
import TestUtils from './test-utils';
33

44
describe("addresses api", () => {
55
it("should return 200 with a valid body", async () => {
@@ -8,7 +8,7 @@ describe("addresses api", () => {
88
.get("/wallet/addresses")
99
.set({ "x-wallet-id": TestUtils.walletId });
1010
expect(response.status).toBe(200);
11-
expect(response.body.addresses.length).toBe(gapLimit + 1);
11+
expect(response.body.addresses.length).toBe(gapLimit + 4);
1212
expect(response.body.addresses).toEqual(TestUtils.addresses);
1313
});
1414

@@ -24,7 +24,7 @@ describe("addresses api", () => {
2424
.get("/wallet/addresses")
2525
.set({ "x-wallet-id": TestUtils.walletId });
2626
expect(response.status).toBe(200);
27-
expect(response.body.addresses.length).toBe(gapLimit + 1);
27+
expect(response.body.addresses.length).toBe(gapLimit + 4);
2828
expect(response.body.addresses.slice(0, TestUtils.addresses.length)).toEqual(TestUtils.addresses);
2929
});
3030
});

__tests__/balance.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import TestUtils from "./test-utils";
1+
import TestUtils from './test-utils';
22

33
describe("balance api", () => {
44
it("should return 200 with a valid body", async () => {
55
const response = await TestUtils.request
66
.get("/wallet/balance")
77
.set({ "x-wallet-id": TestUtils.walletId });
88
expect(response.status).toBe(200);
9-
expect(response.body.available).toBe(76799);
9+
expect(response.body.available).toBe(76809);
1010
expect(response.body.locked).toBe(6400);
1111
});
1212

0 commit comments

Comments
 (0)