Skip to content

Commit

Permalink
common: remove Clone
Browse files Browse the repository at this point in the history
  • Loading branch information
fjl committed Oct 6, 2021
1 parent 0b103bb commit 939af88
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
9 changes: 0 additions & 9 deletions common/types.go
Expand Up @@ -339,15 +339,6 @@ func (a Address) Value() (driver.Value, error) {
return a[:], nil
}

// Clone returns a pointer to a copy of [a] (or nil if [a] is nil)
func (a *Address) Clone() *Address {
if a == nil {
return nil
}
cpy := *a
return &cpy
}

// ImplementsGraphQLType returns true if Hash implements the specified GraphQL type.
func (a Address) ImplementsGraphQLType(name string) bool { return name == "Address" }

Expand Down
23 changes: 0 additions & 23 deletions common/types_test.go
Expand Up @@ -453,29 +453,6 @@ func TestAddress_Format(t *testing.T) {
}
}

func TestCopyAddress(t *testing.T) {
addrBytes := make([]byte, 20)
addr := BytesToAddress(addrBytes)
if !bytes.Equal(addr.Bytes(), addrBytes) {
t.Fatalf("Expected original address bytes to be unmodified")
}
addrPtr := &addr
cpy := addrPtr.Clone()
cpy.SetBytes([]byte("deadbeef"))
if !bytes.Equal(addr.Bytes(), addrBytes) {
t.Fatal("Expected original address bytes to be unmodified")
}
if bytes.Equal(cpy.Bytes(), addrBytes) {
t.Fatal("Expected modified address to no longer match original byte slice")
}

var nilAddr *Address
copiedNilAddr := nilAddr.Clone()
if copiedNilAddr != nil {
t.Fatalf("Expected copied nil address to be nil, but got %s", copiedNilAddr)
}
}

func TestHash_Format(t *testing.T) {
var hash Hash
hash.SetBytes([]byte{
Expand Down

0 comments on commit 939af88

Please sign in to comment.