Skip to content

Commit 95cd1be

Browse files
authored
fix: preprocess bug to remove network from the dummy transaction
1 parent fc95319 commit 95cd1be

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

package-lock.json

+32-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
"jsonc-parser": "^3.0.0",
129129
"jsonrpc-lite": "^2.1.0",
130130
"micro-base58": "^0.5.0",
131+
"nock": "^13.1.1",
131132
"node-fetch": "^2.6.0",
132133
"node-pg-migrate": "^5.9.0",
133134
"p-queue": "^6.3.0",

src/api/routes/rosetta/construction.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,10 @@ export function createRosettaConstructionRouter(db: DataStore, chainId: ChainID)
208208
functionName: 'stack-stx',
209209
publicKey: '000000000000000000000000000000000000000000000000000000000000000000',
210210
functionArgs: [uintCV(options.amount), poxAddressCV, uintCV(0), uintCV(0)],
211-
validateWithAbi: true,
211+
validateWithAbi: false,
212212
network: getStacksNetwork(),
213+
fee: new BN(0),
214+
nonce: new BN(0),
213215
};
214216
transaction = await makeUnsignedContractCall(dummyStackingTx);
215217
break;
@@ -231,8 +233,10 @@ export function createRosettaConstructionRouter(db: DataStore, chainId: ChainID)
231233
noneCV(),
232234
noneCV(),
233235
],
234-
validateWithAbi: true,
236+
validateWithAbi: false,
235237
network: getStacksNetwork(),
238+
fee: new BN(0),
239+
nonce: new BN(0),
236240
};
237241
transaction = await makeUnsignedContractCall(dummyStackingTx);
238242
break;

src/tests-rosetta/offline-api-tests.ts

+8
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@ import {
4545
import { OfflineDummyStore } from '../datastore/offline-dummy-store';
4646
import { getStacksTestnetNetwork, testnetKeys } from '../api/routes/debug';
4747
import { getSignature, getStacksNetwork } from '../rosetta-helpers';
48+
import * as nock from 'nock';
4849
describe('Rosetta API', () => {
4950
let db: DataStore;
5051
let api: ApiServer;
5152

5253
beforeAll(async () => {
5354
db = OfflineDummyStore;
5455
api = await startApiServer({ datastore: db, chainId: ChainID.Testnet });
56+
nock.disableNetConnect();
57+
nock.enableNetConnect('127.0.0.1:3999');
5558
});
5659

5760
test('Success: offline - network/list', async () => {
@@ -295,11 +298,13 @@ describe('Rosetta API', () => {
295298
const recipientAddr = 'STDE7Y8HV3RX8VBM2TZVWJTS7ZA1XB0SSC3NEVH0';
296299
const amount = new BN(1000);
297300
const fee = new BN(180);
301+
const nonce = new BN(0);
298302
const options: SignedTokenTransferOptions = {
299303
recipient: recipientAddr,
300304
amount: amount,
301305
fee: fee,
302306
senderKey: testnetKeys[0].secretKey,
307+
nonce: nonce,
303308
network: getStacksTestnetNetwork(),
304309
};
305310
const testTransaction = await makeSTXTokenTransfer(options);
@@ -338,10 +343,12 @@ describe('Rosetta API', () => {
338343
const recipientAddr = 'STDE7Y8HV3RX8VBM2TZVWJTS7ZA1XB0SSC3NEVH0';
339344
const amount = new BN(1000);
340345
const fee = new BN(180);
346+
const nonce = new BN(0);
341347
const tokenTransferOptions: UnsignedTokenTransferOptions = {
342348
recipient: recipientAddr,
343349
amount: amount,
344350
fee: fee,
351+
nonce: nonce,
345352
publicKey: publicKey,
346353
network: getStacksTestnetNetwork(),
347354
};
@@ -718,5 +725,6 @@ describe('Rosetta API', () => {
718725

719726
afterAll(async () => {
720727
await api.terminate();
728+
nock.enableNetConnect()
721729
});
722730
});

0 commit comments

Comments
 (0)