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

Add some utils/bitcoin test #728

Merged
merged 1 commit into from
Dec 30, 2024
Merged
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
20 changes: 19 additions & 1 deletion webapp/test/utils/bitcoin.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
import { getBitcoinTimestamp } from 'utils/bitcoin'
import { calculateDepositAmount, getBitcoinTimestamp } from 'utils/bitcoin'
import { describe, expect, it, vi } from 'vitest'

describe('utils/bitcoin', function () {
describe('calculateDepositAmount', function () {
it('calculate the deposit amount of a bitcoin deposit transaction', function () {
const userAddress = 'tb1qmynr0k2fuvc24rg2j0xq2wztjvwuqnkdjxvky6'
const bitcoinCustodyAddress = 'tb1qvs632vkezddhuahgdqmwjapm4raprsx0nvyq2q'

const utxos = [
// amount sent to the custody address
{ value: 10000, scriptpubkeyAddress: bitcoinCustodyAddress },
// OP_RETURN
{ value: 0 },
// change
{ value: 300000, scriptpubkeyAddress: userAddress },
]

expect(calculateDepositAmount(utxos, bitcoinCustodyAddress)).toBe(10000)
})
})

describe('getBitcoinTimestamp', function () {
it('should return the block time if is prior to the current time', function () {
// using 5 minutes ago
Expand Down
Loading