Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitea512d1

Browse files
committed
[1.1.0-SNAPSHOT]
FailFast true added[1.1.0-SNAPSHOT]Only java 11 for testing is left[1.1.0-SNAPSHOT]Tests on push disabled for RateLimit not exceed[1.1.0-SNAPSHOT]CI api key env setted[1.1.0-SNAPSHOT]QueueManager 7 sec instead of 6 set[1.1.0-SNAPSHOT]Test fixed with correct address for ABIDebug logging removedPersonalQueue optimized[1.1.0-SNAPSHOT]Key removed[1.1.0-SNAPSHOT]Weak queue set for tests[1.1.0-SNAPSHOT]Rest before timeout check for api not exceed rate
1 parentaf94534 commitea512d1

File tree

7 files changed

+32
-34
lines changed

7 files changed

+32
-34
lines changed

‎.github/workflows/gradle.yml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
name:Java CI
22

33
on:
4-
push:
5-
branches:
6-
-master
7-
-dev
84
schedule:
95
-cron:"0 12 1 * *"
106
pull_request:
@@ -17,7 +13,7 @@ jobs:
1713
runs-on:ubuntu-latest
1814
strategy:
1915
matrix:
20-
java:[ '1.8', '11' ]
16+
java:[ '11' ]
2117
name:Java ${{ matrix.java }} setup
2218

2319
steps:
@@ -30,9 +26,12 @@ jobs:
3026

3127
-name:Build with Gradle
3228
run:./gradlew build jacocoTestReport
29+
env:
30+
API_KEY:${{ secrets.API_KEY }}
3331

3432
-name:Analyze with SonarQube
3533
run:./gradlew sonarqube
3634
env:
3735
GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }}
3836
SONAR_TOKEN:${{ secrets.SONAR_TOKEN }}
37+
API_KEY:${{ secrets.API_KEY }}

‎build.gradle‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ dependencies {
4343
}
4444

4545
test {
46+
failFast=true
47+
4648
useJUnit()
4749
testLogging {
4850
events"passed","skipped","failed"

‎src/main/java/io/api/etherscan/core/impl/BasicProvider.java‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@
77
importio.api.etherscan.error.RateLimitException;
88
importio.api.etherscan.executor.IHttpExecutor;
99
importio.api.etherscan.manager.IQueueManager;
10-
importio.api.etherscan.manager.impl.QueueManager;
1110
importio.api.etherscan.model.utility.StringResponseTO;
1211
importio.api.etherscan.util.BasicUtils;
1312

14-
importjava.time.LocalTime;
1513
importjava.util.Map;
16-
importjava.util.logging.Level;
17-
importjava.util.logging.Logger;
1814

1915
/**
2016
* Base provider for API Implementations
@@ -25,8 +21,6 @@
2521
*/
2622
abstractclassBasicProvider {
2723

28-
privatestaticfinalLoggerlogger =Logger.getLogger(QueueManager.class.getName());
29-
3024
staticfinalintMAX_END_BLOCK =Integer.MAX_VALUE;
3125
staticfinalintMIN_START_BLOCK =0;
3226

@@ -76,9 +70,7 @@ <T> T convert(final String json, final Class<T> tClass) {
7670
}
7771

7872
StringgetRequest(finalStringurlParameters) {
79-
logger.log(Level.SEVERE,"ASKED - " +LocalTime.now());
8073
queue.takeTurn();
81-
logger.log(Level.SEVERE,"GRANTED - " +LocalTime.now());
8274
finalStringurl =baseUrl +module +urlParameters;
8375
finalStringresult =executor.get(url);
8476
if (BasicUtils.isEmpty(result))
@@ -88,9 +80,7 @@ String getRequest(final String urlParameters) {
8880
}
8981

9082
StringpostRequest(finalStringurlParameters,finalStringdataToPost) {
91-
logger.log(Level.SEVERE,"ASKED - " +LocalTime.now());
9283
queue.takeTurn();
93-
logger.log(Level.SEVERE,"GRANTED - " +LocalTime.now());
9484
finalStringurl =baseUrl +module +urlParameters;
9585
returnexecutor.post(url,dataToPost);
9686
}

‎src/main/java/io/api/etherscan/manager/impl/QueueManager.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
importjava.util.concurrent.*;
66

77
/**
8-
* Queue implementationWith size and reset time as params
8+
* QueueSemaphoreimplementationwith size and reset time as params
99
*
1010
* @see IQueueManager
1111
*
@@ -14,19 +14,19 @@
1414
*/
1515
publicclassQueueManagerimplementsIQueueManager {
1616

17-
publicstaticfinalQueueManagerDEFAULT_KEY_QUEUE =newQueueManager(1,6);
18-
publicstaticfinalQueueManagerPERSONAL_KEY_QUEUE =newQueueManager(5,1);
17+
publicstaticfinalQueueManagerDEFAULT_KEY_QUEUE =newQueueManager(1,7);
18+
publicstaticfinalQueueManagerPERSONAL_KEY_QUEUE =newQueueManager(2,1);
1919

2020
privatefinalSemaphoresemaphore;
2121

22-
publicQueueManager(intqueueSize,intqueueResetTimeInSec) {
23-
this(queueSize,queueResetTimeInSec,queueResetTimeInSec);
22+
publicQueueManager(intsize,intresetInSec) {
23+
this(size,resetInSec,resetInSec);
2424
}
2525

26-
publicQueueManager(intqueueSize,intqueueResetTimeInSec,intdelayInSec) {
27-
this.semaphore =newSemaphore(queueSize);
26+
publicQueueManager(intsize,intqueueResetTimeInSec,intdelayInSec) {
27+
this.semaphore =newSemaphore(size);
2828
Executors.newSingleThreadScheduledExecutor()
29-
.scheduleAtFixedRate(releaseLocks(queueSize),delayInSec,queueResetTimeInSec,TimeUnit.SECONDS);
29+
.scheduleAtFixedRate(releaseLocks(size),delayInSec,queueResetTimeInSec,TimeUnit.SECONDS);
3030
}
3131

3232
@Override

‎src/test/java/io/api/ApiRunner.java‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,26 @@ public class ApiRunner extends Assert {
1111
privatestaticfinalEtherScanApiapiRopsten;
1212
privatestaticfinalEtherScanApiapiRinkeby;
1313
privatestaticfinalEtherScanApiapiKovan;
14+
privatestaticfinalStringkey;
1415

1516
static {
1617
finalStringapiKey =System.getenv("API_KEY");
17-
finalStringkeyOrDefault = (apiKey ==null ||apiKey.isEmpty())
18+
key = (apiKey ==null ||apiKey.isEmpty())
1819
?EtherScanApi.DEFAULT_KEY
1920
:apiKey;
2021

21-
finalQueueManagerqueue =keyOrDefault.equals(EtherScanApi.DEFAULT_KEY)
22+
finalQueueManagerqueue =key.equals(EtherScanApi.DEFAULT_KEY)
2223
?QueueManager.DEFAULT_KEY_QUEUE
23-
:QueueManager.PERSONAL_KEY_QUEUE;
24+
:newQueueManager(1,2);
2425

25-
api =newEtherScanApi(keyOrDefault,EthNetwork.MAINNET,queue);
26-
apiRopsten =newEtherScanApi(keyOrDefault,EthNetwork.ROPSTEN,queue);
27-
apiRinkeby =newEtherScanApi(keyOrDefault,EthNetwork.RINKEBY,queue);
28-
apiKovan =newEtherScanApi(keyOrDefault,EthNetwork.KOVAN,queue);
26+
api =newEtherScanApi(key,EthNetwork.MAINNET,queue);
27+
apiRopsten =newEtherScanApi(key,EthNetwork.ROPSTEN,queue);
28+
apiRinkeby =newEtherScanApi(key,EthNetwork.RINKEBY,queue);
29+
apiKovan =newEtherScanApi(key,EthNetwork.KOVAN,queue);
30+
}
31+
32+
publicstaticStringgetKey() {
33+
returnkey;
2934
}
3035

3136
publicstaticEtherScanApigetApi() {

‎src/test/java/io/api/etherscan/EtherScanApiTest.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
importorg.junit.Test;
1414

1515
importjava.util.List;
16+
importjava.util.concurrent.TimeUnit;
1617
importjava.util.function.Supplier;
1718

1819
/**
@@ -75,9 +76,10 @@ public void noTimeoutUnlimitedAwait() {
7576
}
7677

7778
@Test(expected =ApiTimeoutException.class)
78-
publicvoidtimeout() {
79+
publicvoidtimeout()throwsInterruptedException {
80+
TimeUnit.SECONDS.sleep(5);
7981
Supplier<IHttpExecutor>supplier = () ->newHttpExecutor(300,300);
80-
EtherScanApiapi =newEtherScanApi(EthNetwork.KOVAN,supplier);
82+
EtherScanApiapi =newEtherScanApi(getKey(),EthNetwork.KOVAN,supplier);
8183
List<Block>blocks =api.account().minedBlocks("0x0010f94b296A852aAac52EA6c5Ac72e03afD032D");
8284
assertNotNull(blocks);
8385
}

‎src/test/java/io/api/etherscan/contract/ContractApiTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public void invalidParamWithError() {
3434

3535
@Test
3636
publicvoidcorrectParamWithEmptyExpectedResult() {
37-
Abiabi =getApi().contract().contractAbi("0xBB1bc244D798123fDe783fCc1C72d3Bb8C189413");
37+
Abiabi =getApi().contract().contractAbi("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413");
3838
assertNotNull(abi);
39-
assertFalse(abi.isVerified());
39+
assertTrue(abi.isVerified());
4040
}
4141
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp