Skip to content

Commit

Permalink
Included a delay before each integration test for the blockchain to p…
Browse files Browse the repository at this point in the history
…rocess de request
  • Loading branch information
oak committed Sep 13, 2022
1 parent c35c418 commit 1b5121e
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
status = info
status = error
dest = out
name = NearJavaApi

Expand Down Expand Up @@ -38,4 +38,4 @@ rootLogger.level = info
rootLogger.appenderRef.stdout.ref = STDOUT

logger.tests.name = com.syntifi.near.api
logger.tests.level = debug
logger.tests.level = info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
status = info
status = error
dest = out
name = NearJavaApi

Expand Down Expand Up @@ -38,4 +38,4 @@ rootLogger.level = info
rootLogger.appenderRef.stdout.ref = STDOUT

logger.tests.name = com.syntifi.near.api
logger.tests.level = debug
logger.tests.level = info
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.syntifi.near.api.common.model.key.PublicKey;
import com.syntifi.near.api.rpc.model.transaction.Status;
import com.syntifi.near.api.rpc.model.transaction.TransactionAwait;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -28,6 +29,12 @@
public class AccountServiceTest extends AbstractKeyTest {
private static final Logger LOGGER = LoggerFactory.getLogger(AccountServiceTest.class);

// INFO: There must be a delay for the blockchain to process each call
@BeforeEach
void wait_for_network() throws InterruptedException {
Thread.sleep(5000);
}

@Test
void createImplicitAccountFromMnemonic_should_getStatus_SuccessValueStatus() throws GeneralSecurityException, IOException, MnemonicException.MnemonicLengthException {
MnemonicCode mnemonicCode = new MnemonicCode(Language.EN);
Expand All @@ -40,10 +47,10 @@ void createImplicitAccountFromMnemonic_should_getStatus_SuccessValueStatus() thr
LOGGER.debug(Hex.encode(newPublicKey.getData()));
LOGGER.debug("=============> Privatekey ");
LOGGER.debug(Hex.encode(newPrivateKey.getData()));
String signerId = "syntifi-alice.testnet";
String signerId = "syntifi-bob.testnet";
BigInteger amount = new BigInteger(Formats.parseNearAmount("1"), 10);
PrivateKey privateKey = aliceNearPrivateKey;
PublicKey publicKey = aliceNearPublicKey;
PrivateKey privateKey = bobNearPrivateKey;
PublicKey publicKey = bobNearPublicKey;
TransactionAwait transactionAwait = TransferService
.sendTransferActionAwait(nearClient, signerId, Hex.encode(newPublicKey.getData()),
publicKey, privateKey, amount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.syntifi.near.api.rpc.model.identifier.Finality;
import com.syntifi.near.api.rpc.model.transaction.*;
import com.syntifi.near.borshj.Borsh;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.math.BigInteger;
Expand All @@ -26,6 +27,12 @@

public class TransferServiceTest extends AbstractKeyTest {

// INFO: There must be a delay for the blockchain to process each call
@BeforeEach
void wait_for_network() throws InterruptedException {
Thread.sleep(1000);
}

@Test
void serializeSignAndDeserializeVerifyTransaction_should_match() throws GeneralSecurityException {
String signerId = "syntifi-alice.testnet";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.syntifi.near.api.rpc.service.ft;

import com.fasterxml.jackson.databind.JsonNode;
import com.syntifi.near.api.common.key.AbstractKeyTest;
import com.syntifi.near.api.common.model.key.PrivateKey;
import com.syntifi.near.api.common.model.key.PublicKey;
Expand All @@ -11,6 +10,7 @@
import com.syntifi.near.api.rpc.service.contract.common.FunctionCallResult;
import com.syntifi.near.api.rpc.service.contract.ft.FTService;
import com.syntifi.near.api.rpc.service.contract.ft.model.FTTokenMetadata;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand All @@ -28,6 +28,12 @@ public class FTServiceTest extends AbstractKeyTest {

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

// INFO: There must be a delay for the blockchain to process each call
@BeforeEach
void wait_for_network() throws InterruptedException {
Thread.sleep(1000);
}

@Test
void testTotalSupply_should_be_greater_than_zero() {
String tokenId = "ft.demo.testnet";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.syntifi.near.api.rpc.service.contract.nft.model.NFTToken;
import com.syntifi.near.api.rpc.service.contract.nft.model.NFTTokenList;
import com.syntifi.near.api.rpc.service.contract.nft.model.NFTTokenMediaURL;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
Expand All @@ -29,6 +30,12 @@ public class NFTServiceTest extends AbstractKeyTest {

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

// INFO: There must be a delay for the blockchain to process each call
@BeforeEach
void wait_for_network() throws InterruptedException {
Thread.sleep(1000);
}

@Test
void callContractFunction_NFTContractFunctionCall_forTotalSupply_return_list() {
FunctionCallResult<String> result = service.getTotalSupply(nearClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
import com.syntifi.near.api.rpc.service.contract.common.FunctionCallResult;
import com.syntifi.near.api.rpc.service.contract.staking.StakingService;
import com.syntifi.near.api.rpc.service.contract.staking.model.RewardFee;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigInteger;

import static com.syntifi.near.api.rpc.NearClientTestnetHelper.nearClient;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.*;

class StakingServiceTest extends AbstractKeyTest {

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

// INFO: There must be a delay for the blockchain to process each call
@BeforeEach
void wait_for_network() throws InterruptedException {
Thread.sleep(1000);
}

@Test
void testAccountTotalBalance_should_be_bigger_than_zero() {
String stakingPool = "stakesstone.pool.f863973.m0";
Expand Down
6 changes: 3 additions & 3 deletions near-java-api-rpc/src/test/resources/log4j2-test.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
status = info
status = error
dest = out
name = NearJavaApi

Expand Down Expand Up @@ -38,7 +38,7 @@ rootLogger.level = info
rootLogger.appenderRef.stdout.ref = STDOUT

logger.tests.name = com.syntifi.near.api
logger.tests.level = trace
logger.tests.level = info

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

0 comments on commit 1b5121e

Please sign in to comment.