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

Commit

Permalink
accounts/abi: fix staticcheck warnings (ethereum#20358)
Browse files Browse the repository at this point in the history
* accounts/abi: fix staticcheck warnings

* accounts/abi: restore unused field for test
  • Loading branch information
fjl authored and elizabethengelman committed Dec 20, 2019
1 parent f42ce3d commit 4b528b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
2 changes: 1 addition & 1 deletion accounts/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 1 addition & 35 deletions accounts/abi/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down Expand Up @@ -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"}]}]`
Expand Down

0 comments on commit 4b528b5

Please sign in to comment.