@@ -21,6 +21,7 @@ func RunTests(t *testing.T, s account.Store, teardown func()) {
2121 testPutMultipleRecords ,
2222 testPutErrors ,
2323 testGetLatestByOwner ,
24+ testBatchedMethods ,
2425 testRemoteSendEdgeCases ,
2526 testRelationshipAccountEdgeCases ,
2627 testSwapAccountEdgeCases ,
@@ -317,6 +318,49 @@ func testGetLatestByOwner(t *testing.T, s account.Store) {
317318 })
318319}
319320
321+ func testBatchedMethods (t * testing.T , s account.Store ) {
322+ t .Run ("testBatchedMethods" , func (t * testing.T ) {
323+ ctx := context .Background ()
324+
325+ var records []* account.Record
326+ for i := 0 ; i < 100 ; i ++ {
327+ record := & account.Record {
328+ OwnerAccount : fmt .Sprintf ("owner%d" , i ),
329+ AuthorityAccount : fmt .Sprintf ("authority%d" , i ),
330+ TokenAccount : fmt .Sprintf ("token%d" , i ),
331+ MintAccount : fmt .Sprintf ("mint%d" , i ),
332+ AccountType : commonpb .AccountType_POOL ,
333+ Index : uint64 (i ),
334+ }
335+
336+ require .NoError (t , s .Put (ctx , record ))
337+
338+ records = append (records , record )
339+ }
340+
341+ actual , err := s .GetByTokenAddressBatch (ctx , "token0" , "token1" )
342+ require .NoError (t , err )
343+ require .Len (t , actual , 2 )
344+ assertEquivalentRecords (t , records [0 ], actual [records [0 ].TokenAccount ])
345+ assertEquivalentRecords (t , records [1 ], actual [records [1 ].TokenAccount ])
346+
347+ actual , err = s .GetByTokenAddressBatch (ctx , "token0" , "token1" , "token2" , "token3" , "token4" )
348+ require .NoError (t , err )
349+ require .Len (t , actual , 5 )
350+ assertEquivalentRecords (t , records [0 ], actual [records [0 ].TokenAccount ])
351+ assertEquivalentRecords (t , records [1 ], actual [records [1 ].TokenAccount ])
352+ assertEquivalentRecords (t , records [2 ], actual [records [2 ].TokenAccount ])
353+ assertEquivalentRecords (t , records [3 ], actual [records [3 ].TokenAccount ])
354+ assertEquivalentRecords (t , records [4 ], actual [records [4 ].TokenAccount ])
355+
356+ _ , err = s .GetByTokenAddressBatch (ctx , "not-found" )
357+ assert .Equal (t , account .ErrAccountInfoNotFound , err )
358+
359+ _ , err = s .GetByTokenAddressBatch (ctx , "token0" , "not-found" )
360+ assert .Equal (t , account .ErrAccountInfoNotFound , err )
361+ })
362+ }
363+
320364func testRemoteSendEdgeCases (t * testing.T , s account.Store ) {
321365 t .Run ("testRemoteSendEdgeCases" , func (t * testing.T ) {
322366 ctx := context .Background ()
0 commit comments