8000 eth/address: rename null address to zero address by q9f · Pull Request #297 · q9f/eth.rb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

eth/address: rename null address to zero address #297

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

Merged
merged 3 commits into from
Dec 17, 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
12 changes: 6 additions & 6 deletions lib/eth/address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module Eth

# The {Eth::Address} class to handle checksummed Ethereum addresses.
class Address
NULL = "0x0000000000000000000000000000000000000000"
ZERO = "0x0000000000000000000000000000000000000000"

# Provides a special checksum error if EIP-55 is violated.
class CheckSumError < StandardError; end
Expand Down Expand Up @@ -52,11 +52,11 @@ def valid?
end
end

# Checks that the address is the null address.
#
# @return [Boolean] true if the address is the null address.
def null?
address == NULL
# Checks that the address is the zero address.
#
# @return [Boolean] true if the address is the zero address.
def zero?
address == ZERO
end

# Generate a checksummed address.
Expand Down
10 changes: 5 additions & 5 deletions spec/eth/address_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
end
end

describe ".null?" do
let(:null) { Address::NULL }
describe ".zero?" do
let(:zero) { Address::ZERO }
let(:addresses) do
[
"0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed",
Expand All @@ -134,13 +134,13 @@
]
end

it "returns true for the null address" do
expect(Address.new(null)).to be_null
it "returns true for the zero address" do
expect(Address.new(zero)).to be_zero
end

it "returns false for a valid address" do
addresses.each do |address|
expect(Address.new(address)).not_to be_null
expect(Address.new(address)).not_to be_zero
end
end
end
Expand Down
Loading
0