Skip to content

Commit e30636e

Browse files
authored
fix: upgrade stacks node versions to 2.05.0.3.0 (#1328)
* chore: upgrade stacks node version * fix: api and bns tests * fix: rosetta-cli tests * fix: rosetta tests
1 parent 43e0400 commit e30636e

File tree

12 files changed

+55
-49
lines changed

12 files changed

+55
-49
lines changed

.gitpod.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM blockstack/stacks-blockchain:2.05.0.0.0-stretch as corenode
1+
FROM blockstack/stacks-blockchain:2.05.0.3.0-stretch as corenode
22

33
FROM gitpod/workspace-postgres
44

docker/stx-rosetta.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG STACKS_API_VERSION=v0.71.2
2-
ARG STACKS_NODE_VERSION=2.05.0.0.0
2+
ARG STACKS_NODE_VERSION=2.05.0.3.0
33
ARG STACKS_API_REPO=blockstack/stacks-blockchain-api
44
ARG STACKS_NODE_REPO=blockstack/stacks-blockchain
55
ARG PG_VERSION=12

src/tests-bns/setup.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { loadDotEnv } from '../helpers';
2-
import { StacksCoreRpcClient } from '../core-rpc/client';
32

43
// ts-unused-exports:disable-next-line
5-
export default async (): Promise<void> => {
4+
export default (): void => {
65
console.log('Jest - setup..');
76
if (!process.env.NODE_ENV) {
87
process.env.NODE_ENV = 'test';
98
}
109
loadDotEnv();
11-
console.log('Waiting for RPC connection to core node..');
12-
await new StacksCoreRpcClient().waitForConnection(60000);
1310
console.log('Jest - setup done');
1411
};
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import { loadDotEnv } from '../helpers';
2-
import { StacksCoreRpcClient } from '../core-rpc/client';
3-
import { PgWriteStore } from '../datastore/pg-write-store';
42

5-
export interface GlobalServices {
6-
db: PgWriteStore;
7-
}
83
// ts-unused-exports:disable-next-line
9-
export default async (): Promise<void> => {
4+
export default (): void => {
105
console.log('Jest - setup..');
116
if (!process.env.NODE_ENV) {
127
process.env.NODE_ENV = 'test';
138
}
149
loadDotEnv();
15-
const db = await PgWriteStore.connect({ skipMigrations: true, usageName: 'tests' });
16-
console.log('Waiting for RPC connection to core node..');
17-
await new StacksCoreRpcClient().waitForConnection(60000);
18-
const globalServices: GlobalServices = {
19-
db: db,
20-
};
21-
Object.assign(global, globalServices);
2210
console.log('Jest - setup done');
2311
};
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import type { GlobalServices } from './setup';
21
// ts-unused-exports:disable-next-line
3-
export default async (): Promise<void> => {
2+
export default (): void => {
43
console.log('Jest - teardown..');
5-
const globalServices = (global as unknown) as GlobalServices;
6-
await globalServices.db.close();
74
console.log('Jest - teardown done');
85
};

src/tests-rosetta-cli-data/setup.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import { loadDotEnv } from '../helpers';
2-
import { StacksCoreRpcClient } from '../core-rpc/client';
3-
import { PgWriteStore } from '../datastore/pg-write-store';
42

5-
export interface GlobalServices {
6-
db: PgWriteStore;
7-
}
83
// ts-unused-exports:disable-next-line
9-
export default async (): Promise<void> => {
4+
export default (): void => {
105
console.log('Jest - setup..');
116
if (!process.env.NODE_ENV) {
127
process.env.NODE_ENV = 'test';
138
}
149
loadDotEnv();
15-
const db = await PgWriteStore.connect({ skipMigrations: true, usageName: 'tests' });
16-
console.log('Waiting for RPC connection to core node..');
17-
await new StacksCoreRpcClient().waitForConnection(60000);
18-
const globalServices: GlobalServices = {
19-
db: db,
20-
};
21-
Object.assign(global, globalServices);
2210
console.log('Jest - setup done');
2311
};
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import type { GlobalServices } from './setup';
21
// ts-unused-exports:disable-next-line
3-
export default async (): Promise<void> => {
2+
export default (): void => {
43
console.log('Jest - teardown..');
5-
const globalServices = (global as unknown) as GlobalServices;
6-
await globalServices.db.close();
74
console.log('Jest - teardown done');
85
};

src/tests-rosetta/api.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { PgWriteStore } from '../datastore/pg-write-store';
2929
import { cycleMigrations, runMigrations } from '../datastore/migrations';
3030
import { PgSqlClient } from '../datastore/connection';
3131
import { bufferToHexPrefixString } from '../helpers';
32+
import * as nock from 'nock';
3233

3334
describe('Rosetta API', () => {
3435
let db: PgWriteStore;
@@ -129,6 +130,30 @@ describe('Rosetta API', () => {
129130

130131
const block = blockData.block, genesisBlock = genesisData.block;
131132

133+
nock('http://127.0.0.1:20443')
134+
.get('/v2/neighbors')
135+
.reply(200, {
136+
sample: [],
137+
inbound: [],
138+
outbound: []
139+
});
140+
nock('http://127.0.0.1:20443')
141+
.get('/v2/info')
142+
.reply(200, {
143+
burn_block_height: block.burn_block_height,
144+
burn_consensus: block.burn_block_hash,
145+
exit_at_block_height: null,
146+
network_id: 1,
147+
parent_network_id: 1,
148+
peer_version: 1,
149+
server_version: 1,
150+
stable_burn_block_height: block.burn_block_height,
151+
stable_burn_consensus: block.burn_block_hash,
152+
stacks_tip: block.block_hash,
153+
stacks_tip_burn_block: block.burn_block_height,
154+
stacks_tip_height: block.block_height,
155+
unanchored_tip: ''
156+
});
132157
const query1 = await supertest(api.address)
133158
.post(`/rosetta/v1/network/status`)
134159
.send({ network_identifier: { blockchain: 'stacks', network: 'testnet' } });

src/tests-rosetta/setup.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { loadDotEnv } from '../helpers';
2-
import { StacksCoreRpcClient } from '../core-rpc/client';
32

43
// ts-unused-exports:disable-next-line
5-
export default async (): Promise<void> => {
4+
export default (): void => {
65
console.log('Jest - setup..');
76
if (!process.env.NODE_ENV) {
87
process.env.NODE_ENV = 'test';
98
}
109
loadDotEnv();
11-
console.log('Waiting for RPC connection to core node..');
12-
await new StacksCoreRpcClient().waitForConnection(60000);
1310
console.log('Jest - setup done');
1411
};

src/tests/core-rpc-tests.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
import { Server } from 'net';
2+
import { PgWriteStore } from '../datastore/pg-write-store';
3+
import { startEventServer } from '../event-stream/event-server';
14
import { StacksCoreRpcClient } from '../core-rpc/client';
5+
import { ChainID } from '@stacks/transactions';
26

37
describe('core RPC tests', () => {
48
let client: StacksCoreRpcClient;
9+
let db: PgWriteStore;
10+
let eventServer: Server;
11+
12+
beforeAll(async () => {
13+
db = await PgWriteStore.connect({ usageName: 'tests' });
14+
eventServer = await startEventServer({
15+
datastore: db,
16+
chainId: ChainID.Testnet,
17+
httpLogLevel: 'silly',
18+
});
19+
});
520

621
beforeEach(() => {
722
client = new StacksCoreRpcClient();
@@ -34,4 +49,9 @@ describe('core RPC tests', () => {
3449
const fee = await client.getEstimatedTransferFee();
3550
expect(fee).toBeTruthy();
3651
});
52+
53+
afterAll(async () => {
54+
eventServer.close();
55+
await db.close();
56+
});
3757
});

0 commit comments

Comments
 (0)