Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #178 from 0xProject/marcin/naming
Browse files Browse the repository at this point in the history
fix: inaccurate function behavior and dup tests
  • Loading branch information
eitu5ami authored Feb 22, 2024
2 parents 30eb069 + 6d5aa28 commit 6113693
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 168 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/golang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,11 @@ jobs:
~/go/pkg/mod
~/.cache/go-build
key: cache-${{ hashFiles('**/go.sum') }}
- name: Start testing dependencies
run: docker-compose up -d
- name: Run tests
run: go test -race -shuffle=on -v ./internal/...
env:
RPC_GATEWAY_NODE_URL_1: ${{ secrets.RPC_GATEWAY_NODE_URL_1 }}
RPC_GATEWAY_NODE_URL_2: ${{ secrets.RPC_GATEWAY_NODE_URL_2 }}
- name: Print out docker containers' logs
if: always()
run: docker-compose logs

vulncheck:
runs-on: ubuntu-latest
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ RPC Gateway-->>Alice: {"result":[...]}

## Development

Start dependent services
```console
docker-compose up
```

Make sure the test pass
```console
go test -v ./...
Expand Down
10 changes: 0 additions & 10 deletions docker-compose.yml

This file was deleted.

2 changes: 2 additions & 0 deletions example_config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

metrics:
port: 9090 # port for prometheus metrics, served on /metrics and /

Expand Down
20 changes: 7 additions & 13 deletions internal/rpcgateway/rpcgateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,19 @@ func NewRPCGateway(config RPCGatewayConfig) (*RPCGateway, error) {
}, nil
}

func NewRPCGatewayFromConfigFile(path string) (*RPCGatewayConfig, error) {
data, err := os.ReadFile(path)
// NewRPCGatewayFromConfigFile creates an instance of RPCGateway from provided
// configuration file.
func NewRPCGatewayFromConfigFile(s string) (*RPCGateway, error) {
data, err := os.ReadFile(s)
if err != nil {
return nil, err
}

return NewRPCGatewayFromConfigBytes(data)
}

func NewRPCGatewayFromConfigBytes(configBytes []byte) (*RPCGatewayConfig, error) {
config := RPCGatewayConfig{}
var config RPCGatewayConfig

if err := yaml.Unmarshal(configBytes, &config); err != nil {
if err := yaml.Unmarshal(data, &config); err != nil {
return nil, err
}

return &config, nil
}

func NewRPCGatewayFromConfigString(configString string) (*RPCGatewayConfig, error) {
return NewRPCGatewayFromConfigBytes([]byte(configString))
return NewRPCGateway(config)
}
129 changes: 0 additions & 129 deletions internal/rpcgateway/rpcgateway_test.go

This file was deleted.

7 changes: 1 addition & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ func main() {
},
},
Action: func(cc *cli.Context) error {
config, err := rpcgateway.NewRPCGatewayFromConfigFile(cc.String("config"))
if err != nil {
return err
}

service, err := rpcgateway.NewRPCGateway(*config)
service, err := rpcgateway.NewRPCGatewayFromConfigFile(cc.String("config"))
if err != nil {
return errors.Wrap(err, "rpc-gateway failed")
}
Expand Down

0 comments on commit 6113693

Please sign in to comment.