From 36a684ca1efe15efbfefc2f0b22abeb4c0039e5a Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 21 Nov 2019 22:22:47 +0100 Subject: [PATCH] accounts/abi: fix staticcheck warnings (#20358) * accounts/abi: fix staticcheck warnings * accounts/abi: restore unused field for test --- accounts/abi/abi_test.go | 2 +- accounts/abi/event_test.go | 36 +----------------------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/accounts/abi/abi_test.go b/accounts/abi/abi_test.go index ca19c5801..61ab70eb8 100644 --- a/accounts/abi/abi_test.go +++ b/accounts/abi/abi_test.go @@ -927,7 +927,7 @@ func TestABI_MethodById(t *testing.T) { } b := fmt.Sprintf("%v", m2) if a != b { - t.Errorf("Method %v (id %v) not 'findable' by id in ABI", name, common.ToHex(m.ID())) + t.Errorf("Method %v (id %x) not 'findable' by id in ABI", name, m.ID()) } } // Also test empty diff --git a/accounts/abi/event_test.go b/accounts/abi/event_test.go index 792e26762..090b9217d 100644 --- a/accounts/abi/event_test.go +++ b/accounts/abi/event_test.go @@ -173,7 +173,7 @@ func TestEventTupleUnpack(t *testing.T) { type EventTransferWithTag struct { // this is valid because `value` is not exportable, // so value is only unmarshalled into `Value1`. - value *big.Int + value *big.Int //lint:ignore U1000 unused field is part of test Value1 *big.Int `abi:"value"` } @@ -354,40 +354,6 @@ func unpackTestEventData(dest interface{}, hexData string, jsonEvent []byte, ass return a.Unpack(dest, "e", data) } -/* -Taken from -https://github.com/ethereum/go-ethereum/pull/15568 -*/ - -type testResult struct { - Values [2]*big.Int - Value1 *big.Int - Value2 *big.Int -} - -type testCase struct { - definition string - want testResult -} - -func (tc testCase) encoded(intType, arrayType Type) []byte { - var b bytes.Buffer - if tc.want.Value1 != nil { - val, _ := intType.pack(reflect.ValueOf(tc.want.Value1)) - b.Write(val) - } - - if !reflect.DeepEqual(tc.want.Values, [2]*big.Int{nil, nil}) { - val, _ := arrayType.pack(reflect.ValueOf(tc.want.Values)) - b.Write(val) - } - if tc.want.Value2 != nil { - val, _ := intType.pack(reflect.ValueOf(tc.want.Value2)) - b.Write(val) - } - return b.Bytes() -} - // TestEventUnpackIndexed verifies that indexed field will be skipped by event decoder. func TestEventUnpackIndexed(t *testing.T) { definition := `[{"name": "test", "type": "event", "inputs": [{"indexed": true, "name":"value1", "type":"uint8"},{"indexed": false, "name":"value2", "type":"uint8"}]}]`