@@ -199,28 +199,45 @@ describe('NodeConnection', () => {
199
199
} ) ;
200
200
201
201
describe ( 'waitForTransactionConfirmation' , ( ) => {
202
+ const mainnetAcceptedTx = "at1dl9lze8wscct0dee8x9tjnfmpjvj33hh23jcnp5f0ywjn5552yrsperzl9" ;
203
+ const mainnetRejectedTx = "at1x5ed0pyjpt3770e0m60psvdvqeww5z5f32t7velrmrjfhvzgysxqll4g6a" ;
204
+ const testnetAcceptedTx = "at1aknmzq2k2ktuy8l55hthlzkues98fuye0s05nnxfp86ruukz5grsrrujgv" ;
205
+ const testnetRejectedTx = "at1xmjjt0sr2nv2ah38t7j9hmema28w7xfdckz9slyfjqjqywpudvxqdlxvd3" ;
206
+ const invalidTx = "at1dl9lze8wscct0dee8x9tjnfmpj12345678jcnp5f0ywjn5552yrsperzl9" ;
207
+
208
+ const host = "https://api.explorer.provable.com/v1" ;
209
+
210
+ function getTxId ( connection : AleoNetworkClient , type : "accepted" | "rejected" ) {
211
+ const isTestnet = connection . host . includes ( "/testnet" ) ;
212
+ return type === "accepted"
213
+ ? ( isTestnet ? testnetAcceptedTx : mainnetAcceptedTx )
214
+ : ( isTestnet ? testnetRejectedTx : mainnetRejectedTx ) ;
215
+ }
216
+
202
217
it ( 'should return accepted for a valid tx ID' , async ( ) => {
203
- const connection = new AleoNetworkClient ( "https://api.explorer.provable.com/" ) ;
204
- const status = await connection . waitForTransactionConfirmation ( "at1dl9lze8wscct0dee8x9tjnfmpjvj33hh23jcnp5f0ywjn5552yrsperzl9" ) ;
218
+ const connection = new AleoNetworkClient ( host ) ;
219
+ const txId = getTxId ( connection , "accepted" ) ;
220
+ const status = await connection . waitForTransactionConfirmation ( txId ) ;
205
221
expect ( status ) . to . equal ( "accepted" ) ;
206
222
} ) ;
207
-
223
+
208
224
it ( 'should return rejected for a rejected tx ID' , async ( ) => {
209
- const connection = new AleoNetworkClient ( "https://api.explorer.provable.com/" ) ;
210
- const status = await connection . waitForTransactionConfirmation ( "at1x5ed0pyjpt3770e0m60psvdvqeww5z5f32t7velrmrjfhvzgysxqll4g6a" ) ;
225
+ const connection = new AleoNetworkClient ( host ) ;
226
+ const txId = getTxId ( connection , "rejected" ) ;
227
+ const status = await connection . waitForTransactionConfirmation ( txId ) ;
211
228
expect ( status ) . to . equal ( "rejected" ) ;
212
229
} ) ;
213
230
214
231
it ( 'should throw for a malformed tx ID' , async ( ) => {
215
- const connection = new AleoNetworkClient ( "https://api.explorer.provable.com/" ) ;
216
- try {
217
- await connection . waitForTransactionConfirmation ( "at1dl9lze8wscct0dee8x9tjnfmpj12345678jcnp5f0ywjn5552yrsperzl9" ) ;
218
- throw new Error ( "Expected waitForTransactionConfirmation to throw" ) ;
219
- } catch ( err : any ) {
220
- expect ( err . message ) . to . include ( "Malformed transaction ID" ) ;
221
- expect ( err . message ) . to . include ( "Invalid URL" ) ;
222
- }
223
- } ) ;
232
+ const connection = new AleoNetworkClient ( host ) ;
233
+ try {
234
+ await connection . waitForTransactionConfirmation ( invalidTx ) ;
235
+ throw new Error ( "Expected waitForTransactionConfirmation to throw" ) ;
236
+ } catch ( err : any ) {
237
+ expect ( err . message ) . to . include ( "Malformed transaction ID" ) ;
238
+ expect ( err . message ) . to . include ( "Invalid URL" ) ;
239
+ }
240
+ } ) ;
224
241
} ) ;
225
242
226
243
describe ( 'findUnspentRecords' , ( ) => {
0 commit comments