From 66d19188f66a9253c9b92939eab5c90fddf00908 Mon Sep 17 00:00:00 2001 From: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Date: Tue, 24 Nov 2020 16:43:08 +0100 Subject: [PATCH] update tools configs (#611) * update tools configs * minor updates --- .golangci.yml | 8 ++++++++ .mergify.yml | 10 ++++++++++ codecov.yml | 18 ++++++++++++------ tests-solidity/suites/basic/main.go | 20 ++++++++++++-------- utils/int.go | 5 +++++ 5 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 .mergify.yml diff --git a/.golangci.yml b/.golangci.yml index 1cce5232..e5419ed2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -34,6 +34,9 @@ linters: - unused - unparam - misspell + # TODO: address these lint issues + # - wsl + # - nolintlint issues: exclude-rules: @@ -63,3 +66,8 @@ linters-settings: maligned: # print struct with more effective memory layout or not, false by default suggest-new: true + nolintlint: + allow-unused: false + allow-leading-space: true + require-explanation: false + require-specific: false diff --git a/.mergify.yml b/.mergify.yml new file mode 100644 index 00000000..81e07508 --- /dev/null +++ b/.mergify.yml @@ -0,0 +1,10 @@ +pull_request_rules: + - name: automerge to master with label automerge and branch protection passing + conditions: + - "#approved-reviews-by>1" + - base=development + - label=automerge + actions: + merge: + method: squash + strict: true diff --git a/codecov.yml b/codecov.yml index 74317c50..e754fadc 100644 --- a/codecov.yml +++ b/codecov.yml @@ -15,15 +15,19 @@ coverage: threshold: 1% # allow this much decrease on project app: target: 70% - flags: app + flags: + - app modules: - target: 50% - flags: modules + target: 70% + flags: + - modules core: target: 50% - flags: core - clients: - flags: clients + flags: + - core + client: + flags: + - client changes: false comment: @@ -57,4 +61,6 @@ ignore: - "x/faucet" - "**/*.pb.go" - "types/*.pb.go" + - "tests/*" - "x/**/*.pb.go" + - "scripts/" diff --git a/tests-solidity/suites/basic/main.go b/tests-solidity/suites/basic/main.go index 93d32768..9f819066 100644 --- a/tests-solidity/suites/basic/main.go +++ b/tests-solidity/suites/basic/main.go @@ -49,12 +49,14 @@ func createRequest(method string, params interface{}) Request { func getTransactionReceipt(hash hexutil.Bytes) (map[string]interface{}, error) { param := []string{hash.String()} + rpcRes, err := call("eth_getTransactionReceipt", param) if err != nil { return nil, err } receipt := make(map[string]interface{}) + err = json.Unmarshal(rpcRes.Result, &receipt) if err != nil { return nil, err @@ -74,10 +76,13 @@ func waitForReceipt(hash hexutil.Bytes) (map[string]interface{}, error) { time.Sleep(time.Second) } + return nil, errors.New("cound not find transaction on chain") } func call(method string, params interface{}) (*Response, error) { + var rpcRes *Response + if HOST == "" { HOST = "http://localhost:8545" } @@ -87,7 +92,6 @@ func call(method string, params interface{}) (*Response, error) { return nil, err } - var rpcRes *Response time.Sleep(1000000 * time.Nanosecond) /* #nosec */ res, err := http.Post(HOST, "application/json", bytes.NewBuffer(req)) @@ -97,13 +101,12 @@ func call(method string, params interface{}) (*Response, error) { decoder := json.NewDecoder(res.Body) rpcRes = new(Response) - err = decoder.Decode(&rpcRes) - if err != nil { + + if err := decoder.Decode(&rpcRes); err != nil { return nil, err } - err = res.Body.Close() - if err != nil { + if err := res.Body.Close(); err != nil { return nil, err } @@ -111,6 +114,8 @@ func call(method string, params interface{}) (*Response, error) { } func main() { + var hash hexutil.Bytes + dat, err := ioutil.ReadFile(HOME + "/counter/counter_sol.bin") if err != nil { log.Fatal(err) @@ -126,11 +131,10 @@ func main() { log.Fatal(err) } - var hash hexutil.Bytes - err = json.Unmarshal(txRPCRes.Result, &hash) - if err != nil { + if err := json.Unmarshal(txRPCRes.Result, &hash); err != nil { log.Fatal(err) } + fmt.Println("Contract TX hash: ", hash) receipt, err := waitForReceipt(hash) diff --git a/utils/int.go b/utils/int.go index 5a493e59..c3e20980 100644 --- a/utils/int.go +++ b/utils/int.go @@ -8,6 +8,7 @@ func MarshalBigInt(i *big.Int) (string, error) { if err != nil { return "", err } + return string(bz), nil } @@ -18,16 +19,19 @@ func MustMarshalBigInt(i *big.Int) string { if err != nil { panic(err) } + return str } // UnmarshalBigInt unmarshalls string from *big.Int func UnmarshalBigInt(s string) (*big.Int, error) { ret := new(big.Int) + err := ret.UnmarshalText([]byte(s)) if err != nil { return nil, err } + return ret, nil } @@ -38,5 +42,6 @@ func MustUnmarshalBigInt(s string) *big.Int { if err != nil { panic(err) } + return ret }