Skip to content

Commit

Permalink
fix Unpack failed because of tx failed (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
bxq2011hust authored May 15, 2024
1 parent fa09460 commit e65ac24
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .ci/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

set -e

c_sdk_version="v3.5.0"
c_sdk_version="v3.7.0"
chain_version="v3.7.1"
start_time=15
macOS=
ldflags="-ldflags=\"-r /usr/local/lib/\""
Expand Down Expand Up @@ -296,7 +297,7 @@ get_build_chain()
# else
# latest_version="${latest_release}"
# fi
latest_version="${c_sdk_version}"
latest_version="${chain_version}"
echo "download build_chain.sh from https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/${latest_version}/build_chain.sh"
curl -#LO "https://github.com/FISCO-BCOS/FISCO-BCOS/releases/download/${latest_version}/build_chain.sh"
chmod u+x build_chain.sh
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ jobs:
- name: generate code coverage report
run: bash .ci/generate_coverage.sh
- name: upload code coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
file: ./v3/coverage.txt
name: go-sdk code coverage
fail_ci_if_error: true
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
go: ["1.21"]
os: [ubuntu-latest]
go: ["1.21", "1.22"]
steps:
- uses: actions/checkout@v2
with:
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/workflow_macOS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: FISCO-BCOS Go-SDK GitHub Actions macOS
on:
push:
# branches-ignore:
# - "**-1.3"
# tags-ignore:
# - v1.*
paths-ignore:
- "Changelog.md"
- "README.md"
pull_request:
# branches:
# - '**'
release:
types: [published, created, edited]

jobs:
build:
name: build
runs-on: macos-latest
strategy:
matrix:
go: ["1.21", "1.22"]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
# - uses: actions/cache@v1
# id: cache
# with:
# path: deps/
# key: deps-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
# restore-keys: |
# deps-${{ runner.os }}-${{ github.ref }}-${{ hashFiles('.github/workflows/workflow.yml') }}
# deps-${{ runner.os }}-${{ github.ref }}
# deps-${{ runner.os }}-
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: check commit
if: ${{ runner.os == 'Linux' && github.base_ref != 'master' && github.event_name == 'pull_request' }}
run: bash .ci/check-commit.sh
- name: mod tidy
run: go mod tidy
- name: test all
if: ${{ runner.os == 'Linux' }}
run: bash -x .ci/integration_test.sh -a
- name: install deps
if: ${{ runner.os == 'macOS' }}
run: brew install zlib z3
- name: test without amop
if: ${{ runner.os == 'macOS' }}
run: bash .ci/integration_test.sh
2 changes: 1 addition & 1 deletion tools/download_csdk_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
install_path="/usr/local/lib/"
version="3.6.0"
OS="linux"
versions=(3.2.0 3.4.0 3.5.0 3.6.0)
versions=(3.2.0 3.4.0 3.5.0 3.6.0 3.7.0)

LOG_WARN()
{
Expand Down
3 changes: 3 additions & 0 deletions v3/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ func (c *BoundContract) TransactWithResult(opts *TransactOpts, result interface{
if err != nil {
return tx, receipt, err
}
if receipt.Status != types.Success {
return tx, receipt, fmt.Errorf("transact failed, receipt status: %d, message: %s", receipt.Status, receipt.GetErrorMessage())
}
err = c.abi.Unpack(result, method, common.FromHex(receipt.GetOutput()))
if err != nil {
return tx, receipt, err
Expand Down
23 changes: 12 additions & 11 deletions v3/precompiled/auth/auth_manager_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var (
func getClient(t *testing.T) *client.Client {
// privatekey of 0x83309d045a19c44dc3722d15a6abd472f95866ac
privateKey, _ := hex.DecodeString("b89d42f12290070f235fb8fb61dcf96e3b11516c5d4f6333f26e49bb955f8b62")
config := &client.Config{IsSMCrypto: false, GroupID: "group0",
config := &client.Config{IsSMCrypto: false, GroupID: "group0", DisableSsl: false,
PrivateKey: privateKey, Host: "127.0.0.1", Port: 20200, TLSCaFile: "./ca.crt", TLSKeyFile: "./sdk.key", TLSCertFile: "./sdk.crt"}

c, err := client.DialContext(context.Background(), config)
Expand Down Expand Up @@ -433,21 +433,22 @@ func TestVoteProposal(t *testing.T) {
service.UpdateGovernor(accountAddress_common, weight)

lastProposalNum, _ := service.ProposalCount()
lastProposalStatus, _ := service.GetProposalStatus(lastProposalNum)

agree := false
_, err := service.VoteProposal(*lastProposalNum, agree)
if err != nil {
t.Fatalf("TestVoteProposal failed: %v", err)

if err == nil {
t.Fatalf("TestVoteProposal failed")
}

proposalInfo, err := service.GetProposalInfo(lastProposalNum)
againstVoters := proposalInfo.AgainstVoters
// lastProposalStatus, _ := service.GetProposalStatus(lastProposalNum)
// proposalInfo, err := service.GetProposalInfo(lastProposalNum)
// againstVoters := proposalInfo.AgainstVoters

lastProposalNewStatus, _ := service.GetProposalStatus(lastProposalNum)
// lastProposalNewStatus, _ := service.GetProposalStatus(lastProposalNum)

t.Logf("lastProposalNum: %v\n", lastProposalNum)
t.Logf("lastProposalStatus: %v\n", lastProposalStatus)
t.Logf("againstVoters: %v\n", againstVoters)
t.Logf("lastProposalNewStatus: %v\n", lastProposalNewStatus)
// t.Logf("lastProposalNum: %v\n", lastProposalNum)
// t.Logf("lastProposalStatus: %v\n", lastProposalStatus)
// t.Logf("againstVoters: %v\n", againstVoters)
// t.Logf("lastProposalNewStatus: %v\n", lastProposalNewStatus)
}

0 comments on commit e65ac24

Please sign in to comment.