@@ -20,6 +20,8 @@ import {
2020 compiledComplexSierra ,
2121 compiledHelloSierra ,
2222 compiledHelloSierraCasm ,
23+ describeIfDevnetSequencer ,
24+ describeIfSequencerGoerli ,
2325 getTestAccount ,
2426 getTestProvider ,
2527} from './fixtures' ;
@@ -36,13 +38,31 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
3638 let cairo1Contract : TypedContract < typeof tAbi > ;
3739 initializeMatcher ( expect ) ;
3840
39- xtest ( 'Declare & deploy v2 - Hello Cairo 1 contract' , async ( ) => {
41+ beforeAll ( async ( ) => {
42+ dd = await account . declareAndDeploy ( {
43+ contract : compiledHelloSierra ,
44+ casm : compiledHelloSierraCasm ,
45+ } ) ;
46+
47+ cairo1Contract = new Contract (
48+ compiledHelloSierra . abi ,
49+ dd . deploy . contract_address ,
50+ account
51+ ) . typed ( tAbi ) ;
52+ } ) ;
53+
54+ test ( 'Declare & deploy v2 - Hello Cairo 1 contract' , async ( ) => {
4055 expect ( dd . declare ) . toMatchSchemaRef ( 'DeclareContractResponse' ) ;
4156 expect ( dd . deploy ) . toMatchSchemaRef ( 'DeployContractUDCResponse' ) ;
4257 expect ( cairo1Contract ) . toBeInstanceOf ( Contract ) ;
4358 } ) ;
4459
45- xtest ( 'ContractFactory on Cairo1' , async ( ) => {
60+ test ( 'getCairoVersion' , async ( ) => {
61+ const version1 = await cairo1Contract . getVersion ( ) ;
62+ expect ( version1 ) . toEqual ( { cairo : '1' , compiler : '1' } ) ;
63+ } ) ;
64+
65+ test ( 'ContractFactory on Cairo1' , async ( ) => {
4666 const c1CFactory = new ContractFactory ( {
4767 compiledContract : compiledHelloSierra ,
4868 casm : compiledHelloSierraCasm ,
@@ -67,53 +87,53 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
6787 } ) ;
6888 } ) ;
6989
70- xtest ( 'deployContract Cairo1' , async ( ) => {
90+ test ( 'deployContract Cairo1' , async ( ) => {
7191 const deploy = await account . deployContract ( {
7292 classHash : dd . deploy . classHash ,
7393 } ) ;
7494 expect ( deploy ) . toHaveProperty ( 'address' ) ;
7595 } ) ;
7696
77- xtest ( 'GetClassByHash' , async ( ) => {
97+ test ( 'GetClassByHash' , async ( ) => {
7898 const classResponse = await provider . getClassByHash ( dd . deploy . classHash ) ;
7999 expect ( classResponse ) . toMatchSchemaRef ( 'SierraContractClass' ) ;
80100 } ) ;
81101
82- xtest ( 'GetClassAt' , async ( ) => {
102+ test ( 'GetClassAt' , async ( ) => {
83103 const classResponse = await provider . getClassAt ( dd . deploy . contract_address ) ;
84104 expect ( classResponse ) . toMatchSchemaRef ( 'SierraContractClass' ) ;
85105 } ) ;
86106
87- xtest ( 'isCairo1' , async ( ) => {
107+ test ( 'isCairo1' , async ( ) => {
88108 const isContractCairo1 = cairo1Contract . isCairo1 ( ) ;
89109 expect ( isContractCairo1 ) . toBe ( true ) ;
90110 const isAbiCairo1 = isCairo1Abi ( cairo1Contract . abi ) ;
91111 expect ( isAbiCairo1 ) . toBe ( true ) ;
92112 } ) ;
93113
94- xtest ( 'Cairo 1 Contract Interaction - skip invoke validation & call parsing' , async ( ) => {
114+ test ( 'Cairo 1 Contract Interaction - skip invoke validation & call parsing' , async ( ) => {
95115 const tx = await cairo1Contract . increase_balance (
96116 CallData . compile ( {
97117 amount : 100 ,
98118 } )
99119 ) ;
100120 await account . waitForTransaction ( tx . transaction_hash ) ;
101121
102- // const balance = await cairo1Contract.get_balance({
103- // parseResponse: false,
104- // });
122+ const balance = await cairo1Contract . get_balance ( {
123+ parseResponse : false ,
124+ } ) ;
105125
106- // expect(num.toBigInt(balance[0] )).toBe(100n);
126+ expect ( num . toBigInt ( balance ) ) . toBe ( 100n ) ;
107127 } ) ;
108128
109- xtest ( 'Cairo 1 Contract Interaction - felt252' , async ( ) => {
129+ test ( 'Cairo 1 Contract Interaction - felt252' , async ( ) => {
110130 const tx = await cairo1Contract . increase_balance ( 100 ) ;
111131 await account . waitForTransaction ( tx . transaction_hash ) ;
112132 const balance = await cairo1Contract . get_balance ( ) ;
113133 expect ( balance ) . toBe ( 200n ) ;
114134 } ) ;
115135
116- xtest ( 'Cairo 1 Contract Interaction - uint 8, 16, 32, 64, 128' , async ( ) => {
136+ test ( 'Cairo 1 Contract Interaction - uint 8, 16, 32, 64, 128' , async ( ) => {
117137 const tx = await cairo1Contract . increase_balance_u8 ( 255n ) ;
118138 await account . waitForTransaction ( tx . transaction_hash ) ;
119139 const balance = await cairo1Contract . get_balance_u8 ( ) ;
@@ -129,7 +149,7 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
129149 expect ( result ) . toBe ( 256n ) ;
130150 } ) ;
131151
132- xtest ( 'Cairo 1 - uint256' , async ( ) => {
152+ test ( 'Cairo 1 - uint256' , async ( ) => {
133153 // defined as number
134154 const result = await cairo1Contract . test_u256 ( 2n ** 256n - 2n ) ;
135155 expect ( result ) . toBe ( 2n ** 256n - 1n ) ;
@@ -139,7 +159,7 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
139159 expect ( result1 ) . toBe ( 2n ** 256n - 1n ) ;
140160 } ) ;
141161
142- xtest ( 'Cairo 1 Contract Interaction - bool' , async ( ) => {
162+ test ( 'Cairo 1 Contract Interaction - bool' , async ( ) => {
143163 const cdata = CallData . compile ( { false : false , true : true } ) ;
144164 expect ( cdata ) . toEqual ( [ '0' , '1' ] ) ;
145165
@@ -162,15 +182,15 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
162182 expect ( status ) . toBe ( true ) ;
163183 } ) ;
164184
165- xtest ( 'Cairo 1 Contract Interaction - ContractAddress' , async ( ) => {
185+ test ( 'Cairo 1 Contract Interaction - ContractAddress' , async ( ) => {
166186 const tx = await cairo1Contract . set_ca ( '123' ) ;
167187 await account . waitForTransaction ( tx . transaction_hash ) ;
168188 const status = await cairo1Contract . get_ca ( ) ;
169189
170190 expect ( status ) . toBe ( 123n ) ;
171191 } ) ;
172192
173- xtest ( 'Cairo1 simple getStorageAt variables retrieval' , async ( ) => {
193+ test ( 'Cairo1 simple getStorageAt variables retrieval' , async ( ) => {
174194 // u8
175195 let tx = await cairo1Contract . increase_balance ( 100 ) ;
176196 await account . waitForTransaction ( tx . transaction_hash ) ;
@@ -216,7 +236,7 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
216236 expect ( Object . values ( status ) ) . toEqual ( [ 77n , 123n ] ) ;
217237 } ) ;
218238
219- xtest ( 'Cairo 1 Contract Interaction - echo flat un-nested Array u8, uint256, bool' , async ( ) => {
239+ test ( 'Cairo 1 Contract Interaction - echo flat un-nested Array u8, uint256, bool' , async ( ) => {
220240 const status = await cairo1Contract . echo_array ( [ 123 , 55 , 77 , 255 ] ) ;
221241 expect ( status ) . toEqual ( [ 123n , 55n , 77n , 255n ] ) ;
222242
@@ -237,7 +257,7 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
237257 expect ( status2 ) . toEqual ( [ true , true , false , false ] ) ;
238258 } ) ;
239259
240- xtest ( 'Cairo 1 Contract Interaction - echo flat un-nested Struct' , async ( ) => {
260+ test ( 'Cairo 1 Contract Interaction - echo flat un-nested Struct' , async ( ) => {
241261 const status = await cairo1Contract . echo_struct ( {
242262 val : 'simple' ,
243263 } ) ;
@@ -277,7 +297,7 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
277297 expect ( expected ) . toEqual ( status ) ;
278298 } ) ;
279299
280- xtest ( 'C1 Array 2D' , async ( ) => {
300+ test ( 'C1 Array 2D' , async ( ) => {
281301 const cd = CallData . compile ( {
282302 test : [
283303 [ 1 , 2 ] ,
@@ -330,7 +350,7 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
330350 } ) ;
331351 } ) ;
332352
333- xtest ( 'myCallData.compile for Cairo 1' , async ( ) => {
353+ test ( 'myCallData.compile for Cairo 1' , async ( ) => {
334354 const myFalseUint256 = { high : 1 , low : 23456 } ; // wrong order
335355 type Order2 = {
336356 p1 : BigNumberish ;
@@ -475,67 +495,72 @@ describe('TS validation for API & Contract interactions - tests skipped', () =>
475495 expect ( callDataFromArray ) . toStrictEqual ( expectedResult ) ;
476496 } ) ;
477497
478- xtest ( 'getCompiledClassByClassHash' , async ( ) => {
479- const compiledClass = await ( provider as SequencerProvider ) . getCompiledClassByClassHash (
480- dd . deploy . classHash
481- ) ;
482- expect ( compiledClass ) . toMatchSchemaRef ( 'CompiledClass' ) ;
498+ describeIfDevnetSequencer ( 'Sequencer only' , ( ) => {
499+ test ( 'getCompiledClassByClassHash' , async ( ) => {
500+ const compiledClass = await ( provider as SequencerProvider ) . getCompiledClassByClassHash (
501+ dd . deploy . classHash
502+ ) ;
503+ expect ( compiledClass ) . toMatchSchemaRef ( 'CompiledClass' ) ;
504+ } ) ;
483505 } ) ;
484506} ) ;
485507
486- describe ( 'TS validation for Sequencer API - C1 T2 C:0x771bbe2ba64f... - tests skipped' , ( ) => {
487- const provider = getTestProvider ( ) as SequencerProvider ;
488- const classHash : any = '0x028b6f2ee9ae00d55a32072d939a55a6eb522974a283880f3c73a64c2f9fd6d6' ;
489- const contractAddress : any = '0x771bbe2ba64fa5ab52f0c142b4296fc67460a3a2372b4cdce752c620e3e8194' ;
490- let cairo1Contract : TypedContract < typeof tAbi > ;
491- initializeMatcher ( expect ) ;
492-
493- xtest ( 'getCompiledClassByClassHash' , async ( ) => {
494- const compiledClass = await provider . getCompiledClassByClassHash ( classHash ) ;
495- expect ( compiledClass ) . toMatchSchemaRef ( 'CompiledClass' ) ;
496- } ) ;
508+ describeIfSequencerGoerli ( 'Cairo1 Testnet' , ( ) => {
509+ describe ( 'TS validation for Sequencer API - C1 T2 C:0x771bbe2ba64f... - tests skipped' , ( ) => {
510+ const provider = getTestProvider ( ) as SequencerProvider ;
511+ const classHash : any = '0x028b6f2ee9ae00d55a32072d939a55a6eb522974a283880f3c73a64c2f9fd6d6' ;
512+ const contractAddress : any =
513+ '0x771bbe2ba64fa5ab52f0c142b4296fc67460a3a2372b4cdce752c620e3e8194' ;
514+ let cairo1Contract : TypedContract < typeof tAbi > ;
515+ initializeMatcher ( expect ) ;
516+
517+ test ( 'getCompiledClassByClassHash' , async ( ) => {
518+ const compiledClass = await provider . getCompiledClassByClassHash ( classHash ) ;
519+ expect ( compiledClass ) . toMatchSchemaRef ( 'CompiledClass' ) ;
520+ } ) ;
497521
498- xtest ( 'GetClassByHash' , async ( ) => {
499- const classResponse = await provider . getClassByHash ( classHash ) ;
500- expect ( classResponse ) . toMatchSchemaRef ( 'SierraContractClass' ) ;
501- } ) ;
522+ test ( 'GetClassByHash' , async ( ) => {
523+ const classResponse = await provider . getClassByHash ( classHash ) ;
524+ expect ( classResponse ) . toMatchSchemaRef ( 'SierraContractClass' ) ;
525+ } ) ;
502526
503- xtest ( 'GetClassAt' , async ( ) => {
504- const classResponse = await provider . getClassAt ( contractAddress ) ;
505- expect ( classResponse ) . toMatchSchemaRef ( 'SierraContractClass' ) ;
506- } ) ;
527+ test ( 'GetClassAt' , async ( ) => {
528+ const classResponse = await provider . getClassAt ( contractAddress ) ;
529+ expect ( classResponse ) . toMatchSchemaRef ( 'SierraContractClass' ) ;
530+ } ) ;
507531
508- xtest ( 'Cairo 1 Contract Interaction - felt252' , async ( ) => {
509- const result = await cairo1Contract . test_felt252 ( 100 ) ;
510- expect ( result ) . toBe ( 101n ) ;
511- } ) ;
532+ test ( 'Cairo 1 Contract Interaction - felt252' , async ( ) => {
533+ const result = await cairo1Contract . test_felt252 ( 100 ) ;
534+ expect ( result ) . toBe ( 101n ) ;
535+ } ) ;
512536
513- xtest ( 'Cairo 1 Contract Interaction - uint 8, 16, 32, 64, 128' , async ( ) => {
514- const r1 = await cairo1Contract . test_u8 ( 100n ) ;
515- expect ( r1 ) . toBe ( 107n ) ;
516- const r2 = await cairo1Contract . test_u16 ( 100n ) ;
517- expect ( r2 ) . toBe ( 106n ) ;
518- const r3 = await cairo1Contract . test_u32 ( 100n ) ;
519- expect ( r3 ) . toBe ( 104n ) ;
520- const r4 = await cairo1Contract . test_u64 ( 255n ) ;
521- expect ( r4 ) . toBe ( 258n ) ;
522- const r5 = await cairo1Contract . test_u128 ( 255n ) ;
523- expect ( r5 ) . toBe ( 257n ) ;
524- } ) ;
537+ test ( 'Cairo 1 Contract Interaction - uint 8, 16, 32, 64, 128' , async ( ) => {
538+ const r1 = await cairo1Contract . test_u8 ( 100n ) ;
539+ expect ( r1 ) . toBe ( 107n ) ;
540+ const r2 = await cairo1Contract . test_u16 ( 100n ) ;
541+ expect ( r2 ) . toBe ( 106n ) ;
542+ const r3 = await cairo1Contract . test_u32 ( 100n ) ;
543+ expect ( r3 ) . toBe ( 104n ) ;
544+ const r4 = await cairo1Contract . test_u64 ( 255n ) ;
545+ expect ( r4 ) . toBe ( 258n ) ;
546+ const r5 = await cairo1Contract . test_u128 ( 255n ) ;
547+ expect ( r5 ) . toBe ( 257n ) ;
548+ } ) ;
525549
526- xtest ( 'Cairo 1 - uint256 struct' , async ( ) => {
527- const myUint256 = uint256 ( 2n ** 256n - 2n ) ;
528- const result = await cairo1Contract . test_u256 ( myUint256 ) ;
529- expect ( result ) . toBe ( 2n ** 256n - 1n ) ;
530- } ) ;
550+ test ( 'Cairo 1 - uint256 struct' , async ( ) => {
551+ const myUint256 = uint256 ( 2n ** 256n - 2n ) ;
552+ const result = await cairo1Contract . test_u256 ( myUint256 ) ;
553+ expect ( result ) . toBe ( 2n ** 256n - 1n ) ;
554+ } ) ;
531555
532- xtest ( 'Cairo 1 - uint256 by a bignumber' , async ( ) => {
533- const result = await cairo1Contract . test_u256 ( 2n ** 256n - 2n ) ;
534- expect ( result ) . toBe ( 2n ** 256n - 1n ) ;
535- } ) ;
556+ test ( 'Cairo 1 - uint256 by a bignumber' , async ( ) => {
557+ const result = await cairo1Contract . test_u256 ( 2n ** 256n - 2n ) ;
558+ expect ( result ) . toBe ( 2n ** 256n - 1n ) ;
559+ } ) ;
536560
537- xtest ( 'Cairo 1 Contract Interaction - bool' , async ( ) => {
538- const tx = await cairo1Contract . test_bool ( ) ;
539- expect ( tx ) . toBe ( true ) ;
561+ test ( 'Cairo 1 Contract Interaction - bool' , async ( ) => {
562+ const tx = await cairo1Contract . test_bool ( ) ;
563+ expect ( tx ) . toBe ( true ) ;
564+ } ) ;
540565 } ) ;
541566} ) ;
0 commit comments