Skip to content

Commit

Permalink
fix bitcoin test
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-sven committed Dec 4, 2024
1 parent 7d82857 commit f7f16d1
Showing 1 changed file with 73 additions and 73 deletions.
146 changes: 73 additions & 73 deletions sdk/typescript/rooch-sdk/test-e2e/case/bitcoin.test.ts
Original file line number Diff line number Diff line change
@@ -1,95 +1,95 @@
// Copyright (c) RoochNetwork
// SPDX-License-Identifier: Apache-2.0

import { afterAll, beforeAll, describe, it } from 'vitest'
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
import { TestBox } from '../setup.js'

describe('Bitcoin Assets API', () => {
let testBox: TestBox
beforeAll(async () => {
testBox = TestBox.setup()
// await testBox.loadBitcoinEnv()
// await testBox.loadORDEnv()
// await testBox.loadRoochEnv('local', 0)
await testBox.loadBitcoinEnv()
await testBox.loadORDEnv()
await testBox.loadRoochEnv('local', 0)
})

afterAll(async () => {
testBox.cleanEnv()
})

it('query utxo should be success', async () => {
// const addr = testBox.keypair.getSchnorrPublicKey().toAddress().bitcoinAddress.toStr()
//
// const result = await testBox.bitcoinContainer?.executeRpcCommandRaw([], 'generatetoaddress', [
// '50',
// addr,
// ])
// expect(result).toBeDefined()
//
// // rooch indexer
// await testBox.delay(10)
//
// const utxos = await testBox.getClient().queryUTXO({
// filter: {
// owner: addr,
// },
// })
//
// expect(utxos.data.length).toBeGreaterThan(0)
const addr = testBox.keypair.getSchnorrPublicKey().toAddress().bitcoinAddress.toStr()

const result = await testBox.bitcoinContainer?.executeRpcCommandRaw([], 'generatetoaddress', [
'50',
addr,
])
expect(result).toBeDefined()

// rooch indexer
await testBox.delay(10)

const utxos = await testBox.getClient().queryUTXO({
filter: {
owner: addr,
},
})

expect(utxos.data.length).toBeGreaterThan(0)
})

it('query inscriptions should be success', async () => {
// init wallet
// let result = await testBox.ordContainer?.execCmd('wallet create')
// expect(result!.exitCode).eq(0)
// result = await testBox.ordContainer?.execCmd('wallet receive')
// expect(result!.exitCode).eq(0)
// const addr = JSON.parse(result!.output).addresses[0]
//
// // mint utxo
// result = await testBox.bitcoinContainer?.executeRpcCommandRaw([], 'generatetoaddress', [
// '101',
// addr,
// ])
// expect(result).toBeDefined()
//
// // Then sleep: "10" wait ord sync and index
// await testBox.delay(10)
// result = await testBox.ordContainer?.execCmd('wallet balance')
// const balance = JSON.parse(result!.output).total
// expect(balance).eq(5000000000)
//
// // create a inscription
// testBox.shell(
// `echo "{"p":"brc-20","op":"mint","tick":"Rooch","amt":"1"}">/${testBox.ordContainer!.getHostDataPath()}/hello.txt`,
// )
// result = await testBox.ordContainer?.execCmd(
// `wallet inscribe --fee-rate 1 --file /data/hello.txt --destination ${addr}`,
// )
// expect(result!.exitCode).eq(0)
//
// // mint utxo
// result = await testBox.bitcoinContainer?.executeRpcCommandRaw([], 'generatetoaddress', [
// '1',
// addr,
// ])
// expect(result).toBeDefined()
//
// // wait rooch indexer
// await testBox.delay(10)
//
// const utxos = await testBox.getClient().queryUTXO({
// filter: {
// owner: addr,
// },
// })
// expect(utxos.data.length).toBeGreaterThan(0)
//
// const inscriptions = await testBox.getClient().queryInscriptions({
// filter: {
// owner: addr,
// },
// })
// expect(inscriptions.data.length).toBeGreaterThan(0)
let result = await testBox.ordContainer?.execCmd('wallet create')
expect(result!.exitCode).eq(0)
result = await testBox.ordContainer?.execCmd('wallet receive')
expect(result!.exitCode).eq(0)
const addr = JSON.parse(result!.output).addresses[0]

// mint utxo
result = await testBox.bitcoinContainer?.executeRpcCommandRaw([], 'generatetoaddress', [
'101',
addr,
])
expect(result).toBeDefined()

// Then sleep: "10" wait ord sync and index
await testBox.delay(10)
result = await testBox.ordContainer?.execCmd('wallet balance')
const balance = JSON.parse(result!.output).total
expect(balance).eq(5000000000)

// create a inscription
testBox.shell(
`echo "{"p":"brc-20","op":"mint","tick":"Rooch","amt":"1"}">/${testBox.ordContainer!.getHostDataPath()}/hello.txt`,
)
result = await testBox.ordContainer?.execCmd(
`wallet inscribe --fee-rate 1 --file /data/hello.txt --destination ${addr}`,
)
expect(result!.exitCode).eq(0)

// mint utxo
result = await testBox.bitcoinContainer?.executeRpcCommandRaw([], 'generatetoaddress', [
'1',
addr,
])
expect(result).toBeDefined()

// wait rooch indexer
await testBox.delay(10)

const utxos = await testBox.getClient().queryUTXO({
filter: {
owner: addr,
},
})
expect(utxos.data.length).toBeGreaterThan(0)

const inscriptions = await testBox.getClient().queryInscriptions({
filter: {
owner: addr,
},
})
expect(inscriptions.data.length).toBeGreaterThan(0)
})
})

0 comments on commit f7f16d1

Please sign in to comment.