From 12bdcfc5cea7f93067d948f400c7edebce3a4c5f Mon Sep 17 00:00:00 2001 From: Ian Pun Date: Fri, 2 Feb 2024 16:21:34 -0800 Subject: [PATCH] fix linter --- cmd/flow-schema/flow-schema.go | 6 +++++- gateway/emulator.go | 16 ---------------- state_test.go | 3 ++- tests/testnet_test.go | 7 +++++-- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/cmd/flow-schema/flow-schema.go b/cmd/flow-schema/flow-schema.go index 833f8f7af..3281e8038 100644 --- a/cmd/flow-schema/flow-schema.go +++ b/cmd/flow-schema/flow-schema.go @@ -60,7 +60,11 @@ func main() { os.Exit(1) } } else { - os.WriteFile(path, json, 0644) + + if err := os.WriteFile(path, json, 0644); err != nil { + fmt.Println(err) + os.Exit(1) + } } } diff --git a/gateway/emulator.go b/gateway/emulator.go index 7e6b0bbe1..eb5e20cfe 100644 --- a/gateway/emulator.go +++ b/gateway/emulator.go @@ -30,7 +30,6 @@ import ( "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go-sdk/crypto" - flowGo "github.com/onflow/flow-go/model/flow" "github.com/rs/zerolog" "google.golang.org/grpc/status" ) @@ -255,21 +254,6 @@ func messageToCadenceValue(m []byte) (cadence.Value, error) { return v, nil } -func convertBlock(block *flowGo.Block) *flow.Block { - return &flow.Block{ - BlockHeader: flow.BlockHeader{ - ID: flow.Identifier(block.Header.ID()), - ParentID: flow.Identifier(block.Header.ParentID), - Height: block.Header.Height, - Timestamp: block.Header.Timestamp, - }, - BlockPayload: flow.BlockPayload{ - CollectionGuarantees: nil, - Seals: nil, - }, - } -} - func (g *EmulatorGateway) GetEvents( eventType string, startHeight uint64, diff --git a/state_test.go b/state_test.go index 1e52c4381..464f7264d 100644 --- a/state_test.go +++ b/state_test.go @@ -345,7 +345,8 @@ func generateAliasesComplexProject() State { func Test_GetContractsByNameSimple(t *testing.T) { p := generateSimpleProject() path := filepath.FromSlash("../hungry-kitties/cadence/contracts/NonFungibleToken.cdc") - af.WriteFile(path, []byte("pub contract{}"), os.ModePerm) + err := af.WriteFile(path, []byte("pub contract{}"), os.ModePerm) + require.NoError(t, err) contracts, err := p.DeploymentContractsByNetwork(config.EmulatorNetwork) require.NoError(t, err) diff --git a/tests/testnet_test.go b/tests/testnet_test.go index 6758882fa..e78e21da8 100644 --- a/tests/testnet_test.go +++ b/tests/testnet_test.go @@ -138,12 +138,15 @@ var testnet = config.TestnetNetwork.Name func Test_Foo(t *testing.T) { _, st, _, rw, _ := initTestnet(t) - rw.WriteFile("test", []byte("foo"), 0644) + err := rw.WriteFile("test", []byte("foo"), 0644) + require.NoError(t, err) out, _ := rw.ReadFile("test") assert.Equal(t, out, []byte("foo")) - rw.WriteFile("test", []byte("bar"), 0644) + err = rw.WriteFile("test", []byte("bar"), 0644) + require.NoError(t, err) + out, _ = st.ReadFile("test") assert.Equal(t, out, []byte("bar")) }