@@ -13,7 +13,7 @@ import {
1313 toUtxoPsbt ,
1414 toWrappedPsbt ,
1515} from '@bitgo/utxo-core/descriptor' ;
16- import { getFixture , toPlainObject } from '@bitgo/utxo-core/testutil' ;
16+ import { toPlainObject } from '@bitgo/utxo-core/testutil' ;
1717import { getBabylonParamByVersion } from '@bitgo/babylonlabs-io-btc-staking-ts' ;
1818
1919import {
@@ -25,7 +25,12 @@ import {
2525 forceFinalizePsbt ,
2626} from '../../../src/babylon' ;
2727import { parseStakingDescriptor } from '../../../src/babylon/parseDescriptor' ;
28- import { normalize } from '../fixtures.utils' ;
28+ import {
29+ normalize ,
30+ assertEqualsFixture ,
31+ assertEqualsMiniscript ,
32+ assertTransactionEqualsFixture ,
33+ } from '../fixtures.utils' ;
2934
3035import { fromXOnlyPublicKey , getECKey , getECKeys , getXOnlyPubkey } from './key.utils' ;
3136import { getBitGoUtxoStakingMsgCreateBtcDelegation , getVendorMsgCreateBtcDelegation } from './vendor.utils' ;
@@ -203,18 +208,6 @@ function parseScripts(scripts: unknown) {
203208 return Object . fromEntries ( Object . entries ( scripts ) . map ( ( [ key , value ] ) => [ key , parseScript ( key , value ) ] ) ) ;
204209}
205210
206- type EqualsAssertion = typeof assert . deepStrictEqual ;
207-
208- async function assertEqualsFixture (
209- fixtureName : string ,
210- value : unknown ,
211- n = normalize ,
212- eq : EqualsAssertion = assert . deepStrictEqual
213- ) : Promise < void > {
214- value = n ( value ) ;
215- eq ( await getFixture ( fixtureName , value ) , value ) ;
216- }
217-
218211async function assertScriptsEqualFixture (
219212 fixtureName : string ,
220213 builder : vendor . StakingScriptData ,
@@ -226,19 +219,6 @@ async function assertScriptsEqualFixture(
226219 } ) ;
227220}
228221
229- async function assertTransactionEqualsFixture ( fixtureName : string , tx : unknown ) : Promise < void > {
230- await assertEqualsFixture ( fixtureName , normalize ( tx ) ) ;
231- }
232-
233- function assertEqualsMiniscript ( script : Buffer , miniscript : ast . MiniscriptNode ) : void {
234- const ms = Miniscript . fromBitcoinScript ( script , 'tap' ) ;
235- assert . deepStrictEqual ( ast . fromMiniscript ( ms ) , miniscript ) ;
236- assert . deepStrictEqual (
237- script . toString ( 'hex' ) ,
238- Buffer . from ( Miniscript . fromString ( ast . formatNode ( miniscript ) , 'tap' ) . encode ( ) ) . toString ( 'hex' )
239- ) ;
240- }
241-
242222function assertEqualScripts ( descriptorBuilder : BabylonDescriptorBuilder , builder : vendor . StakingScripts ) {
243223 for ( const [ key , script ] of Object . entries ( builder ) as [ keyof vendor . StakingScripts , Buffer ] [ ] ) {
244224 switch ( key ) {
0 commit comments