Skip to content

Commit

Permalink
fix Unpack failed because of tx failed
Browse files Browse the repository at this point in the history
  • Loading branch information
bxq2011hust committed May 15, 2024
1 parent fa09460 commit a85028c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
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 }}
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
21 changes: 11 additions & 10 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: true,
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)
// lastProposalStatus, _ := service.GetProposalStatus(lastProposalNum)

agree := false
_, err := service.VoteProposal(*lastProposalNum, agree)
if err != nil {

if err == nil || err.Error() != "AuthManagerService VoteProposal failed, err: transact failed, receipt status: 16, message: receipt error code: 16, receipt error message: revert instruction, Already voted" {
t.Fatalf("TestVoteProposal failed: %v", err)
}

proposalInfo, err := service.GetProposalInfo(lastProposalNum)
againstVoters := proposalInfo.AgainstVoters
// 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 a85028c

Please sign in to comment.