Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gocycle in chain.go #434

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
module github.com/xuperchain/xupercore

go 1.14
go 1.16

require (
github.com/ChainSafe/go-schnorrkel v0.0.0-20200626160457-b38283118816 // indirect
github.com/agiledragon/gomonkey/v2 v2.9.0
github.com/aws/aws-sdk-go v1.32.4
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
github.com/dgraph-io/badger/v3 v3.2103.1
github.com/docker/go-connections v0.4.1-0.20180821093606-97c2040d34df // indirect
github.com/docker/go-units v0.4.0
github.com/emirpasic/gods v1.12.1-0.20201118132343-79df803e554c
github.com/fsouza/go-dockerclient v1.6.0
github.com/gammazero/deque v0.1.0
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.4.3
github.com/golang/snappy v0.0.3
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
github.com/hashicorp/golang-lru v0.5.4
github.com/hyperledger/burrow v0.30.5
Expand Down Expand Up @@ -45,4 +43,10 @@ require (
google.golang.org/grpc v1.35.0
)

require (
github.com/ChainSafe/go-schnorrkel v0.0.0-20200626160457-b38283118816 // indirect
github.com/docker/go-connections v0.4.1-0.20180821093606-97c2040d34df // indirect
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa // indirect
)

replace github.com/hyperledger/burrow => github.com/xuperchain/burrow v0.30.6-0.20211229032028-fbee6a05ab0f
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrd
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/Workiva/go-datastructures v1.0.50/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/agiledragon/gomonkey/v2 v2.9.0 h1:PDiKKybR596O6FHW+RVSG0Z7uGCBNbmbUXh3uCNQ7Hc=
github.com/agiledragon/gomonkey/v2 v2.9.0/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY=
github.com/alecthomas/jsonschema v0.0.0-20190122210438-a6952de1bbe6/go.mod h1:qpebaTNSsyUn5rPSJMsfqEtDw71TTggXM6stUDI16HA=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down
5 changes: 5 additions & 0 deletions kernel/contract/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ type Response struct {
Body []byte `json:"body"`
}

// HasError checked by status
func (r *Response) HasError() bool {
return r.Status >= StatusErrorThreshold
}

// ContextConfig define the config of context
type ContextConfig struct {
State StateSandbox
Expand Down
50 changes: 50 additions & 0 deletions kernel/contract/context_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package contract

import "testing"

func TestResponse_HasError(t *testing.T) {
type fields struct {
Status int
Message string
Body []byte
}
tests := []struct {
name string
fields fields
want bool
}{
{
name: "no error",
fields: fields{
Status: StatusOK,
},
want: false,
},
{
name: "threshold error",
fields: fields{
Status: StatusErrorThreshold,
},
want: true,
},
{
name: "normal error",
fields: fields{
Status: StatusError,
},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := &Response{
Status: tt.fields.Status,
Message: tt.fields.Message,
Body: tt.fields.Body,
}
if got := r.HasError(); got != tt.want {
t.Errorf("Response.HasError() = %v, want %v", got, tt.want)
}
})
}
}
3 changes: 1 addition & 2 deletions kernel/engines/xuperos/asyncworker/asyncworker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package asyncworker

import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -222,7 +221,7 @@ type TestHelper struct {
}

func NewTestHelper() (*TestHelper, error) {
basedir, err := ioutil.TempDir("", "asyncworker-test")
basedir, err := os.MkdirTemp("", "asyncworker-test")
if err != nil {
return nil, err
}
Expand Down
Loading