Skip to content

Commit 49c82bc

Browse files
authored
Merge e7c8fc0 into b1c8925
2 parents b1c8925 + e7c8fc0 commit 49c82bc

File tree

25 files changed

+591
-115
lines changed

25 files changed

+591
-115
lines changed

.ci/ci_check.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,16 @@ build_node()
105105
{
106106
local node_type="${1}"
107107
local sed_cmd=$(get_sed_cmd)
108-
curl -LO https://raw.githubusercontent.com/FISCO-BCOS/console/master/tools/get_account.sh
109-
curl -LO https://raw.githubusercontent.com/FISCO-BCOS/console/master/tools/get_gm_account.sh
108+
if [ ! -f "get_account.sh" ];then
109+
curl -LO https://raw.githubusercontent.com/FISCO-BCOS/console/master/tools/get_account.sh
110+
fi
111+
if [ ! -f "get_gm_account.sh" ];then
112+
curl -LO https://raw.githubusercontent.com/FISCO-BCOS/console/master/tools/get_gm_account.sh
113+
fi
110114
if [ "${node_type}" == "wasm" ];then
111-
bash build_chain.sh -l 127.0.0.1:4 -e ./fisco-bcos -w "${2}"
115+
bash build_chain.sh -l 127.0.0.1:4 -e ./fisco-bcos -w ${2}
112116
else
113-
bash build_chain.sh -l 127.0.0.1:4 -A -e ./fisco-bcos "${2}"
117+
bash build_chain.sh -l 127.0.0.1:4 -e ./fisco-bcos ${2}
114118
fi
115119
./nodes/127.0.0.1/fisco-bcos -v
116120
cat nodes/127.0.0.1/node0/config.genesis
@@ -153,9 +157,9 @@ pwd
153157
ls -la
154158
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
155159
download_tassl
156-
LOG_INFO "------ download_build_chain: v3.2.0---------"
157-
download_binary "v3.2.0"
158-
download_build_chain "v3.2.0"
160+
LOG_INFO "------ download_build_chain: v3.3.0---------"
161+
download_binary "v3.3.0"
162+
download_build_chain "v3.3.0"
159163
LOG_INFO "------ check_standard_node---------"
160164
check_standard_node "false" "sm" "-s"
161165
LOG_INFO "------ check_wasm_node---------"
@@ -164,6 +168,13 @@ LOG_INFO "------ check_basic---------"
164168
check_basic
165169
rm -rf ./bin
166170

171+
LOG_INFO "------ download_binary: v3.2.0---------"
172+
download_build_chain "v3.2.0"
173+
download_binary "v3.2.0"
174+
LOG_INFO "------ check_standard_node---------"
175+
check_standard_node "true" "sm" "-s -A"
176+
rm -rf ./bin
177+
167178
LOG_INFO "------ download_binary: v3.1.0---------"
168179
download_build_chain "v3.1.0"
169180
download_binary "v3.1.0"

.github/workflows/workflow.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ jobs:
7878
- name: install CentOS dependencies
7979
run: yum install -y epel-release centos-release-scl wget which git openssl-devel openssl java java-devel tree
8080
- name: run build test
81-
run: /bin/bash gradlew build --info && tree ./build/reports
81+
run: /bin/bash gradlew build --info
82+
- name: run integration testing
83+
run: /bin/bash .ci/ci_check.sh && tree ./build/reports
8284
- name: upload unittest coverage
8385
run: curl -LO https://codecov.io/bash && /bin/bash ./bash
8486
# uses: codecov/codecov-action@v3
@@ -87,6 +89,4 @@ jobs:
8789
# files: ./build/reports/jacoco/test/jacocoTestReport.xml
8890
# flags: unittest
8991
# fail_ci_if_error: true
90-
# verbose: true
91-
- name: run integration testing
92-
run: /bin/bash .ci/ci_check.sh
92+
# verbose: true

build.gradle

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ext {
2525
junitVersion = '4.13.2'
2626
commonsCollections4Version = "4.4"
2727
guavaVersion = '31.1-jre'
28-
bcosSdkJniVersion = "3.3.0"
28+
bcosSdkJniVersion = "3.4.0-SNAPSHOT"
2929
slf4jApiVerison = '1.7.36'
3030
mockitoVersion = '4.8.0'
3131
gsonVersion = '2.10.1'
@@ -35,7 +35,7 @@ ext {
3535
// integrationTest.mustRunAfter test
3636
allprojects {
3737
group = 'org.fisco-bcos.java-sdk'
38-
version = '3.3.0'
38+
version = '3.4.0-SNAPSHOT'
3939

4040
apply plugin: 'maven-publish'
4141
apply plugin: 'idea'
@@ -53,12 +53,6 @@ allprojects {
5353
jacoco {
5454
toolVersion = "0.8.6"
5555
}
56-
jacocoTestReport {
57-
reports {
58-
xml.enabled true
59-
html.enabled false
60-
}
61-
}
6256
sourceCompatibility = 1.8
6357
targetCompatibility = 1.8
6458

@@ -169,11 +163,13 @@ configurations {
169163
}
170164

171165
task integrationTest(type: Test) {
166+
dependsOn test
172167
testClassesDirs = sourceSets.integrationTest.output.classesDirs
173168
classpath = sourceSets.integrationTest.runtimeClasspath
174169
}
175170

176171
task integrationWasmTest(type: Test) {
172+
dependsOn test
177173
testClassesDirs = sourceSets.integrationWasmTest.output.classesDirs
178174
classpath = sourceSets.integrationWasmTest.runtimeClasspath
179175
}
@@ -194,6 +190,22 @@ task javadocJar(type: Jar) {
194190
archiveClassifier = 'javadoc'
195191
}
196192

193+
jacocoTestReport {
194+
// The JaCoCo plugin adds a JacocoTaskExtension extension to all tasks of type Test.
195+
// Use task state to include or not task execution data
196+
// https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/TaskState.html
197+
// This declaration will be used as a closure, notice there no wrapping parenthesis
198+
executionData { tasks.withType(Test).findAll { it.jacoco.destinationFile.exists() }*.jacoco.destinationFile }
199+
reports {
200+
xml.enabled true
201+
html.enabled true
202+
}
203+
}
204+
205+
tasks.withType(Test) {
206+
finalizedBy jacocoTestReport
207+
}
208+
197209
publishing {
198210
publications {
199211
mavenJava(MavenPublication) {

src/integration-test/java/org/fisco/bcos/sdk/v3/test/BcosSDKTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ public void onError(Response errorResponse) {
336336
String txHash = receipt.getTransactionHash();
337337
BcosTransaction transaction1 = client.getTransaction(txHash, false);
338338
BcosTransactionReceipt transactionReceipt = client.getTransactionReceipt(txHash, false);
339-
if (client.getChainVersion().compareTo(EnumNodeVersion.BCOS_3_2_0) >= 0) {
339+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
340340
Assert.assertEquals(extraData, transaction1.getResult().getExtraData());
341341
Assert.assertEquals(extraData, transactionReceipt.getResult().getExtraData());
342342
}

src/integration-test/java/org/fisco/bcos/sdk/v3/test/precompiled/PrecompiledTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public void test3SystemConfigService() throws ConfigException, ContractException
161161
CryptoKeyPair cryptoKeyPair = client.getCryptoSuite().getCryptoKeyPair();
162162
SystemConfigService systemConfigService = new SystemConfigService(client, cryptoKeyPair);
163163
boolean authCheck = client.isAuthCheck();
164-
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_3_0) >= 0) {
164+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_3_0.toVersionObj()) >= 0) {
165165
String value = client.getSystemConfigByKey(AUTH_STATUS).getSystemConfig().getValue();
166166
if (Objects.equals(value, "0")) {
167167
authCheck = false;
@@ -209,7 +209,7 @@ public void test5CRUDService() throws ConfigException, ContractException {
209209
}
210210
RetCode code;
211211
Map<String, List<String>> desc;
212-
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_2_0) >= 0) {
212+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
213213
code = tableCRUDService.createTable(tableName, Common.TableKeyOrder.valueOf(0), key, valueFields);
214214
desc = tableCRUDService.descWithKeyOrder(tableName);
215215
} else {
@@ -231,7 +231,7 @@ public void test5CRUDService() throws ConfigException, ContractException {
231231
// select key
232232
Map<String, String> result = tableCRUDService.select(tableName, "key1");
233233

234-
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_2_0) >= 0) {
234+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
235235
ConditionV320 condition = new ConditionV320();
236236
condition.EQ(key, "key1");
237237
condition.setLimit(0, 10);
@@ -278,7 +278,7 @@ public void test51SyncCRUDService() throws ConfigException, ContractException, J
278278
List<String> valueFiled = new ArrayList<>();
279279
valueFiled.add("field");
280280
RetCode retCode;
281-
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_2_0) >= 0) {
281+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
282282
retCode = crudService.createTable(tableName, Common.TableKeyOrder.valueOf(0), "key", valueFiled);
283283
} else {
284284
retCode = crudService.createTable(tableName, "key", valueFiled);
@@ -355,7 +355,7 @@ public void test52AsyncCRUDService()
355355
List<String> valueFiled = new ArrayList<>();
356356
valueFiled.add("field");
357357
String key = "key";
358-
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_2_0) >= 0) {
358+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
359359
crudService.createTable(tableName, Common.TableKeyOrder.valueOf(0), key, valueFiled);
360360
} else {
361361
crudService.createTable(tableName, key, valueFiled);
@@ -424,7 +424,7 @@ public void test6KVService() throws ConfigException, ContractException {
424424
Assert.assertEquals(0, code.getCode());
425425
// desc
426426
Map<String, String> desc;
427-
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_2_0) >= 0) {
427+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_2_0.toVersionObj()) >= 0) {
428428
desc = kvTableService.descWithKeyOrder(tableName);
429429
} else {
430430
desc = kvTableService.desc(tableName);

src/integration-test/java/org/fisco/bcos/sdk/v3/test/transaction/manager/AssembleTransactionProcessorTest.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ public void test1HelloWorld() throws Exception {
103103
Assert.assertTrue(Objects.nonNull(transactionReceipt.getOutput()) && StringUtils.isNotBlank(transactionReceipt.getOutput()));
104104
Assert.assertTrue(Objects.nonNull(transactionReceipt.getReceiptHash()) && StringUtils.isNotBlank(transactionReceipt.getReceiptHash()));
105105
Assert.assertTrue(Objects.nonNull(transactionReceipt.getFrom()) && StringUtils.isNotBlank(transactionReceipt.getFrom()));
106-
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_1_0) >= 0) {
106+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_1_0.toVersionObj()) >= 0) {
107107
Assert.assertTrue(Objects.nonNull(transactionReceipt.getChecksumContractAddress()) && StringUtils.isNotBlank(transactionReceipt.getChecksumContractAddress()));
108108
Assert.assertTrue(transactionReceipt.getChecksumContractAddress().equalsIgnoreCase(transactionReceipt.getContractAddress()));
109109
}
110110
Assert.assertTrue(Objects.nonNull(transactionReceipt.getTo()));
111111

112-
if (client.getChainVersion().compareToVersion(EnumNodeVersion.BCOS_3_3_0) >= 0) {
112+
if (client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_3_0.toVersionObj()) >= 0) {
113113
Assert.assertTrue(Objects.nonNull(transactionReceipt.getInput()) && StringUtils.isNotBlank(transactionReceipt.getInput()));
114114
}
115115

@@ -554,4 +554,41 @@ public void test10EventDemo() throws Exception {
554554
Assert.assertEquals(transactionResponse3.getEventResultMap().get("Echo").size(), 4);
555555
}
556556
}
557+
558+
@Test
559+
public void test11CallWithSign() throws Exception {
560+
AssembleTransactionProcessor transactionProcessor =
561+
TransactionProcessorFactory.createAssembleTransactionProcessor(
562+
this.client, this.cryptoKeyPair, ABI_FILE, BIN_FILE);
563+
564+
if(client.getChainCompatibilityVersion().compareTo(EnumNodeVersion.BCOS_3_4_0.toVersionObj()) < 0){
565+
return;
566+
}
567+
String contractAddress = null;
568+
// deploy
569+
{
570+
List<Object> params = Lists.newArrayList();
571+
TransactionResponse response =
572+
transactionProcessor.deployByContractLoader("TestCallWithSign", params);
573+
Assert.assertEquals(response.getTransactionReceipt().getStatus(), 0);
574+
contractAddress = response.getContractAddress();
575+
Assert.assertTrue(contractAddress != null && !contractAddress.isEmpty());
576+
}
577+
578+
String abi = transactionProcessor.getContractLoader().getABIByContractName("TestCallWithSign");
579+
List<Object> params = new ArrayList<>();
580+
// getOrigin
581+
{
582+
CallResponse getOrigin = transactionProcessor.sendCallWithSign("", contractAddress, abi, "getOrigin", params);
583+
String origin = (String) getOrigin.getReturnObject().get(0);
584+
Assert.assertEquals(origin, this.cryptoKeyPair.getAddress());
585+
}
586+
587+
// getSender
588+
{
589+
CallResponse getSender = transactionProcessor.sendCallWithSign("", contractAddress, abi, "getSender", params);
590+
String sender = (String) getSender.getReturnObject().get(0);
591+
Assert.assertEquals(sender, this.cryptoKeyPair.getAddress());
592+
}
593+
}
557594
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"inputs":[],"name":"getOrigin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSender","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6080604052348015600f57600080fd5b5060908061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80635e01eb5a146037578063df1f29ee146055575b600080fd5b335b6040516001600160a01b03909116815260200160405180910390f35b32603956fea2646970667358221220bdaeaf6c681d4b660240ed4c29eed765b0a053ccd4d1cd7d969cd88a2b5f34a864736f6c634300080b0033

src/main/java/org/fisco/bcos/sdk/v3/client/Client.java

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,15 @@ static Client build(String groupId, ConfigOption configOption, long nativePointe
133133
*/
134134
Boolean isAuthCheck();
135135

136+
/**
137+
* Whether is committee enable in chain
138+
*
139+
* @return true when chain can use committee
140+
*/
141+
Boolean isEnableCommittee();
142+
136143
Boolean isSerialExecute();
144+
137145
/**
138146
* get groupId of the client
139147
*
@@ -214,6 +222,25 @@ void sendTransactionAsync(
214222
*/
215223
Call call(String node, Transaction transaction);
216224

225+
/**
226+
* Ledger operation: call contract functions without sending transaction
227+
*
228+
* @param transaction transaction instance
229+
* @param sign the sign of call data hash(to+data)
230+
* @return Call
231+
*/
232+
Call call(Transaction transaction, String sign);
233+
234+
/**
235+
* Ledger operation: call contract functions without sending transaction
236+
*
237+
* @param node the node rpc request send to
238+
* @param transaction transaction instance
239+
* @param sign the sign of call data hash(to+data)
240+
* @return Call
241+
*/
242+
Call call(String node, Transaction transaction, String sign);
243+
217244
/**
218245
* Ledger operation: async call contract functions without sending transaction
219246
*
@@ -231,6 +258,25 @@ void sendTransactionAsync(
231258
*/
232259
void callAsync(String node, Transaction transaction, RespCallback<Call> callback);
233260

261+
/**
262+
* Ledger operation: async call contract functions without sending transaction
263+
*
264+
* @param transaction transaction instance
265+
* @param sign the sign of call data hash(to+data)
266+
* @param callback the callback that will be called when receive the response
267+
*/
268+
void callAsync(Transaction transaction, String sign, RespCallback<Call> callback);
269+
270+
/**
271+
* Ledger operation: async call contract functions without sending transaction
272+
*
273+
* @param node the node rpc request send to
274+
* @param transaction transaction instance
275+
* @param sign the sign of call data hash(to+data)
276+
* @param callback the callback that will be called when receive the response
277+
*/
278+
void callAsync(String node, Transaction transaction, String sign, RespCallback<Call> callback);
279+
234280
/**
235281
* Ledger operation: get block number
236282
*
@@ -873,15 +919,20 @@ void getTransactionReceiptAsync(
873919
* get the chain compatibility version
874920
*
875921
* @return the chain compatibility version
922+
* @deprecated use getChainCompatibilityVersion instead, because older version sdk did not
923+
* recognize newer chain node
876924
*/
925+
@Deprecated
877926
EnumNodeVersion getChainVersion();
878927

928+
EnumNodeVersion.Version getChainCompatibilityVersion();
929+
879930
/**
880931
* async get the chain compatibility version
881932
*
882933
* @param versionRespCallback the callback instance
883934
*/
884-
void getChainVersionAsync(RespCallback<EnumNodeVersion> versionRespCallback);
935+
void getChainVersionAsync(RespCallback<EnumNodeVersion.Version> versionRespCallback);
885936

886937
void start();
887938

0 commit comments

Comments
 (0)