Skip to content

Commit

Permalink
Updated deposit submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Oct 26, 2023
1 parent c65cefc commit 80f360e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 5 deletions.
32 changes: 29 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 @@ -137,11 +139,23 @@ describe("System Test - Deposit and redemption", () => {
Generated deposit data:
${JSON.stringify(deposit)}
`)

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

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

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

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

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

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 @@ -140,11 +142,23 @@ describe("System Test - Minting and unminting", () => {
Generated deposit data:
${JSON.stringify(deposit)}
`)

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

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

console.log(`
Expand Down

0 comments on commit 80f360e

Please sign in to comment.