Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update system tests to SDK v1.4.0 #719

Merged
merged 10 commits into from
Oct 30, 2023
Merged
11 changes: 5 additions & 6 deletions .github/workflows/system-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: "14.x"
node-version: "18.x"
cache: "yarn"
cache-dependency-path: system-tests/yarn.lock

Expand All @@ -28,8 +28,7 @@ jobs:
working-directory: ./solidity
run: |
npx hardhat node --no-deploy &
HH_NODE_PID=$!
while ! lsof -n -Fn -p $HH_NODE_PID | grep -q '^n.*:8545$'; do sleep 10; done
while [[ -z $(lsof -i :8545 -t) ]]; do echo "Waiting for port 8545 to be open..."; sleep 10; done
lukasz-zimnoch marked this conversation as resolved.
Show resolved Hide resolved

- name: Deploy contracts
working-directory: ./solidity
Expand Down Expand Up @@ -63,13 +62,14 @@ jobs:
yarn test ./test/deposit-redemption.test.ts --network $ETH_NETWORK

system-tests-minting-unminting:
needs: system-tests-deposit-redemption
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: "14.x"
node-version: "18.x"
cache: "yarn"
cache-dependency-path: system-tests/yarn.lock

Expand All @@ -84,8 +84,7 @@ jobs:
working-directory: ./solidity
run: |
npx hardhat node --no-deploy &
HH_NODE_PID=$!
while ! lsof -n -Fn -p $HH_NODE_PID | grep -q '^n.*:8545$'; do sleep 10; done
while [[ -z $(lsof -i :8545 -t) ]]; do echo "Waiting for port 8545 to be open..."; sleep 10; done
lukasz-zimnoch marked this conversation as resolved.
Show resolved Hide resolved

- name: Deploy contracts
working-directory: ./solidity
Expand Down
2 changes: 1 addition & 1 deletion solidity/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const config: HardhatUserConfig = {
allowUnlimitedContractSize: process.env.TEST_USE_STUBS_TBTC === "true",
},
system_tests: {
url: "http://localhost:8545",
url: "http://127.0.0.1:8545",
lukasz-zimnoch marked this conversation as resolved.
Show resolved Hide resolved
tags: ["allowStubs"],
},
development: {
Expand Down
4 changes: 2 additions & 2 deletions system-tests/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import "hardhat-deploy"
const config: HardhatUserConfig = {
networks: {
development: {
url: "http://localhost:8545",
url: "http://127.0.0.1:8545",
},
system_tests: {
url: "http://localhost:8545",
url: "http://127.0.0.1:8545",
},
},

Expand Down
9 changes: 4 additions & 5 deletions system-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
"lint:fix:eslint": "eslint . --fix",
"lint:config": "prettier --check '**/*.@(json|yaml)'",
"lint:config:fix": "prettier --write '**/*.@(json|yaml)'",
"test": "hardhat test",
"postinstall": "npm rebuild"
"test": "hardhat test"
},
"files": [
"test/**/*"
],
"dependencies": {
"@keep-network/tbtc-v2.ts": "development",
"@keep-network/tbtc-v2.ts": "2.0.0-dev.0",
tomaszslabon marked this conversation as resolved.
Show resolved Hide resolved
"elliptic": "^6.5.4",
"wif": "^2.0.6"
},
Expand All @@ -42,14 +41,14 @@
"eslint-config-keep": "github:keep-network/eslint-config-keep",
"ethereum-waffle": "4.0.0-alpha.25",
"ethers": "^5.5.3",
"hardhat": "^2.8.3",
"hardhat": "^2.18.2",
"hardhat-deploy": "^0.11.10",
"mocha": "^9.0.2",
"prettier": "^2.3.2",
"ts-node": "^10.1.0",
"typescript": "^4.3.5"
},
"engines": {
"node": ">= 14.0.0"
"node": ">= 16"
}
}
31 changes: 28 additions & 3 deletions system-tests/test/deposit-redemption.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
ElectrumClient,
EthereumBridge,
BitcoinTransactionHash,
BitcoinNetwork,
} from "@keep-network/tbtc-v2.ts/dist/src"
import { computeHash160 } from "@keep-network/tbtc-v2.ts/dist/src/bitcoin"
import { computeHash160, createAddressFromPublicKey } from "@keep-network/tbtc-v2.ts/dist/src/bitcoin"
import { Hex } from "@keep-network/tbtc-v2.ts/dist/src/hex"
import { BigNumber, constants, Contract } from "ethers"
import chai, { expect } from "chai"
import { submitDepositTransaction } from "@keep-network/tbtc-v2.ts/dist/src/deposit"
Expand Down Expand Up @@ -59,6 +61,7 @@ describe("System Test - Deposit and redemption", () => {

const depositAmount = BigNumber.from(2000000)
const depositSweepTxFee = BigNumber.from(10000)
const depositTxFee = BigNumber.from(1500)
// Number of retries for Electrum requests.
const ELECTRUM_RETRIES = 5
// Initial backoff step in milliseconds that will be increased exponentially for
Expand Down Expand Up @@ -137,11 +140,22 @@ describe("System Test - Deposit and redemption", () => {
Generated deposit data:
${JSON.stringify(deposit)}
`)

const depositorBitcoinAddress = createAddressFromPublicKey(
Hex.from(systemTestsContext.depositorBitcoinKeyPair.publicKey.compressed),
BitcoinNetwork.Testnet,
)
const depositorUtxos = await electrumClient.findAllUnspentTransactionOutputs(
depositorBitcoinAddress
)

;({ depositUtxo } = await submitDepositTransaction(
deposit,
systemTestsContext.depositorBitcoinKeyPair.wif,
electrumClient,
true
true,
depositorUtxos,
depositTxFee
))

console.log(`
Expand Down Expand Up @@ -408,11 +422,22 @@ describe("System Test - Deposit and redemption", () => {
Generated deposit data:
${JSON.stringify(deposit)}
`)

const depositorBitcoinAddress = createAddressFromPublicKey(
Hex.from(systemTestsContext.depositorBitcoinKeyPair.publicKey.compressed),
BitcoinNetwork.Testnet,
)
const depositorUtxos = await electrumClient.findAllUnspentTransactionOutputs(
depositorBitcoinAddress
)

;({ depositUtxo } = await submitDepositTransaction(
deposit,
systemTestsContext.depositorBitcoinKeyPair.wif,
electrumClient,
true
true,
depositorUtxos,
depositTxFee
))

console.log(`
Expand Down
18 changes: 16 additions & 2 deletions system-tests/test/minting-unminting.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import {
EthereumAddress,
EthereumBridge,
BitcoinTransactionHash,
BitcoinNetwork,
} from "@keep-network/tbtc-v2.ts/dist/src"
import { computeHash160 } from "@keep-network/tbtc-v2.ts/dist/src/bitcoin"
import { computeHash160, createAddressFromPublicKey } from "@keep-network/tbtc-v2.ts/dist/src/bitcoin"
import { Hex } from "@keep-network/tbtc-v2.ts/dist/src/hex"
import { BigNumber, constants, Contract, utils as ethersUtils } from "ethers"
import chai, { expect } from "chai"
import { submitDepositTransaction } from "@keep-network/tbtc-v2.ts/dist/src/deposit"
Expand Down Expand Up @@ -62,6 +64,7 @@ describe("System Test - Minting and unminting", () => {

const depositAmount = BigNumber.from(2000000)
const depositSweepTxFee = BigNumber.from(10000)
const depositTxFee = BigNumber.from(1500)
// Number of retries for Electrum requests.
const ELECTRUM_RETRIES = 5
// Initial backoff step in milliseconds that will be increased exponentially for
Expand Down Expand Up @@ -140,11 +143,22 @@ describe("System Test - Minting and unminting", () => {
Generated deposit data:
${JSON.stringify(deposit)}
`)

const depositorBitcoinAddress = createAddressFromPublicKey(
Hex.from(systemTestsContext.depositorBitcoinKeyPair.publicKey.compressed),
BitcoinNetwork.Testnet,
)
const depositorUtxos = await electrumClient.findAllUnspentTransactionOutputs(
depositorBitcoinAddress
)

;({ depositUtxo } = await submitDepositTransaction(
deposit,
systemTestsContext.depositorBitcoinKeyPair.wif,
electrumClient,
true
true,
depositorUtxos,
depositTxFee
))

console.log(`
Expand Down
Loading
Loading