Skip to content

Commit 1b5121e

Browse files
committed
Included a delay before each integration test for the blockchain to process de request
1 parent c35c418 commit 1b5121e

File tree

8 files changed

+46
-16
lines changed

8 files changed

+46
-16
lines changed

near-java-api-common/src/test/resources/log4j2-test.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
status = info
1+
status = error
22
dest = out
33
name = NearJavaApi
44

@@ -38,4 +38,4 @@ rootLogger.level = info
3838
rootLogger.appenderRef.stdout.ref = STDOUT
3939

4040
logger.tests.name = com.syntifi.near.api
41-
logger.tests.level = debug
41+
logger.tests.level = info

near-java-api-indexer/src/test/resources/log4j2-test.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
status = info
1+
status = error
22
dest = out
33
name = NearJavaApi
44

@@ -38,4 +38,4 @@ rootLogger.level = info
3838
rootLogger.appenderRef.stdout.ref = STDOUT
3939

4040
logger.tests.name = com.syntifi.near.api
41-
logger.tests.level = debug
41+
logger.tests.level = info

near-java-api-rpc/src/test/java/com/syntifi/near/api/rpc/service/AccountServiceTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.syntifi.near.api.common.model.key.PublicKey;
1212
import com.syntifi.near.api.rpc.model.transaction.Status;
1313
import com.syntifi.near.api.rpc.model.transaction.TransactionAwait;
14+
import org.junit.jupiter.api.BeforeEach;
1415
import org.junit.jupiter.api.Test;
1516
import org.slf4j.Logger;
1617
import org.slf4j.LoggerFactory;
@@ -28,6 +29,12 @@
2829
public class AccountServiceTest extends AbstractKeyTest {
2930
private static final Logger LOGGER = LoggerFactory.getLogger(AccountServiceTest.class);
3031

32+
// INFO: There must be a delay for the blockchain to process each call
33+
@BeforeEach
34+
void wait_for_network() throws InterruptedException {
35+
Thread.sleep(5000);
36+
}
37+
3138
@Test
3239
void createImplicitAccountFromMnemonic_should_getStatus_SuccessValueStatus() throws GeneralSecurityException, IOException, MnemonicException.MnemonicLengthException {
3340
MnemonicCode mnemonicCode = new MnemonicCode(Language.EN);
@@ -40,10 +47,10 @@ void createImplicitAccountFromMnemonic_should_getStatus_SuccessValueStatus() thr
4047
LOGGER.debug(Hex.encode(newPublicKey.getData()));
4148
LOGGER.debug("=============> Privatekey ");
4249
LOGGER.debug(Hex.encode(newPrivateKey.getData()));
43-
String signerId = "syntifi-alice.testnet";
50+
String signerId = "syntifi-bob.testnet";
4451
BigInteger amount = new BigInteger(Formats.parseNearAmount("1"), 10);
45-
PrivateKey privateKey = aliceNearPrivateKey;
46-
PublicKey publicKey = aliceNearPublicKey;
52+
PrivateKey privateKey = bobNearPrivateKey;
53+
PublicKey publicKey = bobNearPublicKey;
4754
TransactionAwait transactionAwait = TransferService
4855
.sendTransferActionAwait(nearClient, signerId, Hex.encode(newPublicKey.getData()),
4956
publicKey, privateKey, amount);

near-java-api-rpc/src/test/java/com/syntifi/near/api/rpc/service/TransferServiceTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.syntifi.near.api.rpc.model.identifier.Finality;
1212
import com.syntifi.near.api.rpc.model.transaction.*;
1313
import com.syntifi.near.borshj.Borsh;
14+
import org.junit.jupiter.api.BeforeEach;
1415
import org.junit.jupiter.api.Test;
1516

1617
import java.math.BigInteger;
@@ -26,6 +27,12 @@
2627

2728
public class TransferServiceTest extends AbstractKeyTest {
2829

30+
// INFO: There must be a delay for the blockchain to process each call
31+
@BeforeEach
32+
void wait_for_network() throws InterruptedException {
33+
Thread.sleep(1000);
34+
}
35+
2936
@Test
3037
void serializeSignAndDeserializeVerifyTransaction_should_match() throws GeneralSecurityException {
3138
String signerId = "syntifi-alice.testnet";

near-java-api-rpc/src/test/java/com/syntifi/near/api/rpc/service/ft/FTServiceTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.syntifi.near.api.rpc.service.ft;
22

3-
import com.fasterxml.jackson.databind.JsonNode;
43
import com.syntifi.near.api.common.key.AbstractKeyTest;
54
import com.syntifi.near.api.common.model.key.PrivateKey;
65
import com.syntifi.near.api.common.model.key.PublicKey;
@@ -11,6 +10,7 @@
1110
import com.syntifi.near.api.rpc.service.contract.common.FunctionCallResult;
1211
import com.syntifi.near.api.rpc.service.contract.ft.FTService;
1312
import com.syntifi.near.api.rpc.service.contract.ft.model.FTTokenMetadata;
13+
import org.junit.jupiter.api.BeforeEach;
1414
import org.junit.jupiter.api.Disabled;
1515
import org.junit.jupiter.api.Test;
1616
import org.slf4j.Logger;
@@ -28,6 +28,12 @@ public class FTServiceTest extends AbstractKeyTest {
2828

2929
private static final FTService service = ContractClient.createClientProxy(FTService.class, new ContractMethodProxyClient());
3030

31+
// INFO: There must be a delay for the blockchain to process each call
32+
@BeforeEach
33+
void wait_for_network() throws InterruptedException {
34+
Thread.sleep(1000);
35+
}
36+
3137
@Test
3238
void testTotalSupply_should_be_greater_than_zero() {
3339
String tokenId = "ft.demo.testnet";

near-java-api-rpc/src/test/java/com/syntifi/near/api/rpc/service/nft/NFTServiceTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.syntifi.near.api.rpc.service.contract.nft.model.NFTToken;
1414
import com.syntifi.near.api.rpc.service.contract.nft.model.NFTTokenList;
1515
import com.syntifi.near.api.rpc.service.contract.nft.model.NFTTokenMediaURL;
16+
import org.junit.jupiter.api.BeforeEach;
1617
import org.junit.jupiter.api.Disabled;
1718
import org.junit.jupiter.api.Test;
1819
import org.slf4j.Logger;
@@ -29,6 +30,12 @@ public class NFTServiceTest extends AbstractKeyTest {
2930

3031
private static final NFTService service = ContractClient.createClientProxy(NFTService.class, new ContractMethodProxyClient());
3132

33+
// INFO: There must be a delay for the blockchain to process each call
34+
@BeforeEach
35+
void wait_for_network() throws InterruptedException {
36+
Thread.sleep(1000);
37+
}
38+
3239
@Test
3340
void callContractFunction_NFTContractFunctionCall_forTotalSupply_return_list() {
3441
FunctionCallResult<String> result = service.getTotalSupply(nearClient,

near-java-api-rpc/src/test/java/com/syntifi/near/api/rpc/service/staking/StakingServiceTest.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,15 @@
1616
import com.syntifi.near.api.rpc.service.contract.common.FunctionCallResult;
1717
import com.syntifi.near.api.rpc.service.contract.staking.StakingService;
1818
import com.syntifi.near.api.rpc.service.contract.staking.model.RewardFee;
19-
import org.junit.jupiter.api.Disabled;
19+
import org.junit.jupiter.api.BeforeEach;
2020
import org.junit.jupiter.api.Test;
2121
import org.slf4j.Logger;
2222
import org.slf4j.LoggerFactory;
2323

2424
import java.math.BigInteger;
2525

2626
import static com.syntifi.near.api.rpc.NearClientTestnetHelper.nearClient;
27-
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
28-
import static org.junit.jupiter.api.Assertions.assertEquals;
29-
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
30-
import static org.junit.jupiter.api.Assertions.assertNotNull;
27+
import static org.junit.jupiter.api.Assertions.*;
3128

3229
class StakingServiceTest extends AbstractKeyTest {
3330

@@ -37,6 +34,12 @@ class StakingServiceTest extends AbstractKeyTest {
3734
private static final Logger LOGGER = LoggerFactory.getLogger(AccountServiceTest.class);
3835
private static final StakingService service = ContractClient.createClientProxy(StakingService.class, new ContractMethodProxyClient());
3936

37+
// INFO: There must be a delay for the blockchain to process each call
38+
@BeforeEach
39+
void wait_for_network() throws InterruptedException {
40+
Thread.sleep(1000);
41+
}
42+
4043
@Test
4144
void testAccountTotalBalance_should_be_bigger_than_zero() {
4245
String stakingPool = "stakesstone.pool.f863973.m0";

near-java-api-rpc/src/test/resources/log4j2-test.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
status = info
1+
status = error
22
dest = out
33
name = NearJavaApi
44

@@ -38,7 +38,7 @@ rootLogger.level = info
3838
rootLogger.appenderRef.stdout.ref = STDOUT
3939

4040
logger.tests.name = com.syntifi.near.api
41-
logger.tests.level = trace
41+
logger.tests.level = info
4242

4343
logger.tests-rpc.name = com.googlecode.jsonrpc4j
44-
logger.tests-rpc.level = debug
44+
logger.tests-rpc.level = info

0 commit comments

Comments
 (0)