Skip to content

Commit

Permalink
Merge pull request #756 from kyonRay/master
Browse files Browse the repository at this point in the history
Release 3.3.0
  • Loading branch information
kyonRay authored Apr 17, 2023
2 parents 9f8531d + a13ff87 commit de20b61
Show file tree
Hide file tree
Showing 35 changed files with 1,022 additions and 421 deletions.
74 changes: 60 additions & 14 deletions .ci/ci_check.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
#!/bin/bash

set -e
default_tag=v3.1.1
LOG_INFO() {
local content=${1}
echo -e "\033[32m ${content}\033[0m"
}

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/
}

get_sed_cmd()
{
local sed_cmd="sed -i"
Expand All @@ -18,13 +30,23 @@ get_sed_cmd()

download_build_chain()
{
tag=$(curl -sS "https://gitee.com/api/v5/repos/FISCO-BCOS/FISCO-BCOS/tags" | grep -oe "\"name\":\"v[2-9]*\.[0-9]*\.[0-9]*\"" | cut -d \" -f 4 | sort -V | tail -n 1)
local tag="${1}"
if [ -z "${tag}" ]; then
tag=$(curl -sS "https://gitee.com/api/v5/repos/FISCO-BCOS/FISCO-BCOS/tags" | grep -oe "\"name\":\"v[2-9]*\.[0-9]*\.[0-9]*\"" | cut -d \" -f 4 | sort -V | tail -n 1)
fi
LOG_INFO "--- current tag: $tag"
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"
if [[ -z ${tag} ]]; then
LOG_INFO "tag is empty, use default tag: ${default_tag}"
tag="${default_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}/build_chain.sh" && chmod u+x build_chain.sh
curl -LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/${tag}/${package_name}" && tar -zxvf "${package_name}"
}

prepare_environment()
Expand All @@ -47,23 +69,31 @@ build_node()
{
local node_type="${1}"
if [ "${node_type}" == "sm" ];then
bash -x build_chain.sh -l 127.0.0.1:4 -s -A
sed_cmd=$(get_sed_cmd)
$sed_cmd 's/sm_crypto_channel=false/sm_crypto_channel=true/g' nodes/127.0.0.1/node*/config.ini
bash build_chain.sh -l 127.0.0.1:4 -s -A -e ./fisco-bcos
else
bash -x build_chain.sh -l 127.0.0.1:4 -A
bash build_chain.sh -l 127.0.0.1:4 -A -e ./fisco-bcos
fi
./nodes/127.0.0.1/fisco-bcos -v
./nodes/127.0.0.1/start_all.sh
}

clean_node()
{
bash nodes/127.0.0.1/stop_all.sh
rm -rf nodes
if [ "${1}" == "true" ]; then
rm -rf ./fisco-bcos*
fi
}

check_standard_node()
{
build_node
prepare_environment
## run integration test
bash gradlew test --info
bash gradlew integrationTest --info
clean_node "${1}"
}

check_sm_node()
Expand All @@ -73,6 +103,7 @@ check_sm_node()
## run integration test
bash gradlew test --info
bash gradlew integrationTest --info
clean_node "${1}"
}

check_basic()
Expand All @@ -88,10 +119,25 @@ bash gradlew integrationTest --info

#cp src/integration-test/resources/config-example.toml src/integration-test/resources/config.toml
#LOG_INFO "------ download_build_chain---------"
download_build_chain
#LOG_INFO "------ check_standard_node---------"
#check_standard_node
download_binary "v3.2.0"
download_build_chain "v3.2.0"
LOG_INFO "------ check_standard_node---------"
check_standard_node false
LOG_INFO "------ check_sm_node---------"
check_sm_node
check_sm_node true
LOG_INFO "------ check_basic---------"
check_basic

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

LOG_INFO "------ download_binary: v3.0.0---------"
download_binary "v3.0.0"
download_build_chain "v3.0.0"
LOG_INFO "------ check_standard_node---------"
check_standard_node
rm -rf ./bin
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, windows-2019, macos-latest]
os: [ubuntu-20.04, ubuntu-22.04, windows-2019, macos-latest]
steps:
- uses: actions/checkout@v2
with:
Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,22 @@ dependencies {
//compile 'org.fisco-bcos:solcJ:0.5.2.1'
compile 'org.fisco-bcos:solcJ:0.8.11.1'

compile('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.2.0') {
compile('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.3.0-SNAPSHOT') {
exclude group: "org.slf4j"
}

compile('org.fisco-bcos:evm-static-analysis:1.0.0') {
exclude group: "org.slf4j"
}
compile('commons-cli:commons-cli:1.5.0')
compile('org.jline:jline:3.21.0')
compile('io.bretty:console-table-builder:1.2')
compile('com.github.jsqlparser:jsqlparser:2.0')
compile('org.fisco-bcos.code-generator:bcos-code-generator:1.0.0') {
compile('org.fisco-bcos.code-generator:bcos-code-generator:1.1.0-SNAPSHOT') {
exclude group: "org.fisco-bcos.java-sdk"
exclude group: "org.slf4j"
}
compile ('com.fasterxml.jackson.core:jackson-databind:2.14.0'){
compile ('com.fasterxml.jackson.core:jackson-databind:2.14.2'){
force true
}
testCompile('com.github.stefanbirkner:system-rules:1.19.0')
Expand Down
2 changes: 1 addition & 1 deletion release_note.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.2.0
v3.3.0
28 changes: 25 additions & 3 deletions src/integration-test/java/console/PrecompiledTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package console;

import org.fisco.bcos.sdk.v3.model.EnumNodeVersion;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -14,63 +15,84 @@ public class PrecompiledTest extends TestBase {

@Test
public void crudTest() throws Exception {
String tableName = "t_demo" + Math.abs(new Random().nextInt());
String tableName = "t_demo" + System.currentTimeMillis();
String createSql = "create table " + tableName + "(name varchar, item_id varchar, item_name varchar, primary key(name))";
System.out.println(createSql);
precompiledFace.createTable(createSql);
Assert.assertTrue(log.getLog().contains("Ok"));
log.clearLog();

if (chainVersion.getVersion() >= EnumNodeVersion.BCOS_3_2_0.getVersion()) {
String tableName2 = "t_demo_" + System.currentTimeMillis();
String createSql2 = "create table " + tableName2 + "(name varchar, item_id varchar, item_name varchar, primary key(name))";
System.out.println(createSql2);
precompiledFace.createTable(createSql2);
Assert.assertTrue(log.getLog().contains("Ok"));
log.clearLog();
}

System.out.println("ls /tables");
precompiledFace.listDir(new String[]{"", "/tables"});
Assert.assertTrue(log.getLog().contains(tableName));
log.clearLog();

String insertSql = "insert into " + tableName + " (name, item_id, item_name) values (fruit, 1, apple1)";
System.out.println(insertSql);
precompiledFace.insert(insertSql);
Assert.assertTrue(log.getLog().contains("OK"));
log.clearLog();

// select
String selectSql = "select * from " + tableName + " where name = fruit";
System.out.println(selectSql);
precompiledFace.select(selectSql);
Assert.assertTrue(log.getLog().contains("fruit"));
log.clearLog();

selectSql = "select name, item_id, item_name from " + tableName + " where name = fruit";
System.out.println(selectSql);
precompiledFace.select(selectSql);
Assert.assertTrue(log.getLog().contains("fruit"));
log.clearLog();

insertSql = "insert into " + tableName + " (name, item_id, item_name) values (fruit2, 2, orange)";
System.out.println(insertSql);
precompiledFace.insert(insertSql);
Assert.assertTrue(log.getLog().contains("OK"));
log.clearLog();

selectSql = "select * from " + tableName + " where name >= fruit";
System.out.println(selectSql);
precompiledFace.select(selectSql);
Assert.assertTrue(log.getLog().contains("fruit2"));
log.clearLog();

selectSql = "select * from " + tableName + " where name >= fruit limit 0,1";
System.out.println(selectSql);
precompiledFace.select(selectSql);
Assert.assertFalse(log.getLog().contains("fruit2"));
log.clearLog();

String updateSql = "update " + tableName + " set item_name = orange where name = fruit";
System.out.println(updateSql);
precompiledFace.update(updateSql);
Assert.assertTrue(log.getLog().contains("1 row affected"));
log.clearLog();

String removeSql = "delete from " + tableName + " where name = fruit2";
System.out.println(removeSql);
precompiledFace.remove(removeSql);
Assert.assertTrue(log.getLog().contains("OK"));
log.clearLog();

selectSql = "select * from " + tableName + " where name = fruit2";
System.out.println(selectSql);
precompiledFace.select(selectSql);
Assert.assertTrue(log.getLog().contains("Empty"));
log.clearLog();

String newField = "comment" + Math.abs(new Random().nextInt());
String newField = "comment" + System.currentTimeMillis();
System.out.println(newField);
String alterSql = "alter table " + tableName + " add " + newField + " varchar";
precompiledFace.alterTable(alterSql);
Assert.assertTrue(log.getLog().contains("Ok"));
Expand Down Expand Up @@ -139,7 +161,7 @@ public void bfsTest() throws Exception {

@Test
public void authTest() throws Exception {
if (!isAuthCheck){
if (!isAuthCheck) {
return;
}
String[] emptyParams = {};
Expand Down
21 changes: 12 additions & 9 deletions src/main/java/console/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ public static void main(String[] args) {
keymap.bind(new Reference("beginning-of-line"), "\033[1~");
keymap.bind(new Reference("end-of-line"), "\033[4~");
}
consoleInitializer.setLineReader(lineReader);
} catch (Exception e) {
System.out.println(e.getMessage());
logger.error(" message: {}, e: {}", e.getMessage(), e);
e.printStackTrace();
logger.error(" message: {}", e.getMessage(), e);
System.exit(-1);
}

Expand All @@ -66,19 +67,21 @@ public static void main(String[] args) {

while (true) {
try {
if (lineReader == null) {
if (consoleInitializer.getLineReader() == null) {
System.out.println("Console can not read commands.");
break;
}
String request;
if (!consoleInitializer.isDisableAutoCompleter()) {
request =
lineReader.readLine(
"["
+ consoleInitializer.getGroupID()
+ "]: "
+ ConsoleUtils.prettyPwd(pwd)
+ "> ");
consoleInitializer
.getLineReader()
.readLine(
"["
+ consoleInitializer.getGroupID()
+ "]: "
+ ConsoleUtils.prettyPwd(pwd)
+ "> ");
} else {
System.out.print(
"[group:"
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/console/ConsoleInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.fisco.bcos.sdk.v3.crypto.exceptions.LoadKeyStoreException;
import org.fisco.bcos.sdk.v3.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.v3.model.CryptoType;
import org.jline.reader.LineReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -42,6 +43,15 @@ public class ConsoleInitializer {
private AuthFace authFace;
private CollaborationFace collaborationFace;
private boolean disableAutoCompleter = false;
private LineReader lineReader;

public LineReader getLineReader() {
return lineReader;
}

public void setLineReader(LineReader lineReader) {
this.lineReader = lineReader;
}

public void init(String[] args) throws ConfigException {
AccountInfo accountInfo = null;
Expand Down Expand Up @@ -125,6 +135,10 @@ private AccountInfo loadConfig(String[] args) throws ConfigException {
System.exit(0);
}

if (config.getCryptoMaterialConfig().getEnableHsm()) {
return new AccountInfo("HSM", "", "");
}

if (args.length == 3) {
return loadAccount(bcosSDK, args);
}
Expand Down Expand Up @@ -173,7 +187,7 @@ private void loadAccountInfo(AccountInfo accountInfo, String groupID) {
System.out.println(
"Failed to create BcosSDK failed! Please check the node status and the console configuration, error info: "
+ e.getMessage());
logger.error(" message: {}, e: {}", e.getMessage(), e);
logger.error(" message: {}", e.getMessage(), e);
System.exit(0);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/console/auth/AuthFace.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public interface AuthFace {

void createRemoveNodeProposal(String[] params) throws Exception;

void createSetSysConfigProposal(String[] params) throws Exception;
void createSetSysConfigProposal(ConsoleInitializer consoleInitializer, String[] params)
throws Exception;

void createUpgradeVoteComputerProposal(String[] params) throws Exception;

Expand Down Expand Up @@ -69,4 +70,6 @@ public interface AuthFace {
void abolishAccount(String[] params) throws Exception;

void getAccountStatus(String[] params) throws Exception;

void initAuth(String[] params) throws Exception;
}
Loading

0 comments on commit de20b61

Please sign in to comment.