github.com/algorand/go-algorand-sdk@v1.24.0/test/indexer_unit_test.go (about) 1 package test 2 3 import ( 4 "context" 5 "encoding/base64" 6 "fmt" 7 "strings" 8 9 "github.com/algorand/go-algorand-sdk/client/v2/indexer" 10 "github.com/cucumber/godog" 11 ) 12 13 func IndexerUnitTestContext(s *godog.Suite) { 14 s.Step(`^we make any LookupAssetBalances call$`, weMakeAnyLookupAssetBalancesCall) 15 s.Step(`^the parsed LookupAssetBalances response should be valid on round (\d+), and contain an array of len (\d+) and element number (\d+) should have address "([^"]*)" amount (\d+) and frozen state "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 16 s.Step(`^we make any LookupAssetTransactions call$`, weMakeAnyLookupAssetTransactionsCall) 17 s.Step(`^the parsed LookupAssetTransactions response should be valid on round (\d+), and contain an array of len (\d+) and element number (\d+) should have sender "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 18 s.Step(`^we make any LookupAccountTransactions call$`, weMakeAnyLookupAccountTransactionsCall) 19 s.Step(`^the parsed LookupAccountTransactions response should be valid on round (\d+), and contain an array of len (\d+) and element number (\d+) should have sender "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 20 s.Step(`^we make any LookupBlock call$`, weMakeAnyLookupBlockCall) 21 s.Step(`^the parsed LookupBlock response should have previous block hash "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 22 s.Step(`^we make any LookupAccountByID call$`, weMakeAnyLookupAccountByIDCall) 23 s.Step(`^the parsed LookupAccountByID response should have address "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 24 s.Step(`^we make any LookupAssetByID call$`, weMakeAnyLookupAssetByIDCall) 25 s.Step(`^the parsed LookupAssetByID response should have index (\d+)$`, theParsedResponseShouldEqualTheMockResponse) 26 s.Step(`^we make any SearchAccounts call$`, weMakeAnySearchAccountsCall) 27 s.Step(`^the parsed SearchAccounts response should be valid on round (\d+) and the array should be of len (\d+) and the element at index (\d+) should have address "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 28 s.Step(`^we make any SearchForTransactions call$`, weMakeAnySearchForTransactionsCall) 29 s.Step(`^the parsed SearchForTransactions response should be valid on round (\d+) and the array should be of len (\d+) and the element at index (\d+) should have sender "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 30 s.Step(`^we make any SearchForAssets call$`, weMakeAnySearchForAssetsCall) 31 s.Step(`^the parsed SearchForAssets response should be valid on round (\d+) and the array should be of len (\d+) and the element at index (\d+) should have asset index (\d+)$`, theParsedResponseShouldEqualTheMockResponse) 32 s.Step(`^we make a Lookup Asset Balances call against asset index (\d+) with limit (\d+) afterAddress "([^"]*)" currencyGreaterThan (\d+) currencyLessThan (\d+)$`, weMakeALookupAssetBalancesCallAgainstAssetIndexWithLimitLimitAfterAddressCurrencyGreaterThanCurrencyLessThan) 33 s.Step(`^we make a Lookup Asset Transactions call against asset index (\d+) with NotePrefix "([^"]*)" TxType "([^"]*)" SigType "([^"]*)" txid "([^"]*)" round (\d+) minRound (\d+) maxRound (\d+) limit (\d+) beforeTime "([^"]*)" afterTime "([^"]*)" currencyGreaterThan (\d+) currencyLessThan (\d+) address "([^"]*)" addressRole "([^"]*)" ExcluseCloseTo "([^"]*)"$`, deprecatedWeMakeALookupAssetTransactionsCallAgainstAssetIndexWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAddressAddressRoleExcluseCloseTo) 34 s.Step(`^we make a Search Accounts call with assetID (\d+) limit (\d+) currencyGreaterThan (\d+) currencyLessThan (\d+) and round (\d+)$`, weMakeASearchAccountsCallWithAssetIDLimitCurrencyGreaterThanCurrencyLessThanAndRound) 35 s.Step(`^we make a Lookup Account Transactions call against account "([^"]*)" with NotePrefix "([^"]*)" TxType "([^"]*)" SigType "([^"]*)" txid "([^"]*)" round (\d+) minRound (\d+) maxRound (\d+) limit (\d+) beforeTime "([^"]*)" afterTime "([^"]*)" currencyGreaterThan (\d+) currencyLessThan (\d+) assetIndex (\d+)$`, weMakeALookupAccountTransactionsCallAgainstAccountWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAssetIndex) 36 s.Step(`^we make a Lookup Block call against round (\d+)$`, weMakeALookupBlockCallAgainstRound) 37 s.Step(`^we make a Lookup Account by ID call against account "([^"]*)" with round (\d+)$`, weMakeALookupAccountByIDCallAgainstAccountWithRound) 38 s.Step(`^we make a Lookup Asset by ID call against asset index (\d+)$`, weMakeALookupAssetByIDCallAgainstAssetIndex) 39 s.Step(`^mock server recording request paths`, mockServerRecordingRequestPaths) 40 s.Step(`^we make a Search For Transactions call with account "([^"]*)" NotePrefix "([^"]*)" TxType "([^"]*)" SigType "([^"]*)" txid "([^"]*)" round (\d+) minRound (\d+) maxRound (\d+) limit (\d+) beforeTime "([^"]*)" afterTime "([^"]*)" currencyGreaterThan (\d+) currencyLessThan (\d+) assetIndex (\d+) addressRole "([^"]*)" ExcluseCloseTo "([^"]*)"$`, weMakeASearchForTransactionsCallWithAccountNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAssetIndexAddressRoleExcluseCloseTo) 41 s.Step(`^we make a SearchForAssets call with limit (\d+) creator "([^"]*)" name "([^"]*)" unit "([^"]*)" index (\d+)$`, weMakeASearchForAssetsCallWithLimitCreatorNameUnitIndex) 42 s.Step(`^we make a Lookup Account Transactions call against account "([^"]*)" with NotePrefix "([^"]*)" TxType "([^"]*)" SigType "([^"]*)" txid "([^"]*)" round (\d+) minRound (\d+) maxRound (\d+) limit (\d+) beforeTime "([^"]*)" afterTime "([^"]*)" currencyGreaterThan (\d+) currencyLessThan (\d+) assetIndex (\d+) rekeyTo "([^"]*)"$`, weMakeALookupAccountTransactionsCallAgainstAccountWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAssetIndexRekeyTo) 43 s.Step(`^we make a Search Accounts call with assetID (\d+) limit (\d+) currencyGreaterThan (\d+) currencyLessThan (\d+) round (\d+) and authenticating address "([^"]*)"$`, weMakeASearchAccountsCallWithAssetIDLimitCurrencyGreaterThanCurrencyLessThanRoundAndAuthenticatingAddress) 44 s.Step(`^we make a Search For Transactions call with account "([^"]*)" NotePrefix "([^"]*)" TxType "([^"]*)" SigType "([^"]*)" txid "([^"]*)" round (\d+) minRound (\d+) maxRound (\d+) limit (\d+) beforeTime "([^"]*)" afterTime "([^"]*)" currencyGreaterThan (\d+) currencyLessThan (\d+) assetIndex (\d+) addressRole "([^"]*)" ExcluseCloseTo "([^"]*)" rekeyTo "([^"]*)"$`, weMakeASearchForTransactionsCallWithAccountNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAssetIndexAddressRoleExcluseCloseToRekeyTo) 45 s.Step(`^the parsed SearchAccounts response should be valid on round (\d+) and the array should be of len (\d+) and the element at index (\d+) should have authorizing address "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 46 s.Step(`^the parsed SearchForTransactions response should be valid on round (\d+) and the array should be of len (\d+) and the element at index (\d+) should have rekey-to "([^"]*)"$`, theParsedResponseShouldEqualTheMockResponse) 47 s.Step(`^we make a Lookup Asset Transactions call against asset index (\d+) with NotePrefix "([^"]*)" TxType "([^"]*)" SigType "([^"]*)" txid "([^"]*)" round (\d+) minRound (\d+) maxRound (\d+) limit (\d+) beforeTime "([^"]*)" afterTime "([^"]*)" currencyGreaterThan (\d+) currencyLessThan (\d+) address "([^"]*)" addressRole "([^"]*)" ExcluseCloseTo "([^"]*)" RekeyTo "([^"]*)"$`, weMakeALookupAssetTransactionsCallAgainstAssetIndexWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAddressAddressRoleExcluseCloseToRekeyTo) 48 s.Step(`^we make a LookupApplicationLogsByID call with applicationID (\d+) limit (\d+) minRound (\d+) maxRound (\d+) nextToken "([^"]*)" sender "([^"]*)" and txID "([^"]*)"$`, weMakeALookupApplicationLogsByIDCallWithApplicationIDLimitMinRoundMaxRoundNextTokenSenderAndTxID) 49 s.Step(`^we make a LookupAccountAssets call with accountID "([^"]*)" assetID (\d+) includeAll "([^"]*)" limit (\d+) next "([^"]*)"$`, weMakeALookupAccountAssetsCallWithAccountIDAssetIDIncludeAllLimitNext) 50 s.Step(`^we make a LookupAccountCreatedAssets call with accountID "([^"]*)" assetID (\d+) includeAll "([^"]*)" limit (\d+) next "([^"]*)"$`, weMakeALookupAccountCreatedAssetsCallWithAccountIDAssetIDIncludeAllLimitNext) 51 s.Step(`^we make a LookupAccountAppLocalStates call with accountID "([^"]*)" applicationID (\d+) includeAll "([^"]*)" limit (\d+) next "([^"]*)"$`, weMakeALookupAccountAppLocalStatesCallWithAccountIDApplicationIDIncludeAllLimitNext) 52 s.Step(`^we make a LookupAccountCreatedApplications call with accountID "([^"]*)" applicationID (\d+) includeAll "([^"]*)" limit (\d+) next "([^"]*)"$`, weMakeALookupAccountCreatedApplicationsCallWithAccountIDApplicationIDIncludeAllLimitNext) 53 s.Step(`^we make a Search Accounts call with exclude "([^"]*)"$`, weMakeASearchAccountsCallWithExclude) 54 s.Step(`^we make a Lookup Account by ID call against account "([^"]*)" with exclude "([^"]*)"$`, weMakeALookupAccountByIDCallAgainstAccountWithExclude) 55 s.Step(`^we make a SearchForApplications call with creator "([^"]*)"$`, weMakeASearchForApplicationsCallWithCreator) 56 s.Step(`^we make a Lookup Block call against round (\d+) and header "([^"]*)"$`, weMakeALookupBlockCallAgainstRoundAndHeader) 57 s.Step(`^we make a LookupApplicationBoxByIDandName call with applicationID (\d+) with encoded box name "([^"]*)"$`, weMakeALookupApplicationBoxByIDandName) 58 s.Step(`^we make a SearchForApplicationBoxes call with applicationID (\d+) with max (\d+) nextToken "([^"]*)"$`, weMakeASearchForApplicationBoxes) 59 s.BeforeScenario(func(interface{}) { 60 globalErrForExamination = nil 61 }) 62 } 63 64 func weMakeAnyLookupAssetBalancesCall() error { 65 return weMakeAnyCallTo("indexer", "lookupAssetBalances") 66 } 67 68 func weMakeAnyLookupAssetTransactionsCall() error { 69 return weMakeAnyCallTo("indexer", "lookupAssetTransactions") 70 } 71 72 func weMakeAnyLookupAccountTransactionsCall() error { 73 return weMakeAnyCallTo("indexer", "lookupAccountTransactions") 74 } 75 76 func weMakeAnyLookupBlockCall() error { 77 return weMakeAnyCallTo("indexer", "lookupBlock") 78 } 79 80 func weMakeAnyLookupAccountByIDCall() error { 81 return weMakeAnyCallTo("indexer", "lookupAccountByID") 82 } 83 84 func weMakeAnyLookupAssetByIDCall() error { 85 return weMakeAnyCallTo("indexer", "lookupAssetByID") 86 } 87 88 func weMakeAnySearchAccountsCall() error { 89 return weMakeAnyCallTo("indexer", "searchForAccounts") 90 } 91 92 func weMakeAnySearchForTransactionsCall() error { 93 return weMakeAnyCallTo("indexer", "searchForTransactions") 94 } 95 96 func weMakeAnySearchForAssetsCall() error { 97 return weMakeAnyCallTo("indexer", "searchForAssets") 98 } 99 100 func weMakeALookupAssetBalancesCallAgainstAssetIndexWithLimitLimitAfterAddressCurrencyGreaterThanCurrencyLessThan(index, limit int, _ string, currencyGreater, currencyLesser int) error { 101 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 102 if err != nil { 103 return err 104 } 105 _, globalErrForExamination = indexerClient.LookupAssetBalances(uint64(index)).Limit(uint64(limit)).CurrencyGreaterThan(uint64(currencyGreater)).CurrencyLessThan(uint64(currencyLesser)).Do(context.Background()) 106 return nil 107 } 108 109 func deprecatedWeMakeALookupAssetTransactionsCallAgainstAssetIndexWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAddressAddressRoleExcluseCloseTo(assetIndex int, notePrefix, txType, sigType, txid string, round, minRound, maxRound, limit int, beforeTime, afterTime string, currencyGreater, currencyLesser int, address, addressRole, excludeCloseTo string) error { 110 return weMakeALookupAssetTransactionsCallAgainstAssetIndexWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAddressAddressRoleExcluseCloseToRekeyTo(assetIndex, notePrefix, txType, sigType, txid, round, minRound, maxRound, limit, beforeTime, afterTime, currencyGreater, currencyLesser, address, addressRole, excludeCloseTo, "") 111 } 112 113 func weMakeALookupAssetTransactionsCallAgainstAssetIndexWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAddressAddressRoleExcluseCloseToRekeyTo(assetIndex int, notePrefix, txType, sigType, txid string, round, minRound, maxRound, limit int, beforeTime, afterTime string, currencyGreater, currencyLesser int, address, addressRole, excludeCloseTo, rekeyTo string) error { 114 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 115 if err != nil { 116 return err 117 } 118 excludeCloseToBool := excludeCloseTo == "true" 119 notePrefixBytes, err := base64.StdEncoding.DecodeString(notePrefix) 120 if err != nil { 121 return err 122 } 123 rekeyToBool := rekeyTo == "true" 124 _, globalErrForExamination = indexerClient.LookupAssetTransactions(uint64(assetIndex)). 125 NotePrefix(notePrefixBytes). 126 TxType(txType). 127 SigType(sigType). 128 TXID(txid). 129 Round(uint64(round)). 130 MinRound(uint64(minRound)). 131 MaxRound(uint64(maxRound)). 132 Limit(uint64(limit)). 133 BeforeTimeString(beforeTime). 134 AfterTimeString(afterTime). 135 CurrencyGreaterThan(uint64(currencyGreater)). 136 CurrencyLessThan(uint64(currencyLesser)). 137 AddressString(address). 138 AddressRole(addressRole). 139 ExcludeCloseTo(excludeCloseToBool). 140 RekeyTo(rekeyToBool). 141 Do(context.Background()) 142 return nil 143 } 144 145 func weMakeALookupAccountTransactionsCallAgainstAccountWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAssetIndex(account, notePrefix, txType, sigType, txid string, round, minRound, maxRound, limit int, beforeTime, afterTime string, currencyGreater, currencyLesser, assetIndex int) error { 146 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 147 if err != nil { 148 return err 149 } 150 notePrefixBytes, err := base64.StdEncoding.DecodeString(notePrefix) 151 if err != nil { 152 return err 153 } 154 _, globalErrForExamination = indexerClient.LookupAccountTransactions(account).NotePrefix(notePrefixBytes).TxType(txType).SigType(sigType).TXID(txid).Round(uint64(round)).MinRound(uint64(minRound)).MaxRound(uint64(maxRound)).Limit(uint64(limit)).BeforeTimeString(beforeTime).AfterTimeString(afterTime).CurrencyGreaterThan(uint64(currencyGreater)).CurrencyLessThan(uint64(currencyLesser)).AssetID(uint64(assetIndex)).Do(context.Background()) 155 return nil 156 } 157 158 func weMakeALookupAccountTransactionsCallAgainstAccountWithNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAssetIndexRekeyTo(account, notePrefix, txType, sigType, txid string, round, minRound, maxRound, limit int, beforeTime, afterTime string, currencyGreater, currencyLesser, assetIndex int, rekeyTo string) error { 159 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 160 if err != nil { 161 return err 162 } 163 notePrefixBytes, err := base64.StdEncoding.DecodeString(notePrefix) 164 if err != nil { 165 return err 166 } 167 rekeyToBool := rekeyTo == "true" 168 _, globalErrForExamination = indexerClient.LookupAccountTransactions(account).NotePrefix(notePrefixBytes).TxType(txType).SigType(sigType).TXID(txid).Round(uint64(round)).MinRound(uint64(minRound)).MaxRound(uint64(maxRound)).Limit(uint64(limit)).BeforeTimeString(beforeTime).AfterTimeString(afterTime).CurrencyGreaterThan(uint64(currencyGreater)).CurrencyLessThan(uint64(currencyLesser)).AssetID(uint64(assetIndex)).RekeyTo(rekeyToBool).Do(context.Background()) 169 return nil 170 } 171 172 func weMakeALookupBlockCallAgainstRound(round int) error { 173 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 174 if err != nil { 175 return err 176 } 177 _, globalErrForExamination = indexerClient.LookupBlock(uint64(round)).Do(context.Background()) 178 return nil 179 } 180 181 func weMakeALookupAccountByIDCallAgainstAccountWithRound(account string, round int) error { 182 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 183 if err != nil { 184 return err 185 } 186 _, _, globalErrForExamination = indexerClient.LookupAccountByID(account).Round(uint64(round)).Do(context.Background()) 187 return nil 188 } 189 190 func weMakeALookupAssetByIDCallAgainstAssetIndex(assetIndex int) error { 191 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 192 if err != nil { 193 return err 194 } 195 _, _, globalErrForExamination = indexerClient.LookupAssetByID(uint64(assetIndex)).Do(context.Background()) 196 return nil 197 } 198 199 func weMakeASearchAccountsCallWithAssetIDLimitCurrencyGreaterThanCurrencyLessThanRoundAndAuthenticatingAddress(assetIndex, limit, currencyGreater, currencyLesser, round int, authAddress string) error { 200 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 201 if err != nil { 202 return err 203 } 204 _, globalErrForExamination = indexerClient.SearchAccounts(). 205 AssetID(uint64(assetIndex)). 206 Limit(uint64(limit)). 207 CurrencyLessThan(uint64(currencyLesser)). 208 CurrencyGreaterThan(uint64(currencyGreater)). 209 Round(uint64(round)). 210 AuthAddress(authAddress). 211 Do(context.Background()) 212 return nil 213 } 214 215 func weMakeASearchForTransactionsCallWithAccountNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAssetIndexAddressRoleExcluseCloseTo(account, notePrefix, txType, sigType, txid string, round, minRound, maxRound, limit int, beforeTime, afterTime string, currencyGreater, currencyLesser, assetIndex int, addressRole, excludeCloseTo string) error { 216 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 217 if err != nil { 218 return err 219 } 220 excludeCloseToBool := excludeCloseTo == "true" 221 notePrefixBytes, err := base64.StdEncoding.DecodeString(notePrefix) 222 if err != nil { 223 return err 224 } 225 _, globalErrForExamination = indexerClient.SearchForTransactions().AddressString(account).NotePrefix(notePrefixBytes).TxType(txType).SigType(sigType).TXID(txid).Round(uint64(round)).MinRound(uint64(minRound)).MaxRound(uint64(maxRound)).Limit(uint64(limit)).BeforeTimeString(beforeTime).AfterTimeString(afterTime).CurrencyGreaterThan(uint64(currencyGreater)).CurrencyLessThan(uint64(currencyLesser)).AssetID(uint64(assetIndex)).AddressRole(addressRole).ExcludeCloseTo(excludeCloseToBool).Do(context.Background()) 226 return nil 227 } 228 229 func weMakeASearchForTransactionsCallWithAccountNotePrefixTxTypeSigTypeTxidRoundMinRoundMaxRoundLimitBeforeTimeAfterTimeCurrencyGreaterThanCurrencyLessThanAssetIndexAddressRoleExcluseCloseToRekeyTo(account, notePrefix, txType, sigType, txid string, round, minRound, maxRound, limit int, beforeTime, afterTime string, currencyGreater, currencyLesser, assetIndex int, addressRole, excludeCloseTo, rekeyTo string) error { 230 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 231 if err != nil { 232 return err 233 } 234 excludeCloseToBool := excludeCloseTo == "true" 235 notePrefixBytes, err := base64.StdEncoding.DecodeString(notePrefix) 236 if err != nil { 237 return err 238 } 239 rekeyToBool := rekeyTo == "true" 240 _, globalErrForExamination = indexerClient.SearchForTransactions().AddressString(account).NotePrefix(notePrefixBytes).TxType(txType).SigType(sigType).TXID(txid).Round(uint64(round)).MinRound(uint64(minRound)).MaxRound(uint64(maxRound)).Limit(uint64(limit)).BeforeTimeString(beforeTime).AfterTimeString(afterTime).CurrencyGreaterThan(uint64(currencyGreater)).CurrencyLessThan(uint64(currencyLesser)).AssetID(uint64(assetIndex)).AddressRole(addressRole).ExcludeCloseTo(excludeCloseToBool).RekeyTo(rekeyToBool).Do(context.Background()) 241 return nil 242 } 243 244 func weMakeASearchAccountsCallWithAssetIDLimitCurrencyGreaterThanCurrencyLessThanAndRound(assetID, limit, currencyGreater, currencyLesser, round int) error { 245 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 246 if err != nil { 247 return err 248 } 249 _, globalErrForExamination = indexerClient.SearchAccounts().AssetID(uint64(assetID)).Limit(uint64(limit)).CurrencyLessThan(uint64(currencyLesser)).CurrencyGreaterThan(uint64(currencyGreater)).Round(uint64(round)).Do(context.Background()) 250 return nil 251 } 252 253 func weMakeASearchForAssetsCallWithLimitCreatorNameUnitIndex(limit int, creator, name, unit string, index int) error { 254 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 255 if err != nil { 256 return err 257 } 258 _, globalErrForExamination = indexerClient.SearchForAssets().AssetID(uint64(index)).Limit(uint64(limit)).Creator(creator).Name(name).Unit(unit).Do(context.Background()) 259 return nil 260 } 261 262 func weMakeALookupApplicationLogsByIDCallWithApplicationIDLimitMinRoundMaxRoundNextTokenSenderAndTxID(appID, limit, minRound, maxRound int, nextToken, sender, txID string) error { 263 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 264 if err != nil { 265 return err 266 } 267 indexerClient.LookupApplicationLogsByID(uint64(appID)).Limit(uint64(limit)).MinRound(uint64(minRound)).MaxRound(uint64(maxRound)).Next(nextToken).SenderAddress(sender).Txid(txID).Do(context.Background()) 268 return nil 269 } 270 271 func parseBool(s string) (bool, error) { 272 if s == "true" { 273 return true, nil 274 } 275 if s == "false" { 276 return false, nil 277 } 278 return false, fmt.Errorf("parseBool() cannot parse \"%s\"", s) 279 } 280 281 func weMakeALookupAccountAssetsCallWithAccountIDAssetIDIncludeAllLimitNext(accountID string, assetID int, includeAll string, limit int, next string) error { 282 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 283 if err != nil { 284 return err 285 } 286 includeAllBool, err := parseBool(includeAll) 287 if err != nil { 288 return err 289 } 290 indexerClient.LookupAccountAssets(accountID).AssetID(uint64(assetID)).IncludeAll(includeAllBool).Limit(uint64(limit)).Next(next).Do(context.Background()) 291 return nil 292 } 293 294 func weMakeALookupAccountCreatedAssetsCallWithAccountIDAssetIDIncludeAllLimitNext(accountID string, assetID int, includeAll string, limit int, next string) error { 295 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 296 if err != nil { 297 return err 298 } 299 includeAllBool, err := parseBool(includeAll) 300 if err != nil { 301 return err 302 } 303 indexerClient.LookupAccountCreatedAssets(accountID).AssetID(uint64(assetID)).IncludeAll(includeAllBool).Limit(uint64(limit)).Next(next).Do(context.Background()) 304 return nil 305 } 306 307 func weMakeALookupAccountAppLocalStatesCallWithAccountIDApplicationIDIncludeAllLimitNext(accountID string, appID int, includeAll string, limit int, next string) error { 308 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 309 if err != nil { 310 return err 311 } 312 includeAllBool, err := parseBool(includeAll) 313 if err != nil { 314 return err 315 } 316 indexerClient.LookupAccountAppLocalStates(accountID).ApplicationID(uint64(appID)).IncludeAll(includeAllBool).Limit(uint64(limit)).Next(next).Do(context.Background()) 317 return nil 318 } 319 320 func weMakeALookupAccountCreatedApplicationsCallWithAccountIDApplicationIDIncludeAllLimitNext(accountID string, appID int, includeAll string, limit int, next string) error { 321 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 322 if err != nil { 323 return err 324 } 325 includeAllBool, err := parseBool(includeAll) 326 if err != nil { 327 return err 328 } 329 indexerClient.LookupAccountCreatedApplications(accountID).ApplicationID(uint64(appID)).IncludeAll(includeAllBool).Limit(uint64(limit)).Next(next).Do(context.Background()) 330 return nil 331 } 332 333 func weMakeASearchAccountsCallWithExclude(exclude string) error { 334 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 335 if err != nil { 336 return err 337 } 338 indexerClient.SearchAccounts().Exclude(strings.Split(exclude, ",")).Do(context.Background()) 339 return nil 340 } 341 342 func weMakeALookupAccountByIDCallAgainstAccountWithExclude(account, exclude string) error { 343 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 344 if err != nil { 345 return err 346 } 347 indexerClient.LookupAccountByID(account).Exclude(strings.Split(exclude, ",")).Do(context.Background()) 348 return nil 349 } 350 351 func weMakeASearchForApplicationsCallWithCreator(creator string) error { 352 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 353 if err != nil { 354 return err 355 } 356 indexerClient.SearchForApplications().Creator(creator).Do(context.Background()) 357 return nil 358 } 359 360 func weMakeALookupBlockCallAgainstRoundAndHeader(round int, headerOnly string) error { 361 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 362 if err != nil { 363 return err 364 } 365 366 headerOnlyBool, err := parseBool(headerOnly) 367 if err != nil { 368 return weMakeALookupBlockCallAgainstRound(round) 369 } 370 371 _, globalErrForExamination = indexerClient.LookupBlock(uint64(round)).HeaderOnly(headerOnlyBool).Do(context.Background()) 372 return nil 373 } 374 375 func weMakeALookupApplicationBoxByIDandName(appId int, encodedBoxName string) error { 376 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 377 if err != nil { 378 return err 379 } 380 decodedBoxNames, err := parseAppArgs(encodedBoxName) 381 if err != nil { 382 return err 383 } 384 indexerClient.LookupApplicationBoxByIDAndName(uint64(appId), decodedBoxNames[0]).Do(context.Background()) 385 return nil 386 } 387 388 func weMakeASearchForApplicationBoxes(appId int, limit int, next string) error { 389 indexerClient, err := indexer.MakeClient(mockServer.URL, "") 390 if err != nil { 391 return err 392 } 393 indexerClient.SearchForApplicationBoxes(uint64(appId)).Limit(uint64(limit)).Next(next).Do(context.Background()) 394 return nil 395 }