Skip to content

Commit

Permalink
feat(protocol-20): rename BumpFootprintExpiration -> ExtendFootprintTTL
Browse files Browse the repository at this point in the history
  • Loading branch information
nebolsin committed Jan 22, 2024
1 parent e6fe552 commit cf22f80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions base/lib/stellar/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -487,20 +487,20 @@ def inflation(source_account: nil)
# Bump footprint expiration operation builder.
#
# @param source_account [KeyPair, nil] the source account for the operation
# @param ledgers_to_expire [Integer, #to_i] the number of ledgers to expire (uint32)
# @param extend_to [Integer, #to_i] the number of ledgers to expire (uint32)
#
# @return [Operation] the built operation
def bump_footprint_expiration(ledgers_to_expire:, source_account: nil)
ledgers_to_expire = ledgers_to_expire.to_i
raise ArgumentError, ":ledgers_to_expire must be positive" if ledgers_to_expire < 0
raise ArgumentError, ":ledgers_to_expire is too big" unless ledgers_to_expire <= MAX_UINT32
def extend_footprint_ttl(extend_to:, source_account: nil)
extend_to = extend_to.to_i
raise ArgumentError, ":extend_to must be positive" if extend_to < 0
raise ArgumentError, ":extend_to is too big" unless extend_to <= MAX_UINT32

op = BumpFootprintExpirationOp.new(
ledgers_to_expire: ledgers_to_expire,
op = ExtendFootprintTTLOp.new(
extend_to: extend_to,
ext: Stellar::ExtensionPoint.new(0)
)

make(source_account: source_account, body: [:bump_footprint_expiration, op])
make(source_account: source_account, body: [:extend_footprint_ttl, op])
end

# Restore footprint operation builder.
Expand Down
22 changes: 11 additions & 11 deletions base/spec/lib/stellar/operation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,30 +426,30 @@
end
end

describe ".bump_footprint_expiration" do
let(:ledgers_to_expire) { 100 }
let(:attrs) { {source_account: account, ledgers_to_expire: ledgers_to_expire} }
subject(:operation) { described_class.bump_footprint_expiration(**attrs) }
describe ".extend_footprint_ttl" do
let(:extend_to) { 100 }
let(:attrs) { {source_account: account, extend_to: extend_to} }
subject(:operation) { described_class.extend_footprint_ttl(**attrs) }

include_context "XDR serializable"
its("source_account") { is_expected.to eq(account.muxed_account) }
its("body.value") { is_expected.to be_a(Stellar::BumpFootprintExpirationOp) }
its("body.value.ledgers_to_expire") { is_expected.to be_an(Integer) }
its("body.value.ledgers_to_expire") { is_expected.to eq(100) }
its("body.value") { is_expected.to be_a(Stellar::ExtendFootprintTTLOp) }
its("body.value.extend_to") { is_expected.to be_an(Integer) }
its("body.value.extend_to") { is_expected.to eq(100) }

context "when negative ledgers to expire is provided" do
let(:ledgers_to_expire) { -100 }
let(:extend_to) { -100 }

it "raises error" do
expect { operation }.to raise_error(ArgumentError, ":ledgers_to_expire must be positive")
expect { operation }.to raise_error(ArgumentError, ":extend_to must be positive")
end
end

context "when ledgers to expire is too large" do
let(:ledgers_to_expire) { 2**32 }
let(:extend_to) { 2**32 }

it "raises error" do
expect { operation }.to raise_error(ArgumentError, ":ledgers_to_expire is too big")
expect { operation }.to raise_error(ArgumentError, ":extend_to is too big")
end
end
end
Expand Down

0 comments on commit cf22f80

Please sign in to comment.