Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SlabID.Address() #435

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ func (id SlabID) AddressAsUint64() uint64 {
return binary.BigEndian.Uint64(id.address[:])
}

// Address returns the address of SlabID.
func (id SlabID) Address() Address {
return id.address
}

func (id SlabID) IndexAsUint64() uint64 {
return binary.BigEndian.Uint64(id.index[:])
}
Expand Down
11 changes: 11 additions & 0 deletions storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,17 @@ func TestSlabIDAddressAsUint64(t *testing.T) {
})
}

func TestSlabIDAddress(t *testing.T) {
t.Run("temp", func(t *testing.T) {
id := NewSlabID(Address{}, SlabIndex{1})
require.Equal(t, Address{}, id.Address())
})
t.Run("perm", func(t *testing.T) {
id := NewSlabID(Address{0, 0, 0, 0, 0, 0, 0, 1}, SlabIndex{1})
require.Equal(t, Address{0, 0, 0, 0, 0, 0, 0, 1}, id.Address())
})
}

func TestSlabIDIndexAsUint64(t *testing.T) {
t.Run("temp", func(t *testing.T) {
id := NewSlabID(Address{}, SlabIndex{})
Expand Down
Loading