@@ -96,6 +96,50 @@ type AccessAPISuite struct {
9696 serviceClient * testnet.Client
9797}
9898
99+ func (s * AccessAPISuite ) TestAccessAPIs () {
100+ // Deploy the test contract once for both AN1 and AN2 tests
101+ _ = s .deployContract (lib .CounterContract , false )
102+ txResult := s .deployCounter ()
103+ targetHeight := txResult .BlockHeight + 1
104+ s .waitUntilIndexed (targetHeight )
105+
106+ s .T ().Run ("Script execution and get accounts using execution nodes" , func (t * testing.T ) {
107+ s .testScriptExecutionAndGetAccountsAN1 (targetHeight )
108+ })
109+
110+ s .T ().Run ("Script execution and get accounts using local data" , func (t * testing.T ) {
111+ s .testScriptExecutionAndGetAccountsAN2 (targetHeight )
112+ })
113+
114+ s .T ().Run ("MVP script execution with local storage" , func (t * testing.T ) {
115+ s .testMVPScriptExecutionLocalStorage ()
116+ })
117+
118+ s .T ().Run ("Send and subscribe transaction statuses" , func (t * testing.T ) {
119+ s .testSendAndSubscribeTransactionStatuses ()
120+ })
121+
122+ s .T ().Run ("Contract update" , func (t * testing.T ) {
123+ s .testContractUpdate ()
124+ })
125+
126+ s .T ().Run ("Transaction signature with plain extension data" , func (t * testing.T ) {
127+ s .testTransactionSignaturePlainExtensionData ()
128+ })
129+
130+ s .T ().Run ("Transaction signature with WebAuthn extension data" , func (t * testing.T ) {
131+ s .testTransactionSignatureWebAuthnExtensionData ()
132+ })
133+
134+ s .T ().Run ("Extension data preservation" , func (t * testing.T ) {
135+ s .testExtensionDataPreservation ()
136+ })
137+
138+ s .T ().Run ("Rejected invalid signature format" , func (t * testing.T ) {
139+ s .testRejectedInvalidSignatureFormat ()
140+ })
141+ }
142+
99143func (s * AccessAPISuite ) TearDownTest () {
100144 s .log .Info ().Msg ("================> Start TearDownTest" )
101145 s .net .Remove ()
@@ -193,50 +237,38 @@ func (s *AccessAPISuite) SetupTest() {
193237 }, 30 * time .Second , 1 * time .Second )
194238}
195239
196- // TestScriptExecutionAndGetAccountsAN1 test the Access API endpoints for executing scripts and getting
240+ // testScriptExecutionAndGetAccountsAN1 test the Access API endpoints for executing scripts and getting
197241// accounts using execution nodes.
198242//
199243// Note: not combining AN1, AN2 tests together because that causes a drastic increase in test run times. test cases are read-only
200244// and should not interfere with each other.
201- func (s * AccessAPISuite ) TestScriptExecutionAndGetAccountsAN1 () {
202- // deploy the test contract
203- _ = s .deployContract (lib .CounterContract , false )
204- txResult := s .deployCounter ()
205- targetHeight := txResult .BlockHeight + 1
206- s .waitUntilIndexed (targetHeight )
207-
245+ func (s * AccessAPISuite ) testScriptExecutionAndGetAccountsAN1 (targetHeight uint64 ) {
208246 // Run tests against Access 1, which uses the execution node
209247 s .testGetAccount (s .an1Client )
210248 s .testExecuteScriptWithSimpleScript (s .an1Client )
211249 s .testExecuteScriptWithSimpleContract (s .an1Client , targetHeight )
212250}
213251
214- // TestScriptExecutionAndGetAccountsAN2 test the Access API endpoints for executing scripts and getting
252+ // testScriptExecutionAndGetAccountsAN2 test the Access API endpoints for executing scripts and getting
215253// accounts using local storage.
216254//
217255// Note: not combining AN1, AN2 tests together because that causes a drastic increase in test run times. test cases are read-only
218256// and should not interfere with each other.
219- func (s * AccessAPISuite ) TestScriptExecutionAndGetAccountsAN2 () {
220- // deploy the test contract
221- _ = s .deployContract (lib .CounterContract , false )
222- txResult := s .deployCounter ()
223- targetHeight := txResult .BlockHeight + 1
224- s .waitUntilIndexed (targetHeight )
225-
257+ func (s * AccessAPISuite ) testScriptExecutionAndGetAccountsAN2 (targetHeight uint64 ) {
226258 // Run tests against Access 2, which uses local storage
227259 s .testGetAccount (s .an2Client )
228260 s .testExecuteScriptWithSimpleScript (s .an2Client )
229261 s .testExecuteScriptWithSimpleContract (s .an2Client , targetHeight )
230262}
231263
232- func (s * AccessAPISuite ) TestMVPScriptExecutionLocalStorage () {
264+ func (s * AccessAPISuite ) testMVPScriptExecutionLocalStorage () {
233265 // this is a specialized test that creates accounts, deposits funds, deploys contracts, etc, and
234266 // uses the provided access node to handle the Access API calls. there is an existing test that
235267 // covers the default config, so we only need to test with local storage.
236268 mvp .RunMVPTest (s .T (), s .ctx , s .net , s .accessNode2 )
237269}
238270
239- // TestSendAndSubscribeTransactionStatuses tests the functionality of sending and subscribing to transaction statuses.
271+ // testSendAndSubscribeTransactionStatuses tests the functionality of sending and subscribing to transaction statuses.
240272//
241273// This test verifies that a transaction can be created, signed, sent to the access API, and then the status of the transaction
242274// can be subscribed to. It performs the following steps:
@@ -245,7 +277,7 @@ func (s *AccessAPISuite) TestMVPScriptExecutionLocalStorage() {
245277// 3. Signs the transaction.
246278// 4. Sends and subscribes to the transaction status using the access API.
247279// 5. Verifies the received transaction statuses, ensuring they are received in order and the final status is "SEALED".
248- func (s * AccessAPISuite ) TestSendAndSubscribeTransactionStatuses () {
280+ func (s * AccessAPISuite ) testSendAndSubscribeTransactionStatuses () {
249281 accessNodeContainer := s .net .ContainerByName (testnet .PrimaryAN )
250282
251283 // Establish a gRPC connection to the access API
@@ -350,11 +382,20 @@ func (s *AccessAPISuite) TestSendAndSubscribeTransactionStatuses() {
350382
351383 // Check, if the final transaction status is sealed.
352384 s .Assert ().Equal (entities .TransactionStatus_SEALED , lastReportedTxStatus )
385+
386+ // Refresh the suite's service client to sync sequence number.
387+ // This test created a fresh local serviceClient and submitted a transaction,
388+ // which incremented the on-chain sequence number. The suite's s.serviceClient
389+ // still has the old cached sequence number, so we refresh it here.
390+ s .Require ().Eventually (func () bool {
391+ s .serviceClient , err = s .accessNode2 .TestnetClient ()
392+ return err == nil
393+ }, 30 * time .Second , 1 * time .Second )
353394}
354395
355- // TestContractUpdate tests that the Access API can index contract updates, and that the program cache
396+ // testContractUpdate tests that the Access API can index contract updates, and that the program cache
356397// is invalidated when a contract is updated.
357- func (s * AccessAPISuite ) TestContractUpdate () {
398+ func (s * AccessAPISuite ) testContractUpdate () {
358399 txResult := s .deployContract (OriginalContract , false )
359400 targetHeight := txResult .BlockHeight + 1
360401 s .waitUntilIndexed (targetHeight )
@@ -610,9 +651,9 @@ func convertToMessageSigWithExtensionData(sigs []sdk.TransactionSignature, exten
610651 return msgSigs
611652}
612653
613- // TestTransactionSignaturePlainExtensionData tests that the Access API properly handles the ExtensionData field
654+ // testTransactionSignaturePlainExtensionData tests that the Access API properly handles the ExtensionData field
614655// in transaction signatures for different authentication schemes.
615- func (s * AccessAPISuite ) TestTransactionSignaturePlainExtensionData () {
656+ func (s * AccessAPISuite ) testTransactionSignaturePlainExtensionData () {
616657 accessNodeContainer := s .net .ContainerByName (testnet .PrimaryAN )
617658
618659 // Establish a gRPC connection to the access API
@@ -757,8 +798,8 @@ func (s *AccessAPISuite) TestTransactionSignaturePlainExtensionData() {
757798 }
758799}
759800
760- // TestTransactionSignatureWebAuthnExtensionData tests the WebAuthn authentication scheme with properly constructed extension data.
761- func (s * AccessAPISuite ) TestTransactionSignatureWebAuthnExtensionData () {
801+ // testTransactionSignatureWebAuthnExtensionData tests the WebAuthn authentication scheme with properly constructed extension data.
802+ func (s * AccessAPISuite ) testTransactionSignatureWebAuthnExtensionData () {
762803 accessNodeContainer := s .net .ContainerByName (testnet .PrimaryAN )
763804
764805 // Establish a gRPC connection to the access API
@@ -920,9 +961,9 @@ func (s *AccessAPISuite) TestTransactionSignatureWebAuthnExtensionData() {
920961 }
921962}
922963
923- // TestExtensionDataPreservation tests that the ExtensionData field is properly preserved
964+ // testExtensionDataPreservation tests that the ExtensionData field is properly preserved
924965// when transactions are submitted and retrieved through the Access API.
925- func (s * AccessAPISuite ) TestExtensionDataPreservation () {
966+ func (s * AccessAPISuite ) testExtensionDataPreservation () {
926967 accessNodeContainer := s .net .ContainerByName (testnet .PrimaryAN )
927968
928969 // Establish a gRPC connection to the access API
@@ -1063,9 +1104,9 @@ func (s *AccessAPISuite) TestExtensionDataPreservation() {
10631104 }
10641105}
10651106
1066- // TestInvalidTransactionSignature tests that the access API performs sanity checks
1107+ // testRejectedInvalidSignatureFormat tests that the access API performs sanity checks
10671108// on the transaction signature format and rejects invalid formats
1068- func (s * AccessAPISuite ) TestRejectedInvalidSignatureFormat () {
1109+ func (s * AccessAPISuite ) testRejectedInvalidSignatureFormat () {
10691110 accessNodeContainer := s .net .ContainerByName (testnet .PrimaryAN )
10701111
10711112 // Establish a gRPC connection to the access API
0 commit comments