Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoriver committed Sep 21, 2023
1 parent 806d1d0 commit 6bb111f
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 43 deletions.
14 changes: 7 additions & 7 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strconv"
"testing"

Expand Down Expand Up @@ -54,7 +54,7 @@ func TestOpenEthTraceAPI_EmptyTrace(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*json.RawMessage)

file, err := ioutil.ReadFile(
file, err := os.ReadFile(
"testdata/trace_block_empty.json",
)
assert.NoError(t, err)
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestTraceBlockByHash(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*json.RawMessage)

file, err := ioutil.ReadFile(
file, err := os.ReadFile(
"testdata/block_trace_0xd88e8376ec3eef899d9fbc6349e8330ebfc102b245fef784a999ac854091cb64.json",
)
assert.NoError(t, err)
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestOpenEthTraceAPI_1Txn(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*json.RawMessage)

file, err := ioutil.ReadFile(
file, err := os.ReadFile(
"testdata/trace_block_1_tx.json",
)
assert.NoError(t, err)
Expand Down Expand Up @@ -206,7 +206,7 @@ func TestOpenEthTraceAPI_MultiTxns(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*json.RawMessage)

file, err := ioutil.ReadFile(
file, err := os.ReadFile(
"testdata/trace_block_many_traces.json",
)
assert.NoError(t, err)
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestBalance(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(**types.Header)

file, err := ioutil.ReadFile("testdata/block_10992.json")
file, err := os.ReadFile("testdata/block_10992.json")
assert.NoError(t, err)
err = json.Unmarshal(file, &r)
assert.NoError(t, err)
Expand Down Expand Up @@ -308,7 +308,7 @@ func TestBalance(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*string)
var expected map[string]interface{}
file, err := ioutil.ReadFile("testdata/call_balance_token_10992.json")
file, err := os.ReadFile("testdata/call_balance_token_10992.json")
assert.NoError(t, err)

err = json.Unmarshal(file, &expected)
Expand Down
4 changes: 2 additions & 2 deletions client/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package client
import (
"encoding/json"
"fmt"
"io/ioutil"
"math/big"
"os"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -47,7 +47,7 @@ func GetTraceConfig(useNative bool) (*tracers.TraceConfig, error) {
}

func loadTraceConfig() (*tracers.TraceConfig, error) {
loadedFile, err := ioutil.ReadFile(tracerPath)
loadedFile, err := os.ReadFile(tracerPath)
if err != nil {
return nil, fmt.Errorf("could not load tracer file: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ package client

import (
"encoding/json"
"log"
"math/big"
"strings"
"log"

"github.com/coinbase/rosetta-geth-sdk/configuration"

Expand Down Expand Up @@ -181,7 +181,7 @@ func GenerateErc20TransferData(toAddress string, value *big.Int) []byte {
}

func (tx *LoadedTransaction) GetMint() *big.Int {
if tx.Mint == "" {
if tx.Mint == "" {
return big.NewInt(0)
}
hexString := tx.Mint[2:]
Expand Down
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIO
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6 h1:1d9pzdbkth4D9AX6ndKSl7of3UTV0RYl3z64U2dXMGo=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah4HI848JfFxHt+iPb26b4zyfspmqY0/8=
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
Expand Down
44 changes: 22 additions & 22 deletions services/block_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package services
import (
"context"
"encoding/json"
"io/ioutil"
"log"
"os"

EthTypes "github.com/ethereum/go-ethereum/core/types"

Expand All @@ -40,11 +40,11 @@ import (
)

const (
hsh = "0xd83b1dcf7d47c4115d78ce0361587604e8157591b118bd64ada02e86c9d5ca7e"
hsh = "0xd83b1dcf7d47c4115d78ce0361587604e8157591b118bd64ada02e86c9d5ca7e"
)

func loadTokenWhiteList() []configuration.Token {
content, err := ioutil.ReadFile("testdata/tokenList.json")
content, err := os.ReadFile("testdata/tokenList.json")
if err != nil {
log.Fatal("Error when opening file: ", err)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func TestBlockService_Online(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*json.RawMessage)

file, err := ioutil.ReadFile("testdata/block_10992.json")
file, err := os.ReadFile("testdata/block_10992.json")
assert.NoError(t, err)

*r = json.RawMessage(file)
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestBlockService_Online(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*json.RawMessage)

file, err := ioutil.ReadFile("testdata/block_10992.json")
file, err := os.ReadFile("testdata/block_10992.json")
assert.NoError(t, err)

*r = json.RawMessage(file)
Expand Down Expand Up @@ -221,7 +221,7 @@ func TestBlockService_Online(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*json.RawMessage)

file, err := ioutil.ReadFile("testdata/block_10994.json")
file, err := os.ReadFile("testdata/block_10994.json")
assert.NoError(t, err)

*r = json.RawMessage(file)
Expand All @@ -230,15 +230,15 @@ func TestBlockService_Online(t *testing.T) {

m := make(map[string][]*client.FlatCall)
m[hsh] = append(m[hsh], &client.FlatCall{
Type: "call",
Type: "call",
BeforeEVMTransfers: nil,
AfterEVMTransfers: nil,
From: common.HexToAddress("0x1234"),
To: common.HexToAddress("0x4566"),
Value: big.NewInt(900000),
GasUsed: big.NewInt(10000),
Revert: false,
ErrorMessage: "",
From: common.HexToAddress("0x1234"),
To: common.HexToAddress("0x4566"),
Value: big.NewInt(900000),
GasUsed: big.NewInt(10000),
Revert: false,
ErrorMessage: "",
})

// TraceBlockByHash returns valid traces map
Expand Down Expand Up @@ -279,12 +279,12 @@ func TestBlockService_Online(t *testing.T) {
OperationIdentifier: &RosettaTypes.OperationIdentifier{
Index: 0,
},
Type: AssetTypes.CallOpType,
Status: RosettaTypes.String(AssetTypes.SuccessStatus),
Type: AssetTypes.CallOpType,
Status: RosettaTypes.String(AssetTypes.SuccessStatus),
Account: &RosettaTypes.AccountIdentifier{
Address: mock.Anything,
},
Amount: client.Amount(big.NewInt(-1), AssetTypes.Currency),
Amount: client.Amount(big.NewInt(-1), AssetTypes.Currency),
},

{
Expand Down Expand Up @@ -351,7 +351,7 @@ func TestBlockService_Online(t *testing.T) {
func(args mock.Arguments) {
r := args.Get(1).(*json.RawMessage)

file, err := ioutil.ReadFile("testdata/block_10994.json")
file, err := os.ReadFile("testdata/block_10994.json")
assert.NoError(t, err)

*r = json.RawMessage(file)
Expand Down Expand Up @@ -440,12 +440,12 @@ func TestBlockService_Online(t *testing.T) {
OperationIdentifier: &RosettaTypes.OperationIdentifier{
Index: 0,
},
Type: AssetTypes.FeeOpType,
Status: RosettaTypes.String(AssetTypes.SuccessStatus),
Type: AssetTypes.FeeOpType,
Status: RosettaTypes.String(AssetTypes.SuccessStatus),
Account: &RosettaTypes.AccountIdentifier{
Address: "0x0000000000000000000000000000000000001234",
},
Amount: client.Amount(big.NewInt(-10000), AssetTypes.Currency),
Amount: client.Amount(big.NewInt(-10000), AssetTypes.Currency),
},

{
Expand Down Expand Up @@ -489,9 +489,9 @@ func TestBlockService_Online(t *testing.T) {
"GetRosettaConfig",
).Return(
configuration.RosettaConfig{
FilterTokens: true,
FilterTokens: true,
TokenWhiteList: loadTokenWhiteList(),
TracePrefix: "arbtrace",
TracePrefix: "arbtrace",
},
)

Expand Down
3 changes: 2 additions & 1 deletion services/construction/combine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ package construction
import (
"context"
"encoding/json"
AssetTypes "github.com/coinbase/rosetta-geth-sdk/types"
"testing"

AssetTypes "github.com/coinbase/rosetta-geth-sdk/types"

"github.com/coinbase/rosetta-sdk-go/types"
"github.com/stretchr/testify/assert"
)
Expand Down
1 change: 1 addition & 0 deletions services/construction/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"math/big"

"errors"

"github.com/coinbase/rosetta-geth-sdk/client"
sdkTypes "github.com/coinbase/rosetta-geth-sdk/types"
goEthTypes "github.com/ethereum/go-ethereum/core/types"
Expand Down
1 change: 0 additions & 1 deletion services/construction/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
// ConstructionSubmit implements /construction/submit endpoint.
//
// Submit a pre-signed Transaction to the node.
//
func (s *APIService) ConstructionSubmit(
ctx context.Context,
req *types.ConstructionSubmitRequest,
Expand Down
15 changes: 8 additions & 7 deletions services/mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
package services

import (
evmClient "github.com/coinbase/rosetta-geth-sdk/client"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
"math/big"
"testing"
)
"math/big"
"testing"

evmClient "github.com/coinbase/rosetta-geth-sdk/client"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/assert"
)

func TestParseTransferOps(t *testing.T) {
a1 := common.HexToAddress("0xdd4b76b0316dcafa98862a12a92791ac9426a0e2")
Expand Down Expand Up @@ -180,7 +181,7 @@ func TestParseTransferOpsFirstIndexRelatedOps(t *testing.T) {
From: &a2,
Purpose: "refund",
To: &a4,
Value: big.NewInt( 7441300000000),
Value: big.NewInt(7441300000000),
},
&evmClient.EVMTransfer{
From: &a2,
Expand Down

0 comments on commit 6bb111f

Please sign in to comment.