Skip to content

Commit

Permalink
Merge pull request #469 from HathorNetwork/release-candidate
Browse files Browse the repository at this point in the history
Release v0.30.0
  • Loading branch information
r4mmer authored Aug 15, 2024
2 parents 9a373ee + c07f644 commit 04a2676
Show file tree
Hide file tree
Showing 26 changed files with 703 additions and 163 deletions.
19 changes: 15 additions & 4 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ jobs:
node-version: [20.x]

steps:
# https://github.com/actions/checkout/releases/tag/v2.7.0
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5
- name: Checkout
# https://github.com/actions/checkout/releases/tag/v4.1.7
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Use Node.js ${{ matrix.node-version }}
# https://github.com/actions/setup-node/releases/tag/v1.4.6
uses: actions/setup-node@f1f314fca9dfce2769ece7d933488f076716723e
# https://github.com/actions/setup-node/releases/tag/v4.0.2
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -42,6 +43,14 @@ jobs:
- name: Run the tests
run: npm run test_integration

- name: Upload coverage
# https://github.com/codecov/codecov-action/releases/tag/v4.5.0
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673
with:
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Upload debug transaction logs
if: always()
# https://github.com/actions/upload-artifact/releases/tag/v2.3.1
Expand All @@ -56,9 +65,11 @@ jobs:
uses: jwalton/gh-docker-logs@2a058a3b4c97aa3524391cb33bb5e917913ed676
with:
dest: './docker-logs'

- name: Tar logs
if: failure()
run: tar cvzf ./docker-logs.tgz ./docker-logs

- name: Upload logs to GitHub
if: failure()
# https://github.com/actions/upload-artifact/releases/tag/v2.3.1
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,29 @@ jobs:
matrix:
node-version: [20.x]
steps:
# https://github.com/actions/checkout/releases/tag/v2.7.0
- uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5
- name: Checkout
# https://github.com/actions/checkout/releases/tag/v4.1.7
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332

- name: Use Node.js ${{ matrix.node-version }}
# https://github.com/actions/setup-node/releases/tag/v1.4.6
uses: actions/setup-node@f1f314fca9dfce2769ece7d933488f076716723e
# https://github.com/actions/setup-node/releases/tag/v4.0.2
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install

# We mock the config module when testing the settings module, so it needs to exist
- name: Create config module
run: cp ./config.js.template ./src/config.js
- name: Test
run: npm run test

- name: Upload coverage
# https://github.com/codecov/codecov-action/releases/tag/v4.3.0
uses: codecov/codecov-action@84508663e988701840491b86de86b666e8a86bed
# https://github.com/codecov/codecov-action/releases/tag/v4.5.0
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673
with:
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions __tests__/atomic-swap/atomic-swap-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function* mockUtxos(options) {
yield {
txId: fakeTxId,
index: 0,
tokenId: hathorLib.constants.HATHOR_TOKEN_CONFIG.uid,
tokenId: hathorLib.constants.NATIVE_TOKEN_UID,
value: 10,
address: TestUtils.addresses[0],
timelock: null,
Expand All @@ -32,7 +32,7 @@ beforeAll(async () => {
outputs: [
{
value: 10,
token: hathorLib.constants.HATHOR_TOKEN_CONFIG.uid,
token: hathorLib.constants.NATIVE_TOKEN_UID,
token_data: 0,
decoded: { address: TestUtils.addresses[0] },
},
Expand Down
4 changes: 2 additions & 2 deletions __tests__/atomic-swap/fetch-from-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('fetchFromService', () => {
yield {
txId: fakeTxId,
index: 0,
token: hathorLib.constants.HATHOR_TOKEN_CONFIG.uid,
token: hathorLib.constants.NATIVE_TOKEN_UID,
address: TestUtils.addresses[0],
value: 10,
authorities: 0,
Expand All @@ -32,7 +32,7 @@ describe('fetchFromService', () => {
outputs: [
{
value: 10,
token: hathorLib.constants.HATHOR_TOKEN_CONFIG.uid,
token: hathorLib.constants.NATIVE_TOKEN_UID,
token_data: 0,
decoded: { address: TestUtils.addresses[0] },
},
Expand Down
4 changes: 2 additions & 2 deletions __tests__/atomic-swap/tx-proposal-create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('create tx-proposal api', () => {
yield {
txId: fakeTxId,
index: 0,
token: hathorLib.constants.HATHOR_TOKEN_CONFIG.uid,
token: hathorLib.constants.NATIVE_TOKEN_UID,
address: TestUtils.addresses[0],
value: 10,
authorities: 0,
Expand All @@ -33,7 +33,7 @@ describe('create tx-proposal api', () => {
outputs: [
{
value: 10,
token: hathorLib.constants.HATHOR_TOKEN_CONFIG.uid,
token: hathorLib.constants.NATIVE_TOKEN_UID,
token_data: 0,
decoded: { address: TestUtils.addresses[0] },
},
Expand Down
54 changes: 54 additions & 0 deletions __tests__/history-sync.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import hathorLib from '@hathor/wallet-lib';
import TestUtils from './test-utils';
import settings from '../src/settings';
import { initializedWallets } from '../src/services/wallets.service';

const walletId = 'stub_history_sync';

describe('history sync', () => {
afterEach(async () => {
await TestUtils.stopWallet({ walletId });
});

it('should start a wallet with default http polling if not configured', async () => {
const response = await TestUtils.request
.post('/start')
.send({ seedKey: TestUtils.seedKey, 'wallet-id': walletId });
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
const wallet = initializedWallets.get(walletId);
expect(wallet.historySyncMode).toEqual(hathorLib.HistorySyncMode.POLLING_HTTP_API);
});

it('should start a wallet with configured history sync', async () => {
const config = settings._getDefaultConfig();
config.history_sync_mode = 'manual_stream_ws';
settings._setConfig(config);
const response = await TestUtils.request
.post('/start')
.send({ seedKey: TestUtils.seedKey, 'wallet-id': walletId });
settings._resetConfig();
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
const wallet = initializedWallets.get(walletId);
expect(wallet.historySyncMode).toEqual(hathorLib.HistorySyncMode.MANUAL_STREAM_WS);
});

it('should use the history sync from the request when provided', async () => {
const config = settings._getDefaultConfig();
config.history_sync_mode = 'manual_stream_ws';
settings._setConfig(config);
const response = await TestUtils.request
.post('/start')
.send({
seedKey: TestUtils.seedKey,
'wallet-id': walletId,
history_sync_mode: 'xpub_stream_ws',
});
settings._resetConfig();
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
const wallet = initializedWallets.get(walletId);
expect(wallet.historySyncMode).toEqual(hathorLib.HistorySyncMode.XPUB_STREAM_WS);
});
});
2 changes: 1 addition & 1 deletion __tests__/integration/configuration/test-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ export const AUTHORITY_VALUE = {
MELT: libConstants.TOKEN_MELT_MASK
};

export const HATHOR_TOKEN_ID = libConstants.HATHOR_TOKEN_CONFIG.uid;
export const HATHOR_TOKEN_ID = libConstants.NATIVE_TOKEN_UID;
4 changes: 2 additions & 2 deletions __tests__/integration/create-token.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ describe('create token', () => {
});

it('create token with data outputs', async () => {
const htrBalance = await wallet2.getBalance(constants.HATHOR_TOKEN_CONFIG.uid);
const htrBalance = await wallet2.getBalance(constants.NATIVE_TOKEN_UID);
const response = await TestUtils.request
.post('/wallet/create-token')
.send({
Expand All @@ -488,7 +488,7 @@ describe('create token', () => {
// Make sure we spent 0.03 HTR
// 0.01 for the mint
// 0.02 for the two data script outputs
const newHtrBalance = await wallet2.getBalance(constants.HATHOR_TOKEN_CONFIG.uid);
const newHtrBalance = await wallet2.getBalance(constants.NATIVE_TOKEN_UID);
expect(newHtrBalance.available).toBe(htrBalance.available - 3);

// Make sure the token was minted
Expand Down
Loading

0 comments on commit 04a2676

Please sign in to comment.