Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 4 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,51 +27,6 @@ When running multiple tests, you'll want to limit it to one test at a time becau
yarn vitest --run tests/integration/pox/stacking/ --threads false
```

#### Using 2.4 `stacks-node`

To run tests using the 2.2 node (the tests in the _pox-disabled/_ directory), you'll need to use a currently unpublished version of the `stacks-devnet-js` package which has support for the new settings. To build this locally:

```
git clone https://github.com/hirosystems/clarinet.git
cd clarinet
git checkout feat/devnet-epoch-2.2
cd components/stacks-devnet-js
npm install
```

Then you'll want to run one of the following commands, depending on your platform:

```
npm run build-linux-x64-glibc
npm run build-linux-x64-musl
npm run build-windows-x64
npm run build-darwin-x64 # Mac with Intel
npm run build-darwin-arm64 # Mac with Apple Silicon
```

Finally, you'll use `npm link` to utilize this version in this testing repo. First, in the `stacks-devnet-js` directory, run:

```
npm link
```

This will create a symbolic link from the local package directory to the global node_modules directory.

Then back in this testing directory, run:

```
npm link @hirosystems/stacks-devnet-js
```

Now, you can run the tests expecting this 2.2 node, i.e. those in the _pox-disabled/_ directory.

To switch back to the default version, run:

```
npm unlink @hirosystems/stacks-devnet-js --no-save
yarn install
```

#### 2.4 `stacks-node` Image

To run with the latest node, you'll need to specify the docker image URL to use via an environment variable:
Expand Down Expand Up @@ -100,3 +55,7 @@ export CUSTOM_STACKS_NODE="stacksbrice/stacks-node:devnet-2.4.0.0.0"
```

If this environment variable is not defined, `stacks-devnet-js` will default to an older version of the `stacks-node`.

## Logging

The devnet orchestrator outputs logging details to folder `/tmp/stacks-node-...`
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
const config = {
preset: "ts-jest",
testEnvironment: "node",
testTimeout: 300_000,
maxWorkers: 1,
reporters: ["default", "jest-github-actions-reporter"],
testLocationInResults: true,

setupFilesAfterEnv: ["<rootDir>/setup.ts"],
};

export default config;
48 changes: 24 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "stacks-2-1-integration-tests",
"version": "1.0.0",
"name": "stacks-integration-tests",
"version": "3.0.0",
"description": "",
"type": "module",
"scripts": {
"build": "tsc --build",
"test:dev": "vitest",
Expand All @@ -10,32 +11,31 @@
"fmt": "./node_modules/.bin/prettier --write ."
},
"dependencies": {
"@hirosystems/stacks-devnet-js": "^1.3.0",
"@noble/hashes": "^1.1.5",
"@noble/secp256k1": "^1.7.0",
"@scure/base": "^1.1.1",
"@scure/bip32": "^1.1.1",
"@scure/bip39": "^1.1.0",
"@stacks/common": "^6.0.0",
"@stacks/network": "^6.3.0",
"@stacks/stacking": "^6.0.2",
"@stacks/transactions": "^6.5.0",
"@types/node": "^16.7.13",
"micro-btc-signer": "^0.2.0",
"node-fetch": "^2.6.7",
"typescript": "^4.9.0"
"@hirosystems/stacks-devnet-js": "^2.5.1",
"@noble/hashes": "^1.4.0",
"@noble/secp256k1": "^2.1.0",
"@scure/base": "^1.1.6",
"@scure/bip32": "^1.4.0",
"@scure/bip39": "^1.3.0",
"@stacks/common": "^6.13.0",
"@stacks/network": "^6.13.0",
"@stacks/stacking": "^6.13.2",
"@stacks/transactions": "^6.13.1",
"@types/node": "^20.12.7",
"node-fetch": "2.6.7",
"typescript": "^5.4.5"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^27.0.3",
"@vitest/ui": "^0.25.8",
"jest": "^27.4.5",
"@types/jest": "^29.5.12",
"@vitest/ui": "^1.5.0",
"jest": "^29.7.0",
"jest-github-actions-reporter": "^1.0.3",
"prettier": "2.8.1",
"ts-jest": "^27.1.2",
"vite": "^4.0.1",
"vitest": "^0.25.8",
"vitest-github-actions-reporter": "^0.9.0"
"prettier": "3.2.5",
"ts-jest": "^29.1.2",
"vite": "^5.2.9",
"vitest": "^1.5.0",
"vitest-github-actions-reporter": "^0.11.1"
}
}
10 changes: 3 additions & 7 deletions settings/Devnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ balance = 1_000_000_000_000_000
# btc_address: mjSrB3wS4xab3kYqFktwBzfTdPg367ZJ2d

[devnet]
use_nakamoto = true
disable_stacks_explorer = true
disable_stacks_api = true
enable_next_features = true
# bind_containers_volumes = true
# disable_bitcoin_explorer = true
# working_dir = "tmp/devnet"
Expand All @@ -66,8 +66,8 @@ bitcoin_controller_automining_disabled = true
# postgres_username = "postgres"
# postgres_password = "postgres"
# postgres_database = "postgres"
# bitcoin_node_image_url = "quay.io/hirosystems/bitcoind:devnet-v2"
# stacks_node_image_url = "quay.io/hirosystems/stacks-node:v3-beta2"
# bitcoin_node_image_url = "quay.io/hirosystems/bitcoind:26.0"
# stacks_node_image_url = "quay.io/hirosystems/stacks-node:devnet-with-signer-beta4"
# stacks_node_env_vars = ["STACKS_LOG_DEBUG=1"]
# stacks_api_image_url = "hirosystems/stacks-blockchain-api:latest"
# stacks_explorer_image_url = "hirosystems/explorer:latest"
Expand All @@ -82,7 +82,3 @@ bitcoin_controller_automining_disabled = true
# subnet_node_p2p_port = 30444
# subnet_events_ingestion_port = 30445
# subnet_node_events_observers = ["host.docker.internal:8002"]
# epoch_2_00 = 100
# epoch_2_05 = 102
# epoch_2_1 = 106
# pox_2_activation = 108
6 changes: 6 additions & 0 deletions setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ensureEphemeralDevnetDown } from "./tests/helpers";

beforeAll(async () => {
console.log("Starting tests");
ensureEphemeralDevnetDown();
});
13 changes: 13 additions & 0 deletions tests/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { execSync as x } from "child_process";

export function ensureEphemeralDevnetDown() {
try {
x("docker ps -q --filter 'name=ephemeral-devnet' | xargs -r docker stop");
x("docker ps -aq --filter 'name=ephemeral-devnet' | xargs -r docker rm -v");
x(
"docker network ls --format '{{.Name}}' | grep 'ephemeral-devnet' | xargs docker network rm",
);
} catch (error) {
console.error("Failed to clean up previous devnet instances.", error);
}
}
28 changes: 15 additions & 13 deletions tests/integration/clarity/natives/buff-to-int-be.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ describe("buff-to-int-be", () => {
beforeAll(() => {
orchestrator = buildDevnetNetworkOrchestrator(getNetworkIdFromEnv());
orchestrator.start();
network = new StacksTestnet({ url: orchestrator.getStacksNodeUrl() });
network = new StacksTestnet({
url: orchestrator.getStacksNodeUrl().replace("localhost", "127.0.0.1"),
});
});

afterAll(() => {
Expand Down Expand Up @@ -66,13 +68,13 @@ describe("buff-to-int-be", () => {
// Wait for the transaction to be processed
let [block, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(block.bitcoin_anchor_block_identifier.index).toBeLessThanOrEqual(
Constants.DEVNET_DEFAULT_EPOCH_2_1
Constants.DEVNET_DEFAULT_EPOCH_2_1,
);
expect(tx.description).toBe(
`deployed: ${Accounts.DEPLOYER.stxAddress}.test-2-05`
`deployed: ${Accounts.DEPLOYER.stxAddress}.test-2-05`,
);
expect(tx.success).toBeFalsy();
});
Expand All @@ -81,7 +83,7 @@ describe("buff-to-int-be", () => {
beforeAll(async () => {
// Wait for 2.1 to go live
await orchestrator.waitForStacksBlockAnchoredOnBitcoinBlockOfHeight(
Constants.DEVNET_DEFAULT_EPOCH_2_1
Constants.DEVNET_DEFAULT_EPOCH_2_1,
);
await orchestrator.waitForNextStacksBlock();
});
Expand Down Expand Up @@ -111,10 +113,10 @@ describe("buff-to-int-be", () => {
// Wait for the transaction to be processed
let [block, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(tx.description).toBe(
`deployed: ${Accounts.DEPLOYER.stxAddress}.test-2-1`
`deployed: ${Accounts.DEPLOYER.stxAddress}.test-2-1`,
);
expect(tx.success).toBeTruthy();
});
Expand Down Expand Up @@ -145,10 +147,10 @@ describe("buff-to-int-be", () => {
// Wait for the transaction to be processed
let [block, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(tx.description).toBe(
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-1()`
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-1()`,
);
expect(tx.result).toBe("(ok 1)");
expect(tx.success).toBeTruthy();
Expand Down Expand Up @@ -180,10 +182,10 @@ describe("buff-to-int-be", () => {
// Wait for the transaction to be processed
let [_, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(tx.description).toBe(
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-2()`
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-2()`,
);
expect(tx.result).toBe("(ok -1)");
expect(tx.success).toBeTruthy();
Expand Down Expand Up @@ -215,10 +217,10 @@ describe("buff-to-int-be", () => {
// Wait for the transaction to be processed
let [block, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(tx.description).toBe(
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-3()`
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-3()`,
);
expect(tx.result).toBe("(ok 0)");
expect(tx.success).toBeTruthy();
Expand Down
28 changes: 15 additions & 13 deletions tests/integration/clarity/natives/buff-to-int-le.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ describe("buff-to-int-le", () => {
beforeAll(() => {
orchestrator = buildDevnetNetworkOrchestrator(getNetworkIdFromEnv());
orchestrator.start();
network = new StacksTestnet({ url: orchestrator.getStacksNodeUrl() });
network = new StacksTestnet({
url: orchestrator.getStacksNodeUrl().replace("localhost", "127.0.0.1"),
});
nonce = 0;
});

Expand Down Expand Up @@ -69,13 +71,13 @@ describe("buff-to-int-le", () => {
// Wait for the transaction to be processed
let [block, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(block.bitcoin_anchor_block_identifier.index).toBeLessThanOrEqual(
Constants.DEVNET_DEFAULT_EPOCH_2_1
Constants.DEVNET_DEFAULT_EPOCH_2_1,
);
expect(tx.description).toBe(
`deployed: ${Accounts.DEPLOYER.stxAddress}.test-2-05`
`deployed: ${Accounts.DEPLOYER.stxAddress}.test-2-05`,
);
expect(tx.success).toBeFalsy();
});
Expand All @@ -84,7 +86,7 @@ describe("buff-to-int-le", () => {
beforeAll(async () => {
// Wait for 2.1 to go live
await orchestrator.waitForStacksBlockAnchoredOnBitcoinBlockOfHeight(
Constants.DEVNET_DEFAULT_EPOCH_2_1
Constants.DEVNET_DEFAULT_EPOCH_2_1,
);
await orchestrator.waitForNextStacksBlock();
});
Expand Down Expand Up @@ -114,10 +116,10 @@ describe("buff-to-int-le", () => {
// Wait for the transaction to be processed
let [block, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(tx.description).toBe(
`deployed: ${Accounts.DEPLOYER.stxAddress}.test-2-1`
`deployed: ${Accounts.DEPLOYER.stxAddress}.test-2-1`,
);
expect(tx.success).toBeTruthy();
});
Expand Down Expand Up @@ -148,10 +150,10 @@ describe("buff-to-int-le", () => {
// Wait for the transaction to be processed
let [block, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(tx.description).toBe(
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-1()`
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-1()`,
);
expect(tx.result).toBe("(ok 1)");
expect(tx.success).toBeTruthy();
Expand Down Expand Up @@ -184,10 +186,10 @@ describe("buff-to-int-le", () => {
// Wait for the transaction to be processed
let [_, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(tx.description).toBe(
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-2()`
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-2()`,
);
expect(tx.result).toBe("(ok -1)");
expect(tx.success).toBeTruthy();
Expand Down Expand Up @@ -220,10 +222,10 @@ describe("buff-to-int-le", () => {
// Wait for the transaction to be processed
let [block, tx] = await waitForStacksTransaction(
orchestrator,
transaction.txid()
transaction.txid(),
);
expect(tx.description).toBe(
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-3()`
`invoked: ${Accounts.DEPLOYER.stxAddress}.test-2-1::test-3()`,
);
expect(tx.result).toBe("(ok 0)");
expect(tx.success).toBeTruthy();
Expand Down
Loading