Skip to content

Commit

Permalink
test: Update to succeed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Oct 18, 2024
1 parent f704a8b commit affa2c9
Show file tree
Hide file tree
Showing 11 changed files with 366 additions and 214 deletions.
2 changes: 0 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"dependencies": {
"@scure/bip32": "1.1.3",
"@scure/bip39": "1.1.0",
"@stacks/api": "file:../api",
"@stacks/auth": "^6.16.1",
"@stacks/blockchain-api-client": "4.0.1",
"@stacks/bns": "^6.16.1",
Expand Down
240 changes: 123 additions & 117 deletions packages/cli/src/cli.ts

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions packages/cli/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"composite": true
},
"references": [
{
"path": "../api/tsconfig.build.json"
},
{
"path": "../auth/tsconfig.build.json"
},
Expand Down
1 change: 0 additions & 1 deletion packages/internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"typecheck:watch": "npm run typecheck -- --watch"
},
"devDependencies": {
"@stacks/api": "^6.9.0",
"@stacks/stacking": "^6.9.0",
"@stacks/blockchain-api-client": "^7.12.0",
"@stacks/network": "^6.16.0",
Expand Down
19 changes: 14 additions & 5 deletions packages/internal/src/apiMockingHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Configuration, TransactionsApi } from '@stacks/blockchain-api-client';
import { STACKS_TESTNET } from '@stacks/network';
import { MockResponseInitFunction } from 'jest-fetch-mock';
import { StackingClient } from '@stacks/stacking';
import { StacksNodeApi } from '@stacks/api';

// NOTES
// Capture traffic via the fetchWrapper
Expand Down Expand Up @@ -93,8 +92,13 @@ export async function waitForTx(txId: string, apiUrl = 'http://localhost:3999')
export async function waitForBlock(burnBlockId: number, client?: StackingClient) {
if (isMocking()) return;

const api = { url: 'http://localhost:3999' };
client = client ?? new StackingClient({ address: '', network: STACKS_TESTNET, api });
client =
client ??
new StackingClient({
address: '',
network: STACKS_TESTNET,
client: { baseUrl: 'http://localhost:3999' },
});

let current: number;
for (let i = 1; i <= MAX_ITERATIONS; i++) {
Expand All @@ -117,8 +121,13 @@ export async function waitForBlock(burnBlockId: number, client?: StackingClient)
export async function waitForCycle(cycleId: number, client?: StackingClient) {
if (isMocking()) return;

const api = new StacksNodeApi({ url: 'http://localhost:3999' });
client = client ?? new StackingClient({ address: '', network: STACKS_TESTNET, api });
client =
client ??
new StackingClient({
address: '',
network: STACKS_TESTNET,
client: { baseUrl: 'http://localhost:3999' },
});

let current: number;
for (let i = 1; i <= MAX_ITERATIONS; i++) {
Expand Down
3 changes: 0 additions & 3 deletions packages/internal/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"composite": true
},
"references": [
{
"path": "../api/tsconfig.build.json"
},
{
"path": "../stacking/tsconfig.build.json"
}
Expand Down
23 changes: 11 additions & 12 deletions packages/stacking/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ClientOpts, IntegerType, PrivateKey, hexToBytes, intToBigInt } from '@stacks/common';
import {
ClientOpts,
IntegerType,
PrivateKey,
defaultClientOpts,
hexToBytes,
intToBigInt,
} from '@stacks/common';
import { ChainId, StacksNetwork, StacksNetworkName, networkFrom } from '@stacks/network';
ChainId,
StacksNetwork,
StacksNetworkName,
defaultClientOptsFromNetwork,
networkFrom,
} from '@stacks/network';
import {
BurnchainRewardListResponse,
BurnchainRewardSlotHolderListResponse,
Expand Down Expand Up @@ -342,7 +341,7 @@ export class StackingClient {
}) {
this.address = opts.address;
this.network = networkFrom(opts.network);
this.client = defaultClientOpts(opts.client);
this.client = defaultClientOptsFromNetwork(this.network, opts.client);
}

get baseUrl() {
Expand All @@ -353,17 +352,17 @@ export class StackingClient {
return this.client.fetch;
}

/** @deprecated alias of StacksNodeApi.getCoreInfo, kept for backwards compatibility */
/** @deprecated Kept for backwards compatibility, may be removed in the future */
getCoreInfo(): Promise<V2CoreInfoResponse> {
return this.client.fetch(`${this.client.baseUrl}/v2/info`).then(res => res.json());
}

/** @deprecated alias of StacksNodeApi.getPoxInfo, kept for backwards compatibility */
/** @deprecated Kept for backwards compatibility, may be removed in the future */
getPoxInfo(): Promise<V2PoxInfoResponse> {
return this.client.fetch(`${this.client.baseUrl}/v2/pox`).then(res => res.json());
}

/** @deprecated alias of StacksNodeApi.getTargetBlockTime, kept for backwards compatibility */
/** @deprecated Kept for backwards compatibility, may be removed in the future */
async getTargetBlockTime(): Promise<number> {
const res = await this.client
.fetch(`${this.client.baseUrl}/extended/v1/info/network_block_times`)
Expand Down
Loading

0 comments on commit affa2c9

Please sign in to comment.