Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 61 additions & 22 deletions .ci/ci_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ check_basic()
bash gradlew build --info
}

download_tassl()
{
local OPENSSL_CMD=${HOME}/.fisco/tassl-1.1.1b
if [ -f "${OPENSSL_CMD}" ];then
return
fi
local package_name="tassl-1.1.1b-linux-x86_64"
if [ "$(uname)" == "Darwin" ];then
package_name="tassl-1.1.1b-macOS-x86_64"
fi
curl -LO "https://github.com/FISCO-BCOS/LargeFiles/raw/master/tools/${package_name}.tar.gz" && tar -zxvf "${package_name}.tar.gz" && mv "${package_name}" tassl-1.1.1b && mkdir -p ~/.fisco && mv tassl-1.1.1b ~/.fisco/
}

download_build_chain()
{
local tag="${1}"
Expand All @@ -23,6 +36,17 @@ download_build_chain()
curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/${tag}/build_chain.sh" && chmod u+x build_chain.sh
}

download_binary()
{
local tag="${1}"
LOG_INFO "--- current tag: $tag"
local package_name="fisco-bcos-linux-x86_64.tar.gz"
if [ "$(uname)" == "Darwin" ];then
package_name="fisco-bcos-macOS-x86_64.tar.gz"
fi
curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/${tag}/${package_name}" && tar -zxvf "${package_name}"
}

get_sed_cmd()
{
local sed_cmd="sed -i"
Expand All @@ -47,16 +71,15 @@ prepare_environment()
cp -r src/test/resources/ecdsa/abi src/integration-test/resources/abi
cp -r src/test/resources/ecdsa/bin src/integration-test/resources/bin

sed_cmd=$(get_sed_cmd)

local node_type="${1}"
if [ "${node_type}" == "sm" ];then
rm -rf src/integration-test/resources/abi
rm -rf src/integration-test/resources/bin
cp -r src/test/resources/gm/abi src/integration-test/resources/abi
cp -r src/test/resources/gm/bin src/integration-test/resources/bin
${sed_cmd} 's/useSMCrypto = "false"/useSMCrypto = "true"/g' src/integration-test/resources/config.toml
fi
# sed_cmd=$(get_sed_cmd)
# local node_type="${1}"
# if [ "${node_type}" == "sm" ];then
# rm -rf src/integration-test/resources/abi
# rm -rf src/integration-test/resources/bin
# cp -r src/test/resources/gm/abi src/integration-test/resources/abi
# cp -r src/test/resources/gm/bin src/integration-test/resources/bin
# ${sed_cmd} 's/useSMCrypto = "false"/useSMCrypto = "true"/g' src/integration-test/resources/config.toml
# fi
}

prepare_wasm_environment()
Expand All @@ -76,9 +99,9 @@ build_node()
local node_type="${1}"
local sed_cmd=$(get_sed_cmd)
if [ "${node_type}" == "wasm" ];then
bash build_chain.sh -l 127.0.0.1:4 -w
bash build_chain.sh -l 127.0.0.1:4 -e ./fisco-bcos -w "${2}"
else
bash build_chain.sh -l 127.0.0.1:4
bash build_chain.sh -l 127.0.0.1:4 -e ./fisco-bcos "${2}"
fi
./nodes/127.0.0.1/fisco-bcos -v
cat nodes/127.0.0.1/node0/config.genesis
Expand All @@ -89,41 +112,57 @@ clean_node()
{
bash nodes/127.0.0.1/stop_all.sh
rm -rf nodes
if [ "${1}" == "true" ]; then
rm -rf ./fisco-bcos*
fi
}

# check integration-test for non-gm node
check_standard_node()
{
build_node
build_node "normal" "${2}"
prepare_environment
## run integration test
bash gradlew clean integrationTest --info
## clean
clean_node
clean_node "${1}"
}

check_wasm_node()
{
build_node "wasm"
build_node "wasm" "${2}"
prepare_wasm_environment
## run integration test
bash gradlew clean integrationWasmTest --info
## clean
clean_node
clean_node "${1}"
}

pwd
ls -la
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
LOG_INFO "------ download_build_chain---------"
download_tassl
LOG_INFO "------ download_build_chain: v3.2.0---------"
download_binary "v3.2.0"
download_build_chain "v3.2.0"
LOG_INFO "------ check_standard_node---------"
check_standard_node
check_standard_node "false"
LOG_INFO "------ check_wasm_node---------"
check_wasm_node
check_wasm_node "true"
LOG_INFO "------ check_basic---------"
check_basic
LOG_INFO "------ check_log---------"
rm -rf ./bin
cat log/* |grep -i error
cat log/* |grep -i warn

LOG_INFO "------ download_binary: v3.1.0---------"
download_build_chain "v3.1.0"
download_binary "v3.1.0"
LOG_INFO "------ check_standard_node---------"
check_standard_node
rm -rf ./bin

LOG_INFO "------ download_binary: v3.0.0---------"
download_build_chain "v3.0.0"
download_binary "v3.0.0"
LOG_INFO "------ check_standard_node---------"
check_standard_node
rm -rf ./bin
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.fisco.bcos.sdk.v3.codec.datatypes.Type;
import org.fisco.bcos.sdk.v3.codec.datatypes.TypeReference;
import org.fisco.bcos.sdk.v3.codec.datatypes.Utf8String;
import org.fisco.bcos.sdk.v3.model.EnumNodeVersion;
import org.fisco.bcos.sdk.v3.model.callback.RespCallback;
import org.fisco.bcos.sdk.v3.client.protocol.response.Abi;
import org.fisco.bcos.sdk.v3.client.protocol.response.BcosBlock;
Expand Down Expand Up @@ -334,10 +335,11 @@ public void onError(Response errorResponse) {

String txHash = receipt.getTransactionHash();
BcosTransaction transaction1 = client.getTransaction(txHash, false);
Assert.assertEquals(extraData, transaction1.getResult().getExtraData());

BcosTransactionReceipt transactionReceipt = client.getTransactionReceipt(txHash, false);
Assert.assertEquals(extraData, transactionReceipt.getResult().getExtraData());
if (client.getChainVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
Assert.assertEquals(extraData, transaction1.getResult().getExtraData());
Assert.assertEquals(extraData, transactionReceipt.getResult().getExtraData());
}

// get 2nd block
block1 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicLong;

import org.fisco.bcos.sdk.jni.common.JniException;
import org.fisco.bcos.sdk.v3.client.Client;
import org.fisco.bcos.sdk.v3.client.protocol.response.SealerList;
Expand All @@ -45,6 +46,7 @@
import org.fisco.bcos.sdk.v3.contract.precompiled.sysconfig.SystemConfigService;
import org.fisco.bcos.sdk.v3.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.v3.model.ConstantConfig;
import org.fisco.bcos.sdk.v3.model.EnumNodeVersion;
import org.fisco.bcos.sdk.v3.model.PrecompiledConstant;
import org.fisco.bcos.sdk.v3.model.PrecompiledRetCode;
import org.fisco.bcos.sdk.v3.model.RetCode;
Expand Down Expand Up @@ -172,28 +174,35 @@ private void testSystemConfigService(
BigInteger queriedValue =
new BigInteger(client.getSystemConfigByKey(key).getSystemConfig().getValue());
System.out.println("queriedValue: " + queriedValue);
Assert.assertTrue(queriedValue.equals(updatedValue));
Assert.assertTrue(queriedValue.equals(value.add(BigInteger.valueOf(100))));
Assert.assertEquals(queriedValue, updatedValue);
Assert.assertEquals(queriedValue, value.add(BigInteger.valueOf(100)));
}

@Test
public void test5CRUDService() throws ConfigException, ContractException, JniException {
public void test5CRUDService() throws ConfigException, ContractException {
ConfigOption configOption = Config.load(configFile);
Client client = Client.build(GROUP, configOption);

CryptoKeyPair cryptoKeyPair = client.getCryptoSuite().getCryptoKeyPair();
TableCRUDService tableCRUDService = new TableCRUDService(client, cryptoKeyPair);
// create a user table
String tableName = "test" + new Random().nextInt(10000);
String tableName = "test" + System.currentTimeMillis();
String key = "key";
List<String> valueFields = new ArrayList<>(5);
for (int i = 0; i < 5; i++) {
valueFields.add(i, "field" + i);
}
RetCode code = tableCRUDService.createTable(tableName, Common.TableKeyOrder.valueOf(0), key, valueFields);
RetCode code;
Map<String, List<String>> desc;
if (client.getChainVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
code = tableCRUDService.createTable(tableName, Common.TableKeyOrder.valueOf(0), key, valueFields);
desc = tableCRUDService.descWithKeyOrder(tableName);
} else {
code = tableCRUDService.createTable(tableName, key, valueFields);
desc = tableCRUDService.desc(tableName);
}
Assert.assertEquals(0, code.getCode());
// desc
Map<String, List<String>> desc = tableCRUDService.descWithKeyOrder(tableName);
Assert.assertEquals(desc.get(PrecompiledConstant.VALUE_FIELD_NAME), valueFields);

// insert
Expand All @@ -207,10 +216,19 @@ public void test5CRUDService() throws ConfigException, ContractException, JniExc
// select key
Map<String, String> result = tableCRUDService.select(tableName, "key1");

ConditionV320 condition = new ConditionV320();
condition.EQ(key,"990");
condition.setLimit(0, 10);
List<Map<String, String>> select = tableCRUDService.select(tableName, condition);
if (client.getChainVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
ConditionV320 condition = new ConditionV320();
condition.EQ(key, "key1");
condition.setLimit(0, 10);
List<Map<String, String>> select = tableCRUDService.select(tableName, condition);
Assert.assertEquals(select.size(), 1);
} else {
Condition condition = new Condition();
condition.EQ("key1");
condition.setLimit(0, 10);
List<Map<String, String>> select = tableCRUDService.select(tableName, condition);
Assert.assertEquals(select.size(), 1);
}
// field value result + key result
Assert.assertEquals(result.size(), valueFields.size() + 1);
System.out.println("tableCRUDService select result: " + result);
Expand Down Expand Up @@ -244,7 +262,12 @@ public void test51SyncCRUDService() throws ConfigException, ContractException, J
String tableName = "test_sync" + System.currentTimeMillis();
List<String> valueFiled = new ArrayList<>();
valueFiled.add("field");
RetCode retCode = crudService.createTable(tableName, Common.TableKeyOrder.valueOf(0), "key", valueFiled);
RetCode retCode;
if (client.getChainVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
retCode = crudService.createTable(tableName, Common.TableKeyOrder.valueOf(0), "key", valueFiled);
} else {
retCode = crudService.createTable(tableName, "key", valueFiled);
}
System.out.println("tableName" + tableName);
System.out.println(
"createResult: " + retCode.getCode() + ", message: " + retCode.getMessage());
Expand Down Expand Up @@ -317,7 +340,11 @@ public void test52AsyncCRUDService()
List<String> valueFiled = new ArrayList<>();
valueFiled.add("field");
String key = "key";
crudService.createTable(tableName, Common.TableKeyOrder.valueOf(0), key, valueFiled);
if (client.getChainVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
crudService.createTable(tableName, Common.TableKeyOrder.valueOf(0), key, valueFiled);
} else {
crudService.createTable(tableName, key, valueFiled);
}
// create a thread pool to parallel insert and select
ExecutorService threadPool = Executors.newFixedThreadPool(50);
BigInteger orgTxCount =
Expand Down Expand Up @@ -369,19 +396,24 @@ public void test52AsyncCRUDService()
}

@Test
public void test6KVService() throws ConfigException, ContractException, JniException {
public void test6KVService() throws ConfigException, ContractException {
ConfigOption configOption = Config.load(configFile);
Client client = Client.build(GROUP, configOption);

CryptoKeyPair cryptoKeyPair = client.getCryptoSuite().getCryptoKeyPair();
KVTableService kvTableService = new KVTableService(client, cryptoKeyPair);
// create a user table
String tableName = "test" + (int) (Math.random() * 1000);
String tableName = "test" + System.currentTimeMillis();
String key = "key";
RetCode code = kvTableService.createTable(tableName, key, "field");
Assert.assertEquals(0, code.getCode());
// desc
Map<String, String> desc = kvTableService.descWithKeyOrder(tableName);
Map<String, String> desc;
if (client.getChainVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
desc = kvTableService.descWithKeyOrder(tableName);
} else {
desc = kvTableService.desc(tableName);
}
Assert.assertEquals(desc.get(PrecompiledConstant.VALUE_FIELD_NAME), "field");

// set
Expand All @@ -395,7 +427,7 @@ public void test6KVService() throws ConfigException, ContractException, JniExcep
}

@Test
public void test7BFSPrecompiled() throws ConfigException, ContractException, JniException {
public void test7BFSPrecompiled() throws ConfigException, ContractException {

ConfigOption configOption = Config.load(configFile);
Client client = Client.build(GROUP, configOption);
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/v3/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.fisco.bcos.sdk.v3.client.protocol.response.TotalTransactionCount;
import org.fisco.bcos.sdk.v3.config.ConfigOption;
import org.fisco.bcos.sdk.v3.crypto.CryptoSuite;
import org.fisco.bcos.sdk.v3.model.EnumNodeVersion;
import org.fisco.bcos.sdk.v3.model.callback.RespCallback;
import org.fisco.bcos.sdk.v3.model.callback.TransactionCallback;
import org.slf4j.Logger;
Expand Down Expand Up @@ -868,6 +869,20 @@ void getTransactionReceiptAsync(

// ------------------------- rpc interface end ------------------------------------------

/**
* get the chain compatibility version
*
* @return the chain compatibility version
*/
EnumNodeVersion.Version getChainVersion();

/**
* async get the chain compatibility version
*
* @param versionRespCallback the callback instance
*/
void getChainVersionAsync(RespCallback<EnumNodeVersion.Version> versionRespCallback);

void start();

void stop();
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/org/fisco/bcos/sdk/v3/client/ClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,42 @@ public void getGroupNodeInfoAsync(String node, RespCallback<BcosGroupNodeInfo> c
callback);
}

@Override
public EnumNodeVersion.Version getChainVersion() {
List<BcosGroupNodeInfo.GroupNodeInfo> nodeList = getGroupInfo().getResult().getNodeList();
if (nodeList == null || nodeList.isEmpty()) {
throw new IllegalStateException("Empty node list in group info.");
}
long compatibilityVersion = nodeList.get(0).getProtocol().getCompatibilityVersion();
return EnumNodeVersion.convertToVersion((int) compatibilityVersion);
}

@Override
public void getChainVersionAsync(RespCallback<EnumNodeVersion.Version> versionRespCallback) {
getGroupInfoAsync(
new RespCallback<BcosGroupInfo>() {
@Override
public void onResponse(BcosGroupInfo bcosGroupInfo) {
List<BcosGroupNodeInfo.GroupNodeInfo> nodeList =
bcosGroupInfo.getResult().getNodeList();
if (nodeList == null || nodeList.isEmpty()) {
versionRespCallback.onError(
new Response(-1, "Empty node list in group info."));
return;
}
long compatibilityVersion =
nodeList.get(0).getProtocol().getCompatibilityVersion();
versionRespCallback.onResponse(
EnumNodeVersion.convertToVersion((int) compatibilityVersion));
}

@Override
public void onError(Response errorResponse) {
versionRespCallback.onError(errorResponse);
}
});
}

@Override
public void start() {
if (rpcJniObj != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ disableSsl = "false" # Communication with nodes without S
[network]
messageTimeout = "10000"
defaultGroup = "group0"
peers=["127.0.0.1:20200", "127.0.0.1:20201"] # The peer list to connect
peers=["127.0.0.1:20201"] # The peer list to connect


[account]
Expand Down