@@ -35,10 +35,16 @@ async function expectThrows(f: () => Promise<any>): Promise<void> {
35
35
36
36
describe ( 'NodeConnection' , ( ) => {
37
37
let connection : AleoNetworkClient ;
38
+ let network : string ;
38
39
let windowFetchSpy : sinon . SinonSpy ;
39
40
40
41
beforeEach ( ( ) => {
41
42
connection = new AleoNetworkClient ( "https://api.explorer.provable.com/v1" ) ;
43
+ if ( connection . host === "https://api.explorer.provable.com/v1/testnet" ) {
44
+ network = "testnet" ;
45
+ } else {
46
+ network = "mainnet" ;
47
+ }
42
48
windowFetchSpy = sinon . spy ( globalThis , 'fetch' ) ;
43
49
} ) ;
44
50
@@ -237,8 +243,7 @@ describe('NodeConnection', () => {
237
243
238
244
describe ( 'Test API methods that return wasm objects' , ( ) => {
239
245
it ( 'Plaintext returned from the API should have expected properties' , async ( ) => {
240
- const transactions = await connection . getTransactions ( 27400 ) ;
241
- if ( transactions . length > 0 ) {
246
+ if ( network === "testnet" ) {
242
247
// Check a struct variant of a plaintext object.
243
248
let plaintext = await connection . getProgramMappingPlaintext ( "credits.aleo" , "committee" , "aleo17m3l8a4hmf3wypzkf5lsausfdwq9etzyujd0vmqh35ledn2sgvqqzqkqal" ) ;
244
249
expect ( plaintext . plaintextType ( ) ) . equal ( "struct" ) ;
@@ -259,8 +264,7 @@ describe('NodeConnection', () => {
259
264
260
265
it ( 'should have correct data within the wasm object and summary object for an execution transaction' , async ( ) => {
261
266
// Get the first transaction at block 24700 on testnet.
262
- const transactions = await connection . getTransactions ( 27400 ) ;
263
- if ( transactions . length > 0 ) {
267
+ if ( network === "testnet" ) {
264
268
const transaction = await connection . getTransactionObject ( "at1fjy6s9md2v4rgcn3j3q4qndtfaa2zvg58a4uha0rujvrn4cumu9qfazxdd" ) ;
265
269
const transition = < Transition > transaction . transitions ( ) [ 0 ] ;
266
270
const summary = < TransactionObject > transaction . summary ( true ) ;
@@ -325,8 +329,7 @@ describe('NodeConnection', () => {
325
329
326
330
it ( 'should have correct data within the wasm object and summary object for a deployment transaction' , async ( ) => {
327
331
// Get the deployment transaction for token_registry.aleo
328
- const transactions = await connection . getTransactions ( 27400 ) ;
329
- if ( transactions . length === 0 ) {
332
+ if ( network === "mainnet" ) {
330
333
const transaction = await connection . getTransactionObject ( "at15mwg0jyhvpjjrfxwrlwzn8puusnmy7r3xzvpjht4e5gzgnp68q9qd0qqec" ) ;
331
334
const summary = < TransactionObject > transaction . summary ( true ) ;
332
335
const deployment = < DeploymentObject > summary . deployment ;
@@ -352,8 +355,8 @@ describe('NodeConnection', () => {
352
355
} ) ;
353
356
354
357
it ( 'Should give the correct JSON response when requesting multiple transactions' , async ( ) => {
355
- const transactions = await connection . getTransactions ( 27400 ) ;
356
- if ( transactions . length > 0 ) {
358
+ if ( network === "testnet" ) {
359
+ const transactions = await connection . getTransactions ( 27400 ) ;
357
360
expect ( transactions . length ) . equal ( 4 ) ;
358
361
expect ( transactions [ 0 ] . status ) . equal ( "accepted" ) ;
359
362
expect ( transactions [ 0 ] . type ) . equal ( "execute" ) ;
0 commit comments