@@ -18,11 +18,11 @@ import {
1818 carolPriv ,
1919 carolPub ,
2020} from '../fixture/vars.js' ;
21- import { Network } from '../../src/interfaces.js' ;
21+ import { Network , Utxo } from '../../src/interfaces.js' ;
2222import { addressToLockScript , randomUtxo } from '../../src/utils.js' ;
2323import p2pkhArtifact from '../fixture/p2pkh.artifact.js' ;
2424import twtArtifact from '../fixture/transfer_with_timeout.artifact.js' ;
25- import { getTxOutputs } from '../test-util.js' ;
25+ import { addUtxo , getTxOutputs } from '../test-util.js' ;
2626import SiblingIntrospectionArtifact from '../fixture/SiblingIntrospection.artifact.js' ;
2727
2828describe ( 'Multi Contract' , ( ) => {
@@ -38,16 +38,16 @@ describe('Multi Contract', () => {
3838 const p2pkhInstance1 = new Contract ( p2pkhArtifact , [ bobPkh ] , { provider } ) ;
3939 const p2pkhInstance2 = new Contract ( p2pkhArtifact , [ carolPkh ] , { provider } ) ;
4040
41- beforeAll ( ( ) => {
41+ beforeAll ( async ( ) => {
4242 // Note: We instantiate the contract with carolPkh to avoid mempool conflicts with other (P2PKH) tests
4343 console . log ( p2pkhInstance1 . tokenAddress ) ;
4444 console . log ( p2pkhInstance2 . tokenAddress ) ;
45- ( provider as any ) . addUtxo ?. ( p2pkhInstance1 . address , randomUtxo ( ) ) ;
46- ( provider as any ) . addUtxo ?. ( p2pkhInstance1 . address , randomUtxo ( ) ) ;
47- ( provider as any ) . addUtxo ?. ( p2pkhInstance2 . address , randomUtxo ( ) ) ;
48- ( provider as any ) . addUtxo ?. ( p2pkhInstance2 . address , randomUtxo ( ) ) ;
49- ( provider as any ) . addUtxo ?. ( bobAddress , randomUtxo ( ) ) ;
50- ( provider as any ) . addUtxo ?. ( bobAddress , randomUtxo ( ) ) ;
45+ await addUtxo ( provider , p2pkhInstance1 . address , randomUtxo ( ) ) ;
46+ await addUtxo ( provider , p2pkhInstance1 . address , randomUtxo ( ) ) ;
47+ await addUtxo ( provider , p2pkhInstance2 . address , randomUtxo ( ) ) ;
48+ await addUtxo ( provider , p2pkhInstance2 . address , randomUtxo ( ) ) ;
49+ await addUtxo ( provider , bobAddress , randomUtxo ( ) ) ;
50+ await addUtxo ( provider , bobAddress , randomUtxo ( ) ) ;
5151 } ) ;
5252
5353 it ( 'should fail with correct errors when using incorrect unlocker for p2pkhInstance1' , async ( ) => {
@@ -126,14 +126,14 @@ describe('Multi Contract', () => {
126126
127127 describe ( 'Different contracts' , ( ) => {
128128 const p2pkhContract = new Contract ( p2pkhArtifact , [ bobPkh ] , { provider } ) ;
129- const twtContract = new Contract ( twtArtifact , [ bobPub , carolPub , 100000n ] , { provider } ) ;
129+ const twtContract = new Contract ( twtArtifact , [ bobPub , carolPub , 100_000n ] , { provider } ) ;
130130
131- beforeAll ( ( ) => {
131+ beforeAll ( async ( ) => {
132132 console . log ( p2pkhContract . tokenAddress ) ;
133133 console . log ( twtContract . tokenAddress ) ;
134134
135- ( provider as any ) . addUtxo ?. ( p2pkhContract . address , randomUtxo ( ) ) ;
136- ( provider as any ) . addUtxo ?. ( twtContract . address , randomUtxo ( ) ) ;
135+ await addUtxo ( provider , p2pkhContract . address , randomUtxo ( ) ) ;
136+ await addUtxo ( provider , twtContract . address , randomUtxo ( ) ) ;
137137 } ) ;
138138
139139 it ( 'should fail with correct errors when using incorrect unlocker for p2pkhContract' , async ( ) => {
@@ -198,7 +198,7 @@ describe('Multi Contract', () => {
198198 . addInput ( twtContractUtxos [ 0 ] , twtContract . unlock . timeout ( bobSignatureTemplate ) )
199199 . addInput ( bobAddressUtxos [ 0 ] , bobSignatureTemplate . unlockP2PKH ( ) )
200200 . addOutput ( { to, amount } )
201- . setLocktime ( 1000000 )
201+ . setLocktime ( 100_000 )
202202 . send ( ) ;
203203
204204 // then
@@ -214,13 +214,15 @@ describe('Multi Contract', () => {
214214 const correctLockingBytecode = addressToLockScript ( correctContract . address ) ;
215215 const siblingIntrospectionContract = new Contract ( SiblingIntrospectionArtifact , [ correctLockingBytecode ] , { provider } ) ;
216216
217- const correctContractUtxo = randomUtxo ( ) ;
218- const incorrectContractUtxo = randomUtxo ( ) ;
219- const siblingIntrospectionUtxo = randomUtxo ( ) ;
217+ let correctContractUtxo : Utxo ;
218+ let incorrectContractUtxo : Utxo ;
219+ let siblingIntrospectionUtxo : Utxo ;
220220
221- ( provider as any ) . addUtxo ?.( correctContract . address , correctContractUtxo ) ;
222- ( provider as any ) . addUtxo ?.( incorrectContract . address , incorrectContractUtxo ) ;
223- ( provider as any ) . addUtxo ?.( siblingIntrospectionContract . address , siblingIntrospectionUtxo ) ;
221+ beforeAll ( async ( ) => {
222+ correctContractUtxo = await addUtxo ( provider , correctContract . address , randomUtxo ( ) ) ;
223+ incorrectContractUtxo = await addUtxo ( provider , incorrectContract . address , randomUtxo ( ) ) ;
224+ siblingIntrospectionUtxo = await addUtxo ( provider , siblingIntrospectionContract . address , randomUtxo ( ) ) ;
225+ } ) ;
224226
225227 it ( 'should succeed when introspecting correct sibling UTXOs' , async ( ) => {
226228 // given
0 commit comments