@@ -2197,6 +2197,141 @@ describe('Connection', function () {
2197
2197
expect ( nullResponse ) . to . be . null ;
2198
2198
} ) ;
2199
2199
2200
+ it ( 'get transactions' , async function ( ) {
2201
+ await mockRpcResponse ( {
2202
+ method : 'getSlot' ,
2203
+ params : [ ] ,
2204
+ value : 1 ,
2205
+ } ) ;
2206
+
2207
+ while ( ( await connection . getSlot ( ) ) <= 0 ) {
2208
+ continue ;
2209
+ }
2210
+
2211
+ await mockRpcResponse ( {
2212
+ method : 'getBlock' ,
2213
+ params : [ 1 ] ,
2214
+ value : {
2215
+ blockHeight : 0 ,
2216
+ blockTime : 1614281964 ,
2217
+ blockhash : '57zQNBZBEiHsCZFqsaY6h176ioXy5MsSLmcvHkEyaLGy' ,
2218
+ previousBlockhash : 'H5nJ91eGag3B5ZSRHZ7zG5ZwXJ6ywCt2hyR8xCsV7xMo' ,
2219
+ parentSlot : 0 ,
2220
+ transactions : [
2221
+ {
2222
+ meta : {
2223
+ fee : 10000 ,
2224
+ postBalances : [ 499260347380 , 15298080 , 1 , 1 , 1 ] ,
2225
+ preBalances : [ 499260357380 , 15298080 , 1 , 1 , 1 ] ,
2226
+ status : { Ok : null } ,
2227
+ err : null ,
2228
+ } ,
2229
+ transaction : {
2230
+ message : {
2231
+ accountKeys : [
2232
+ 'va12u4o9DipLEB2z4fuoHszroq1U9NcAB9aooFDPJSf' ,
2233
+ '57zQNBZBEiHsCZFqsaY6h176ioXy5MsSLmcvHkEyaLGy' ,
2234
+ 'SysvarS1otHashes111111111111111111111111111' ,
2235
+ 'SysvarC1ock11111111111111111111111111111111' ,
2236
+ 'Vote111111111111111111111111111111111111111' ,
2237
+ ] ,
2238
+ header : {
2239
+ numReadonlySignedAccounts : 0 ,
2240
+ numReadonlyUnsignedAccounts : 3 ,
2241
+ numRequiredSignatures : 2 ,
2242
+ } ,
2243
+ instructions : [
2244
+ {
2245
+ accounts : [ 1 , 2 , 3 ] ,
2246
+ data : '37u9WtQpcm6ULa3VtWDFAWoQc1hUvybPrA3dtx99tgHvvcE7pKRZjuGmn7VX2tC3JmYDYGG7' ,
2247
+ programIdIndex : 4 ,
2248
+ } ,
2249
+ ] ,
2250
+ recentBlockhash : 'GeyAFFRY3WGpmam2hbgrKw4rbU2RKzfVLm5QLSeZwTZE' ,
2251
+ } ,
2252
+ signatures : [
2253
+ 'w2Zeq8YkpyB463DttvfzARD7k9ZxGEwbsEw4boEK7jDp3pfoxZbTdLFSsEPhzXhpCcjGi2kHtHFobgX49MMhbWt' ,
2254
+ '4oCEqwGrMdBeMxpzuWiukCYqSfV4DsSKXSiVVCh1iJ6pS772X7y219JZP3mgqBz5PhsvprpKyhzChjYc3VSBQXzG' ,
2255
+ ] ,
2256
+ } ,
2257
+ } ,
2258
+ ] ,
2259
+ } ,
2260
+ } ) ;
2261
+
2262
+ // Find a block that has a transaction.
2263
+ await mockRpcResponse ( {
2264
+ method : 'getFirstAvailableBlock' ,
2265
+ params : [ ] ,
2266
+ value : 1 ,
2267
+ } ) ;
2268
+ let slot = await connection . getFirstAvailableBlock ( ) ;
2269
+
2270
+ let transaction : string | undefined ;
2271
+ while ( ! transaction ) {
2272
+ const block = await connection . getBlock ( slot ) ;
2273
+ if ( block && block . transactions . length > 0 ) {
2274
+ transaction = block . transactions [ 0 ] . transaction . signatures [ 0 ] ;
2275
+ continue ;
2276
+ }
2277
+ slot ++ ;
2278
+ }
2279
+
2280
+ await mockRpcBatchResponse ( {
2281
+ batch : [
2282
+ {
2283
+ methodName : 'getTransaction' ,
2284
+ args : [ transaction ] ,
2285
+ } ,
2286
+ ] ,
2287
+ result : [
2288
+ {
2289
+ slot,
2290
+ transaction : {
2291
+ message : {
2292
+ accountKeys : [
2293
+ 'va12u4o9DipLEB2z4fuoHszroq1U9NcAB9aooFDPJSf' ,
2294
+ '57zQNBZBEiHsCZFqsaY6h176ioXy5MsSLmcvHkEyaLGy' ,
2295
+ 'SysvarS1otHashes111111111111111111111111111' ,
2296
+ 'SysvarC1ock11111111111111111111111111111111' ,
2297
+ 'Vote111111111111111111111111111111111111111' ,
2298
+ ] ,
2299
+ header : {
2300
+ numReadonlySignedAccounts : 0 ,
2301
+ numReadonlyUnsignedAccounts : 3 ,
2302
+ numRequiredSignatures : 2 ,
2303
+ } ,
2304
+ instructions : [
2305
+ {
2306
+ accounts : [ 1 , 2 , 3 ] ,
2307
+ data : '37u9WtQpcm6ULa3VtWDFAWoQc1hUvybPrA3dtx99tgHvvcE7pKRZjuGmn7VX2tC3JmYDYGG7' ,
2308
+ programIdIndex : 4 ,
2309
+ } ,
2310
+ ] ,
2311
+ recentBlockhash : 'GeyAFFRY3WGpmam2hbgrKw4rbU2RKzfVLm5QLSeZwTZE' ,
2312
+ } ,
2313
+ signatures : [
2314
+ 'w2Zeq8YkpyB463DttvfzARD7k9ZxGEwbsEw4boEK7jDp3pfoxZbTdLFSsEPhzXhpCcjGi2kHtHFobgX49MMhbWt' ,
2315
+ '4oCEqwGrMdBeMxpzuWiukCYqSfV4DsSKXSiVVCh1iJ6pS772X7y219JZP3mgqBz5PhsvprpKyhzChjYc3VSBQXzG' ,
2316
+ ] ,
2317
+ } ,
2318
+ meta : {
2319
+ fee : 10000 ,
2320
+ postBalances : [ 499260347380 , 15298080 , 1 , 1 , 1 ] ,
2321
+ preBalances : [ 499260357380 , 15298080 , 1 , 1 , 1 ] ,
2322
+ status : { Ok : null } ,
2323
+ err : null ,
2324
+ } ,
2325
+ } ,
2326
+ ] ,
2327
+ } ) ;
2328
+ const [ firstResult ] = await connection . getTransactions ( [ transaction ] ) ;
2329
+ if ( firstResult == null ) {
2330
+ expect . fail ( 'Expected `getTransactions()` to return one result' ) ;
2331
+ }
2332
+ expect ( firstResult . transaction . message . isAccountSigner ( 0 ) ) . to . be . true ;
2333
+ } ) ;
2334
+
2200
2335
if ( mockServer ) {
2201
2336
it ( 'get parsed confirmed transaction coerces public keys of inner instructions' , async ( ) => {
2202
2337
const confirmedTransaction : TransactionSignature =
0 commit comments