Skip to content

Commit 2297027

Browse files
authored
Merge pull request #1957 from hirosystems/develop
Cut beta release
2 parents 2306fbc + 4bba526 commit 2297027

File tree

4 files changed

+30
-40
lines changed

4 files changed

+30
-40
lines changed

docker/rosetta.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Running with `SEED_CHAINSTATE=true` will require the container to be launched with `--shm-size=xxxxMB` where at least 256MB is recommended
22
ARG STACKS_API_VERSION=v7.1.10
3-
ARG STACKS_BLOCKCHAIN_VERSION=2.3.0.0.2
3+
ARG STACKS_BLOCKCHAIN_VERSION=2.5.0.0.2
44
ARG PG_VERSION=15
55
ARG STACKS_NETWORK=mainnet
66
ARG PG_HOST=127.0.0.1

src/api/routes/rosetta/account.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export function createRosettaAccountRouter(db: PgStore, chainId: ChainID): expre
3939
let blockHash: string = '0x';
4040
// we need to return the block height/hash in the response, so we
4141
// need to fetch the block first.
42-
if (blockIdentifier === undefined) {
42+
if (
43+
(!blockIdentifier?.hash && !blockIdentifier?.index) ||
44+
(blockIdentifier && blockIdentifier.index <= 0)
45+
) {
4346
blockQuery = await db.getCurrentBlock();
4447
} else if (blockIdentifier.index > 0) {
4548
blockQuery = await db.getBlock({ height: blockIdentifier.index });

src/tests-rosetta/account-tests.ts

+25-12
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,7 @@ describe('/account tests', () => {
7474
.build();
7575
await db.update(block2);
7676

77-
const query1 = await supertest(api.server)
78-
.post(`/rosetta/v1/account/balance`)
79-
.send({
80-
network_identifier: { blockchain: 'stacks', network: 'testnet' },
81-
block_identifier: { index: 2, hash: '0xf1f1' },
82-
account_identifier: { address: addr2 },
83-
});
84-
expect(query1.status).toBe(200);
85-
expect(query1.type).toBe('application/json');
86-
const result1 = JSON.parse(query1.text);
87-
expect(result1.balances).toEqual([
77+
const expectedBalance = [
8878
{
8979
currency: {
9080
decimals: 6,
@@ -99,7 +89,30 @@ describe('/account tests', () => {
9989
},
10090
value: '7500'
10191
}
102-
]);
92+
];
93+
const query1 = await supertest(api.server)
94+
.post(`/rosetta/v1/account/balance`)
95+
.send({
96+
network_identifier: { blockchain: 'stacks', network: 'testnet' },
97+
block_identifier: { index: 2, hash: '0xf1f1' },
98+
account_identifier: { address: addr2 },
99+
});
100+
expect(query1.status).toBe(200);
101+
expect(query1.type).toBe('application/json');
102+
expect(JSON.parse(query1.text).balances).toEqual(expectedBalance);
103+
104+
// ensure query works with block identifier omitted
105+
const query2 = await supertest(api.server)
106+
.post(`/rosetta/v1/account/balance`)
107+
.send({
108+
network_identifier: { blockchain: 'stacks', network: 'testnet' },
109+
account_identifier: { address: addr2 },
110+
});
111+
expect(query2.status).toBe(200);
112+
expect(query2.type).toBe('application/json');
113+
expect(JSON.parse(query2.text).balances).toEqual(expectedBalance);
114+
103115
nock.cleanAll();
104116
});
117+
105118
});

src/tests-rosetta/api.ts

-26
Original file line numberDiff line numberDiff line change
@@ -1239,32 +1239,6 @@ describe('Rosetta API', () => {
12391239
expect(JSON.parse(result.text)).toEqual(expectResponse);
12401240
});
12411241

1242-
test('account/balance - empty block identifier', async () => {
1243-
const request: RosettaAccountBalanceRequest = {
1244-
network_identifier: {
1245-
blockchain: 'stacks',
1246-
network: 'testnet',
1247-
},
1248-
account_identifier: {
1249-
address: 'SP2QXJDSWYFGT9022M6NCA9SS4XNQM79D8E7EDSPQ',
1250-
metadata: {},
1251-
},
1252-
block_identifier: {},
1253-
};
1254-
1255-
const result = await supertest(api.server).post(`/rosetta/v1/account/balance/`).send(request);
1256-
expect(result.status).toBe(400);
1257-
expect(result.type).toBe('application/json');
1258-
1259-
const expectResponse = {
1260-
code: 615,
1261-
message: 'Block identifier is null.',
1262-
retriable: false,
1263-
};
1264-
1265-
expect(JSON.parse(result.text)).toEqual(expectResponse);
1266-
});
1267-
12681242
test('account/balance - invalid block hash', async () => {
12691243
const request: RosettaAccountBalanceRequest = {
12701244
network_identifier: {

0 commit comments

Comments
 (0)