Skip to content

Commit

Permalink
Merge pull request #148 from FISCO-BCOS/release-v1.0.0
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
bxq2011hust authored May 12, 2022
2 parents 5ca92a0 + 797900f commit d1a8411
Show file tree
Hide file tree
Showing 76 changed files with 1,539 additions and 4,241 deletions.
6 changes: 4 additions & 2 deletions .ci/check-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ execute_cmd() {
}

function check_codeFormat() {
go get golang.org/x/tools/cmd/goimports
go version
go install golang.org/x/tools/cmd/goimports@latest || true
go get golang.org/x/tools/cmd/goimports || true
sum=0
for file in $(git diff-index --name-status HEAD^ | grep -v D | grep -E '\.go' | awk '{print $2}'); do
checkResult=$(eval "${check_script} ${file}")
Expand Down Expand Up @@ -103,4 +105,4 @@ function check_PR_limit() {
}

check_codeFormat
check_PR_limit
# check_PR_limit
2 changes: 1 addition & 1 deletion .ci/counter/Counter.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity>=0.4.24 <0.6.11;

contract Counter {
int256 public version;
Expand Down
2 changes: 0 additions & 2 deletions .ci/ethPrecompiled/bn256.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .ci/ethPrecompiled/bn256_gm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions .ci/generate_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ LOG_INFO() {

calculate_coverage() {
# start blockchain demo
curl -LO https://raw.githubusercontent.com/FISCO-BCOS/FISCO-BCOS/master/tools/build_chain.sh && chmod u+x build_chain.sh
bash build_chain.sh -v 2.5.0 -l 127.0.0.1:4 -o nodes
latest_version=$(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)
curl -#LO https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/"${latest_version}"/build_chain.sh && chmod u+x build_chain.sh
bash build_chain.sh -l 127.0.0.1:4 -o nodes
cp nodes/127.0.0.1/sdk/* ./
bash nodes/127.0.0.1/start_all.sh

Expand Down
175 changes: 57 additions & 118 deletions .ci/hello/HelloWorld.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .ci/hello/HelloWorld.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pragma solidity>=0.4.24 <0.6.11;

contract HelloWorld {
string value;
event setValue(string);
event setValue(string v, address indexed from, address indexed to, uint256 value);
string public version = "1";

constructor() public {
Expand All @@ -13,8 +13,8 @@ contract HelloWorld {
return value;
}

function set(string v) public {
function set(string calldata v) public {
value = v;
emit setValue(v);
emit setValue(v, tx.origin, msg.sender, 1);
}
}
94 changes: 66 additions & 28 deletions .ci/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -e

start_time=10
start_time=15
macOS=
check_amop=
GOPATH_BIN=$(go env GOPATH)/bin
Expand Down Expand Up @@ -38,7 +38,8 @@ check_env(){
# export PATH="/usr/local/opt/openssl/bin:$PATH"
macOS="macOS"
fi
go get -u github.com/sqs/goreturns
go install golang.org/x/tools/cmd/goimports@latest || true
go get golang.org/x/tools/cmd/goimports || true
}

compile_and_ut()
Expand Down Expand Up @@ -87,6 +88,21 @@ cat << EOF >> "${output}"
fmt.Printf("hello.Get() failed: %v", err)
return
}
done := make(chan bool)
err = hello.WatchAllSetValue(nil, func(ret int, logs []types.Log) {
fmt.Printf("WatchAllSetValue receive statud: %d, logs: %v\n", ret, logs)
setValue, err := hello.ParseSetValue(logs[0])
if err != nil {
fmt.Printf("hello.WatchAllSetValue() failed: %v", err)
panic("WatchAllSetValue hello.WatchAllSetValue() failed")
}
fmt.Printf("receive setValue: %+v\n", *setValue)
done <- true
})
if err != nil {
fmt.Printf("hello.WatchAllSetValue() failed: %v", err)
return
}
fmt.Printf("Get: %s\n", ret)
_, _, err = hello.Set("fisco")
if err != nil {
Expand All @@ -99,9 +115,22 @@ cat << EOF >> "${output}"
return
}
fmt.Printf("Get: %s\n", ret)
<-done
from := common.HexToAddress("0x83309d045a19c44Dc3722D15A6AbD472f95866aC")
hello.WatchSetValue(nil, func(ret int, logs []types.Log) {
fmt.Printf("WatchSetValue receive statud: %d, logs: %+v\n", ret, logs)
setValue, err := hello.ParseSetValue(logs[0])
if err != nil {
fmt.Printf("hello.WatchSetValue() failed: %v", err)
panic("hello.WatchSetValue() failed")
}
fmt.Printf("WatchSetValue receive setValue: %+v\n", *setValue)
done <- true
}, from, from)
<-done
}
EOF
"${GOPATH_BIN}"/goreturns -w "${output}"
"${GOPATH_BIN}"/goimports -w "${output}"
}

generate_counter() {
Expand Down Expand Up @@ -158,7 +187,7 @@ cat << EOF >> "${output}"
}
EOF
"${GOPATH_BIN}"/goreturns -w "${output}"
"${GOPATH_BIN}"/goimports -w "${output}"
}

get_build_chain()
Expand All @@ -168,7 +197,7 @@ get_build_chain()
}

precompiled_test(){
# TODO: consensus test use getSealer first
# TODO: consensus test use getSealer first
precompileds=(config cns crud permission)
for pkg in ${precompileds[*]}; do
go test -v ./precompiled/${pkg}
Expand All @@ -178,26 +207,29 @@ precompiled_test(){
integration_std()
{
LOG_INFO "integration_std testing..."
execute_cmd "bash tools/download_solc.sh -v 0.4.25"
execute_cmd "bash tools/download_solc.sh -v 0.6.10"

bash build_chain.sh -v "${latest_version}" -l 127.0.0.1:2 -o nodes
cp nodes/127.0.0.1/sdk/* ./
bash nodes/127.0.0.1/start_all.sh && sleep "${start_time}"

# abigen std
execute_cmd "./solc-0.4.25 --bin --abi -o .ci/hello .ci/hello/HelloWorld.sol"
execute_cmd "./solc-0.6.10 --bin --abi --optimize -o .ci/hello .ci/hello/HelloWorld.sol"
execute_cmd "./abigen --bin .ci/hello/HelloWorld.bin --abi .ci/hello/HelloWorld.abi --type Hello --pkg main --out=hello.go"
generate_hello Hello hello.go
execute_cmd "go build -o hello hello.go"
execute_cmd "go build -o bn256 .ci/ethPrecompiled/bn256.go"
LOG_INFO "generate hello.go and build hello done."

bash build_chain.sh -v "${latest_version}" -l 127.0.0.1:2 -o nodes
cp nodes/127.0.0.1/sdk/* ./
bash nodes/127.0.0.1/start_all.sh && sleep "${start_time}"
precompiled_test
go test -v ./client

./hello > hello.out
if [ -z "$(grep address hello.out)" ];then LOG_ERROR "std deploy hello contract failed." && cat hello.out && exit 1;fi
if [ ! -z "$(./hello | grep failed)" ];then LOG_ERROR "call hello failed." && exit 1;fi
if [ ! -z "$(cat hello.out | grep failed)" ];then LOG_ERROR "call hello failed." && cat hello.out && exit 1;fi
# if [ ! -z "$(./bn256 | grep failed)" ];then ./bn256 && LOG_ERROR "call bn256 failed." && exit 1;fi
precompiled_test
go test -v ./client
execute_cmd "./solc-0.4.25 --bin --abi -o .ci/counter .ci/counter/Counter.sol"

execute_cmd "./solc-0.6.10 --bin --abi --optimize -o .ci/counter .ci/counter/Counter.sol"
execute_cmd "./abigen --bin .ci/counter/Counter.bin --abi .ci/counter/Counter.abi --type Counter --pkg main --out=counter.go"
generate_counter Counter counter.go
execute_cmd "go build -o counter counter.go"
Expand All @@ -208,27 +240,27 @@ integration_std()
fi
bash nodes/127.0.0.1/stop_all.sh
LOG_INFO "integration_std testing pass."

}

integration_gm()
{
LOG_INFO "integration_gm testing..."
execute_cmd "bash tools/download_solc.sh -v 0.4.25 -g"
execute_cmd "bash tools/download_solc.sh -v 0.6.10 -g"

bash build_chain.sh -v "${latest_version}" -l 127.0.0.1:2 -g -o nodes_gm
cp -r nodes_gm/127.0.0.1/sdk/* ./
bash nodes_gm/127.0.0.1/start_all.sh && sleep "${start_time}"
sed -i "s/SMCrypto=false/SMCrypto=true/g" config.toml
sed -i "s#KeyFile=\".ci/0x83309d045a19c44dc3722d15a6abd472f95866ac.pem\"#KeyFile=\".ci/sm2p256v1_0x791a0073e6dfd9dc5e5061aebc43ab4f7aa4ae8b.pem\"#g" config.toml

# abigen gm
execute_cmd "./solc-0.4.25-gm --bin --abi --overwrite -o .ci/hello .ci/hello/HelloWorld.sol"
execute_cmd "./solc-0.6.10-gm --bin --abi --overwrite -o .ci/hello .ci/hello/HelloWorld.sol"
execute_cmd "./abigen --bin .ci/hello/HelloWorld.bin --abi .ci/hello/HelloWorld.abi --type Hello --pkg main --out=hello_gm.go --smcrypto=true"
generate_hello Hello hello_gm.go
execute_cmd "go build -o hello_gm hello_gm.go"
execute_cmd "go build -o bn256_gm .ci/ethPrecompiled/bn256_gm.go"
LOG_INFO "generate hello_gm.go and build hello_gm done."

bash build_chain.sh -v "${latest_version}" -l 127.0.0.1:2 -g -o nodes_gm
cp -r nodes_gm/127.0.0.1/sdk/* ./
bash nodes_gm/127.0.0.1/start_all.sh && sleep "${start_time}"
sed -i "s/SMCrypto=false/SMCrypto=true/g" config.toml
sed -i "s#KeyFile=\".ci/0x83309d045a19c44dc3722d15a6abd472f95866ac.pem\"#KeyFile=\".ci/sm2p256v1_0x791a0073e6dfd9dc5e5061aebc43ab4f7aa4ae8b.pem\"#g" config.toml
if [ -z "$(./hello_gm | grep address)" ];then LOG_ERROR "gm deploy contract failed." && exit 1;fi
./hello_gm > hello.out
if [ ! -z "$(grep failed hello.out)" ];then LOG_ERROR "gm call hello_gm failed." && cat hello.out && exit 1;fi
Expand All @@ -243,13 +275,15 @@ integration_amop() {
LOG_INFO "amop unicast testing..."
execute_cmd "go build -o subscriber examples/amop/sub/subscriber.go"
execute_cmd "go build -o unicast_publisher examples/amop/unicast_pub/publisher.go"
./unicast_publisher 127.0.0.1:20200 hello &
./subscriber 127.0.0.1:20201 hello
./subscriber 127.0.0.1:20201 hello &
sleep 2
./unicast_publisher 127.0.0.1:20200 hello

LOG_INFO "amop broadcast testing..."
execute_cmd "go build -o broadcast_publisher examples/amop/broadcast_pub/publisher.go"
./broadcast_publisher 127.0.0.1:20200 hello1 &
./subscriber 127.0.0.1:20201 hello1
./subscriber 127.0.0.1:20201 hello1 &
sleep 2
./broadcast_publisher 127.0.0.1:20200 hello1
}

parse_params()
Expand All @@ -268,9 +302,13 @@ main()
check_env
compile_and_ut
get_build_chain
integration_std

if [ -z "${macOS}" ];then integration_gm ; fi
if [ -z "${macOS}" ];then # linux
integration_std
integration_gm
else
integration_std
fi
}

parse_params "$@"
Expand Down
Loading

0 comments on commit d1a8411

Please sign in to comment.