diff --git a/lib/xdr/transactions/operation_body.ex b/lib/xdr/transactions/operation_body.ex index 0b320e0..d5c0d0f 100644 --- a/lib/xdr/transactions/operation_body.ex +++ b/lib/xdr/transactions/operation_body.ex @@ -19,7 +19,7 @@ defmodule StellarBase.XDR.OperationBody do alias StellarBase.XDR.Operations.{ AllowTrust, BeginSponsoringFutureReserves, - BumpFootprintExpiration, + ExtendFootprintTTL, BumpSequence, ChangeTrust, Clawback, @@ -69,7 +69,7 @@ defmodule StellarBase.XDR.OperationBody do LIQUIDITY_POOL_DEPOSIT: LiquidityPoolDeposit, LIQUIDITY_POOL_WITHDRAW: LiquidityPoolWithdraw, INVOKE_HOST_FUNCTION: InvokeHostFunction, - BUMP_FOOTPRINT_EXPIRATION: BumpFootprintExpiration, + EXTEND_FOOTPRINT_TTL: ExtendFootprintTTL, RESTORE_FOOTPRINT: RestoreFootprint ] @@ -98,7 +98,7 @@ defmodule StellarBase.XDR.OperationBody do | LiquidityPoolDeposit.t() | LiquidityPoolWithdraw.t() | InvokeHostFunction.t() - | BumpFootprintExpiration.t() + | ExtendFootprintTTL.t() | RestoreFootprint.t() @type t :: %__MODULE__{value: value(), type: OperationType.t()} diff --git a/lib/xdr/transactions/operation_result_tr.ex b/lib/xdr/transactions/operation_result_tr.ex index 518884f..2537bfe 100644 --- a/lib/xdr/transactions/operation_result_tr.ex +++ b/lib/xdr/transactions/operation_result_tr.ex @@ -16,7 +16,7 @@ defmodule StellarBase.XDR.OperationResultTr do AccountMergeResult, AllowTrustResult, BeginSponsoringFutureReservesResult, - BumpFootprintExpirationResult, + ExtendFootprintTTLResult, BumpSequenceResult, ChangeTrustResult, ClaimClaimableBalanceResult, @@ -67,7 +67,7 @@ defmodule StellarBase.XDR.OperationResultTr do LIQUIDITY_POOL_DEPOSIT: LiquidityPoolDepositResult, LIQUIDITY_POOL_WITHDRAW: LiquidityPoolWithdrawResult, INVOKE_HOST_FUNCTION: InvokeHostFunctionResult, - BUMP_FOOTPRINT_EXPIRATION: BumpFootprintExpirationResult, + EXTEND_FOOTPRINT_TTL: ExtendFootprintTTLResult, RESTORE_FOOTPRINT: RestoreFootprintResult ] @@ -96,7 +96,7 @@ defmodule StellarBase.XDR.OperationResultTr do | LiquidityPoolDepositResult.t() | LiquidityPoolWithdrawResult.t() | InvokeHostFunctionResult.t() - | BumpFootprintExpirationResult.t() + | ExtendFootprintTTLResult.t() | RestoreFootprintResult.t() @type t :: %__MODULE__{value: value(), type: OperationType.t()} diff --git a/lib/xdr/transactions/operation_type.ex b/lib/xdr/transactions/operation_type.ex index 50e0e8b..99a56d6 100644 --- a/lib/xdr/transactions/operation_type.ex +++ b/lib/xdr/transactions/operation_type.ex @@ -36,7 +36,7 @@ defmodule StellarBase.XDR.OperationType do LIQUIDITY_POOL_DEPOSIT: 22, LIQUIDITY_POOL_WITHDRAW: 23, INVOKE_HOST_FUNCTION: 24, - BUMP_FOOTPRINT_EXPIRATION: 25, + EXTEND_FOOTPRINT_TTL: 25, RESTORE_FOOTPRINT: 26 ] diff --git a/lib/xdr/transactions/operations/bump_footprint_expiration.ex b/lib/xdr/transactions/operations/bump_footprint_expiration.ex deleted file mode 100644 index 53f962f..0000000 --- a/lib/xdr/transactions/operations/bump_footprint_expiration.ex +++ /dev/null @@ -1,73 +0,0 @@ -defmodule StellarBase.XDR.Operations.BumpFootprintExpiration do - @moduledoc """ - Automatically generated by xdrgen - DO NOT EDIT or your changes may be overwritten - - Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr - - Representation of Stellar `BumpFootprintExpiration` type. - """ - - @behaviour XDR.Declaration - - alias StellarBase.XDR.{ - ExtensionPoint, - UInt32 - } - - @struct_spec XDR.Struct.new( - ext: ExtensionPoint, - ledgers_to_expire: UInt32 - ) - - @type ext_type :: ExtensionPoint.t() - @type ledgers_to_expire_type :: UInt32.t() - - @type t :: %__MODULE__{ext: ext_type(), ledgers_to_expire: ledgers_to_expire_type()} - - defstruct [:ext, :ledgers_to_expire] - - @spec new(ext :: ext_type(), ledgers_to_expire :: ledgers_to_expire_type()) :: t() - def new( - %ExtensionPoint{} = ext, - %UInt32{} = ledgers_to_expire - ), - do: %__MODULE__{ext: ext, ledgers_to_expire: ledgers_to_expire} - - @impl true - def encode_xdr(%__MODULE__{ext: ext, ledgers_to_expire: ledgers_to_expire}) do - [ext: ext, ledgers_to_expire: ledgers_to_expire] - |> XDR.Struct.new() - |> XDR.Struct.encode_xdr() - end - - @impl true - def encode_xdr!(%__MODULE__{ext: ext, ledgers_to_expire: ledgers_to_expire}) do - [ext: ext, ledgers_to_expire: ledgers_to_expire] - |> XDR.Struct.new() - |> XDR.Struct.encode_xdr!() - end - - @impl true - def decode_xdr(bytes, struct \\ @struct_spec) - - def decode_xdr(bytes, struct) do - case XDR.Struct.decode_xdr(bytes, struct) do - {:ok, {%XDR.Struct{components: [ext: ext, ledgers_to_expire: ledgers_to_expire]}, rest}} -> - {:ok, {new(ext, ledgers_to_expire), rest}} - - error -> - error - end - end - - @impl true - def decode_xdr!(bytes, struct \\ @struct_spec) - - def decode_xdr!(bytes, struct) do - {%XDR.Struct{components: [ext: ext, ledgers_to_expire: ledgers_to_expire]}, rest} = - XDR.Struct.decode_xdr!(bytes, struct) - - {new(ext, ledgers_to_expire), rest} - end -end diff --git a/lib/xdr/transactions/operations/extend_footprint_ttl.ex b/lib/xdr/transactions/operations/extend_footprint_ttl.ex new file mode 100644 index 0000000..6a39c3f --- /dev/null +++ b/lib/xdr/transactions/operations/extend_footprint_ttl.ex @@ -0,0 +1,73 @@ +defmodule StellarBase.XDR.Operations.ExtendFootprintTTL do + @moduledoc """ + Automatically generated by xdrgen + DO NOT EDIT or your changes may be overwritten + + Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr + + Representation of Stellar `ExtendFootprintTTL` type. + """ + + @behaviour XDR.Declaration + + alias StellarBase.XDR.{ + ExtensionPoint, + UInt32 + } + + @struct_spec XDR.Struct.new( + ext: ExtensionPoint, + extend_to: UInt32 + ) + + @type ext_type :: ExtensionPoint.t() + @type extend_to_type :: UInt32.t() + + @type t :: %__MODULE__{ext: ext_type(), extend_to: extend_to_type()} + + defstruct [:ext, :extend_to] + + @spec new(ext :: ext_type(), extend_to :: extend_to_type()) :: t() + def new( + %ExtensionPoint{} = ext, + %UInt32{} = extend_to + ), + do: %__MODULE__{ext: ext, extend_to: extend_to} + + @impl true + def encode_xdr(%__MODULE__{ext: ext, extend_to: extend_to}) do + [ext: ext, extend_to: extend_to] + |> XDR.Struct.new() + |> XDR.Struct.encode_xdr() + end + + @impl true + def encode_xdr!(%__MODULE__{ext: ext, extend_to: extend_to}) do + [ext: ext, extend_to: extend_to] + |> XDR.Struct.new() + |> XDR.Struct.encode_xdr!() + end + + @impl true + def decode_xdr(bytes, struct \\ @struct_spec) + + def decode_xdr(bytes, struct) do + case XDR.Struct.decode_xdr(bytes, struct) do + {:ok, {%XDR.Struct{components: [ext: ext, extend_to: extend_to]}, rest}} -> + {:ok, {new(ext, extend_to), rest}} + + error -> + error + end + end + + @impl true + def decode_xdr!(bytes, struct \\ @struct_spec) + + def decode_xdr!(bytes, struct) do + {%XDR.Struct{components: [ext: ext, extend_to: extend_to]}, rest} = + XDR.Struct.decode_xdr!(bytes, struct) + + {new(ext, extend_to), rest} + end +end diff --git a/lib/xdr/transactions/operations/bump_footprint_expiration_result.ex b/lib/xdr/transactions/operations/extend_footprint_ttl_result.ex similarity index 63% rename from lib/xdr/transactions/operations/bump_footprint_expiration_result.ex rename to lib/xdr/transactions/operations/extend_footprint_ttl_result.ex index b4ced23..999d51c 100644 --- a/lib/xdr/transactions/operations/bump_footprint_expiration_result.ex +++ b/lib/xdr/transactions/operations/extend_footprint_ttl_result.ex @@ -1,34 +1,34 @@ -defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResult do +defmodule StellarBase.XDR.Operations.ExtendFootprintTTLResult do @moduledoc """ Automatically generated by xdrgen DO NOT EDIT or your changes may be overwritten Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr - Representation of Stellar `BumpFootprintExpirationResult` type. + Representation of Stellar `ExtendFootprintTTLResult` type. """ @behaviour XDR.Declaration alias StellarBase.XDR.Void - alias StellarBase.XDR.Operations.BumpFootprintExpirationResultCode + alias StellarBase.XDR.Operations.ExtendFootprintTTLResultCode @arms [ - BUMP_FOOTPRINT_EXPIRATION_SUCCESS: Void, - BUMP_FOOTPRINT_EXPIRATION_MALFORMED: Void, - BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: Void, - BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: Void + EXTEND_FOOTPRINT_TTL_SUCCESS: Void, + EXTEND_FOOTPRINT_TTL_MALFORMED: Void, + EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED: Void, + EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: Void ] @type value :: Void.t() - @type t :: %__MODULE__{value: value(), type: BumpFootprintExpirationResultCode.t()} + @type t :: %__MODULE__{value: value(), type: ExtendFootprintTTLResultCode.t()} defstruct [:value, :type] - @spec new(value :: value(), type :: BumpFootprintExpirationResultCode.t()) :: t() - def new(value, %BumpFootprintExpirationResultCode{} = type), + @spec new(value :: value(), type :: ExtendFootprintTTLResultCode.t()) :: t() + def new(value, %ExtendFootprintTTLResultCode{} = type), do: %__MODULE__{value: value, type: type} @impl true @@ -66,7 +66,7 @@ defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResult do @spec union_spec() :: XDR.Union.t() defp union_spec do nil - |> BumpFootprintExpirationResultCode.new() + |> ExtendFootprintTTLResultCode.new() |> XDR.Union.new(@arms) end end diff --git a/lib/xdr/transactions/operations/bump_footprint_expiration_result_code.ex b/lib/xdr/transactions/operations/extend_footprint_ttl_result_code.ex similarity index 72% rename from lib/xdr/transactions/operations/bump_footprint_expiration_result_code.ex rename to lib/xdr/transactions/operations/extend_footprint_ttl_result_code.ex index 757e56e..57ca708 100644 --- a/lib/xdr/transactions/operations/bump_footprint_expiration_result_code.ex +++ b/lib/xdr/transactions/operations/extend_footprint_ttl_result_code.ex @@ -1,20 +1,20 @@ -defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResultCode do +defmodule StellarBase.XDR.Operations.ExtendFootprintTTLResultCode do @moduledoc """ Automatically generated by xdrgen DO NOT EDIT or your changes may be overwritten Target implementation: elixir_xdr at https://hex.pm/packages/elixir_xdr - Representation of Stellar `BumpFootprintExpirationResultCode` type. + Representation of Stellar `ExtendFootprintTTLResultCode` type. """ @behaviour XDR.Declaration @declarations [ - BUMP_FOOTPRINT_EXPIRATION_SUCCESS: 0, - BUMP_FOOTPRINT_EXPIRATION_MALFORMED: -1, - BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED: -2, - BUMP_FOOTPRINT_EXPIRATION_INSUFFICIENT_REFUNDABLE_FEE: -3 + EXTEND_FOOTPRINT_TTL_SUCCESS: 0, + EXTEND_FOOTPRINT_TTL_MALFORMED: -1, + EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED: -2, + EXTEND_FOOTPRINT_TTL_INSUFFICIENT_REFUNDABLE_FEE: -3 ] @enum_spec %XDR.Enum{declarations: @declarations, identifier: nil} @@ -24,7 +24,7 @@ defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResultCode do defstruct [:identifier] @spec new(type :: atom()) :: t() - def new(type \\ :BUMP_FOOTPRINT_EXPIRATION_SUCCESS), do: %__MODULE__{identifier: type} + def new(type \\ :EXTEND_FOOTPRINT_TTL_SUCCESS), do: %__MODULE__{identifier: type} @impl true def encode_xdr(%__MODULE__{identifier: type}) do diff --git a/lib/xdr/transactions/operations/invoke_host_function_result.ex b/lib/xdr/transactions/operations/invoke_host_function_result.ex index af4c951..20eb882 100644 --- a/lib/xdr/transactions/operations/invoke_host_function_result.ex +++ b/lib/xdr/transactions/operations/invoke_host_function_result.ex @@ -18,7 +18,7 @@ defmodule StellarBase.XDR.Operations.InvokeHostFunctionResult do INVOKE_HOST_FUNCTION_MALFORMED: Void, INVOKE_HOST_FUNCTION_TRAPPED: Void, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: Void, - INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: Void, + INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED: Void, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: Void ] diff --git a/lib/xdr/transactions/operations/invoke_host_function_result_code.ex b/lib/xdr/transactions/operations/invoke_host_function_result_code.ex index b7d0d4c..554357f 100644 --- a/lib/xdr/transactions/operations/invoke_host_function_result_code.ex +++ b/lib/xdr/transactions/operations/invoke_host_function_result_code.ex @@ -15,7 +15,7 @@ defmodule StellarBase.XDR.Operations.InvokeHostFunctionResultCode do INVOKE_HOST_FUNCTION_MALFORMED: -1, INVOKE_HOST_FUNCTION_TRAPPED: -2, INVOKE_HOST_FUNCTION_RESOURCE_LIMIT_EXCEEDED: -3, - INVOKE_HOST_FUNCTION_ENTRY_EXPIRED: -4, + INVOKE_HOST_FUNCTION_ENTRY_ARCHIVED: -4, INVOKE_HOST_FUNCTION_INSUFFICIENT_REFUNDABLE_FEE: -5 ] diff --git a/lib/xdr/transactions/soroban_transaction_data.ex b/lib/xdr/transactions/soroban_transaction_data.ex index abf65ba..ce4989d 100644 --- a/lib/xdr/transactions/soroban_transaction_data.ex +++ b/lib/xdr/transactions/soroban_transaction_data.ex @@ -19,43 +19,43 @@ defmodule StellarBase.XDR.SorobanTransactionData do @struct_spec XDR.Struct.new( ext: ExtensionPoint, resources: SorobanResources, - refundable_fee: Int64 + resource_fee: Int64 ) @type ext_type :: ExtensionPoint.t() @type resources_type :: SorobanResources.t() - @type refundable_fee_type :: Int64.t() + @type resource_fee_type :: Int64.t() @type t :: %__MODULE__{ ext: ext_type(), resources: resources_type(), - refundable_fee: refundable_fee_type() + resource_fee: resource_fee_type() } - defstruct [:ext, :resources, :refundable_fee] + defstruct [:ext, :resources, :resource_fee] @spec new( ext :: ext_type(), resources :: resources_type(), - refundable_fee :: refundable_fee_type() + resource_fee :: resource_fee_type() ) :: t() def new( %ExtensionPoint{} = ext, %SorobanResources{} = resources, - %Int64{} = refundable_fee + %Int64{} = resource_fee ), - do: %__MODULE__{ext: ext, resources: resources, refundable_fee: refundable_fee} + do: %__MODULE__{ext: ext, resources: resources, resource_fee: resource_fee} @impl true - def encode_xdr(%__MODULE__{ext: ext, resources: resources, refundable_fee: refundable_fee}) do - [ext: ext, resources: resources, refundable_fee: refundable_fee] + def encode_xdr(%__MODULE__{ext: ext, resources: resources, resource_fee: resource_fee}) do + [ext: ext, resources: resources, resource_fee: resource_fee] |> XDR.Struct.new() |> XDR.Struct.encode_xdr() end @impl true - def encode_xdr!(%__MODULE__{ext: ext, resources: resources, refundable_fee: refundable_fee}) do - [ext: ext, resources: resources, refundable_fee: refundable_fee] + def encode_xdr!(%__MODULE__{ext: ext, resources: resources, resource_fee: resource_fee}) do + [ext: ext, resources: resources, resource_fee: resource_fee] |> XDR.Struct.new() |> XDR.Struct.encode_xdr!() end @@ -66,9 +66,9 @@ defmodule StellarBase.XDR.SorobanTransactionData do def decode_xdr(bytes, struct) do case XDR.Struct.decode_xdr(bytes, struct) do {:ok, - {%XDR.Struct{components: [ext: ext, resources: resources, refundable_fee: refundable_fee]}, + {%XDR.Struct{components: [ext: ext, resources: resources, resource_fee: resource_fee]}, rest}} -> - {:ok, {new(ext, resources, refundable_fee), rest}} + {:ok, {new(ext, resources, resource_fee), rest}} error -> error @@ -79,9 +79,9 @@ defmodule StellarBase.XDR.SorobanTransactionData do def decode_xdr!(bytes, struct \\ @struct_spec) def decode_xdr!(bytes, struct) do - {%XDR.Struct{components: [ext: ext, resources: resources, refundable_fee: refundable_fee]}, - rest} = XDR.Struct.decode_xdr!(bytes, struct) + {%XDR.Struct{components: [ext: ext, resources: resources, resource_fee: resource_fee]}, rest} = + XDR.Struct.decode_xdr!(bytes, struct) - {new(ext, resources, refundable_fee), rest} + {new(ext, resources, resource_fee), rest} end end diff --git a/test/xdr/transactions/operations/bump_footprint_expiration_result_code_test.exs b/test/xdr/transactions/operations/bump_footprint_expiration_result_code_test.exs deleted file mode 100644 index 5578149..0000000 --- a/test/xdr/transactions/operations/bump_footprint_expiration_result_code_test.exs +++ /dev/null @@ -1,72 +0,0 @@ -defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResultCodeTest do - use ExUnit.Case - - alias StellarBase.XDR.Operations.BumpFootprintExpirationResultCode - - @codes [ - :BUMP_FOOTPRINT_EXPIRATION_SUCCESS, - :BUMP_FOOTPRINT_EXPIRATION_MALFORMED, - :BUMP_FOOTPRINT_EXPIRATION_RESOURCE_LIMIT_EXCEEDED - ] - - @binaries [ - <<0, 0, 0, 0>>, - <<255, 255, 255, 255>>, - <<255, 255, 255, 254>> - ] - - describe "BumpFootprintExpirationResultCode" do - setup do - %{ - codes: @codes, - results: @codes |> Enum.map(fn code -> BumpFootprintExpirationResultCode.new(code) end), - binaries: @binaries - } - end - - test "new/1", %{codes: types} do - for type <- types, - do: - %BumpFootprintExpirationResultCode{identifier: ^type} = - BumpFootprintExpirationResultCode.new(type) - end - - test "encode_xdr/1", %{results: results, binaries: binaries} do - for {result, binary} <- Enum.zip(results, binaries), - do: {:ok, ^binary} = BumpFootprintExpirationResultCode.encode_xdr(result) - end - - test "encode_xdr/1 with an invalid code" do - {:error, :invalid_key} = - BumpFootprintExpirationResultCode.encode_xdr(%BumpFootprintExpirationResultCode{ - identifier: :TEST - }) - end - - test "encode_xdr!/1", %{results: results, binaries: binaries} do - for {result, binary} <- Enum.zip(results, binaries), - do: ^binary = BumpFootprintExpirationResultCode.encode_xdr!(result) - end - - test "decode_xdr/2", %{results: results, binaries: binaries} do - for {result, binary} <- Enum.zip(results, binaries), - do: {:ok, {^result, ""}} = BumpFootprintExpirationResultCode.decode_xdr(binary) - end - - test "decode_xdr/2 with an invalid declaration" do - {:error, :invalid_key} = BumpFootprintExpirationResultCode.decode_xdr(<<1, 0, 0, 1>>) - end - - test "decode_xdr!/2", %{results: results, binaries: binaries} do - for {result, binary} <- Enum.zip(results, binaries), - do: {^result, ^binary} = BumpFootprintExpirationResultCode.decode_xdr!(binary <> binary) - end - - test "decode_xdr!/2 with an error code", %{binaries: binaries} do - for binary <- binaries, - do: - {%BumpFootprintExpirationResultCode{identifier: _}, ""} = - BumpFootprintExpirationResultCode.decode_xdr!(binary) - end - end -end diff --git a/test/xdr/transactions/operations/bump_footprint_expiration_result_test.exs b/test/xdr/transactions/operations/bump_footprint_expiration_result_test.exs deleted file mode 100644 index 1dba871..0000000 --- a/test/xdr/transactions/operations/bump_footprint_expiration_result_test.exs +++ /dev/null @@ -1,61 +0,0 @@ -defmodule StellarBase.XDR.Operations.BumpFootprintExpirationResultTest do - use ExUnit.Case - - alias StellarBase.XDR.Void - - alias StellarBase.XDR.Operations.{ - BumpFootprintExpirationResult, - BumpFootprintExpirationResultCode - } - - describe "BumpFootprintExpirationResult" do - setup do - type = BumpFootprintExpirationResultCode.new(:BUMP_FOOTPRINT_EXPIRATION_SUCCESS) - - %{ - type: type, - value: Void.new(), - result: BumpFootprintExpirationResult.new(Void.new(), type), - binary: <<0, 0, 0, 0>> - } - end - - test "new/1", %{type: type, value: value} do - %BumpFootprintExpirationResult{type: ^type, value: ^value} = - BumpFootprintExpirationResult.new(value, type) - end - - test "encode_xdr/1", %{result: result, binary: binary} do - {:ok, ^binary} = BumpFootprintExpirationResult.encode_xdr(result) - end - - test "encode_xdr!/1", %{result: result, binary: binary} do - ^binary = BumpFootprintExpirationResult.encode_xdr!(result) - end - - test "encode_xdr!/1 with a default value", %{type: type, binary: binary} do - result = BumpFootprintExpirationResult.new("TEST", type) - ^binary = BumpFootprintExpirationResult.encode_xdr!(result) - end - - test "decode_xdr/2", %{result: result, binary: binary} do - {:ok, {^result, ""}} = BumpFootprintExpirationResult.decode_xdr(binary) - end - - test "decode_xdr!/2", %{result: result, binary: binary} do - {^result, ^binary} = BumpFootprintExpirationResult.decode_xdr!(binary <> binary) - end - - test "decode_xdr!/2 an error type" do - {%BumpFootprintExpirationResult{ - type: %BumpFootprintExpirationResultCode{ - identifier: :BUMP_FOOTPRINT_EXPIRATION_MALFORMED - } - }, ""} = BumpFootprintExpirationResult.decode_xdr!(<<255, 255, 255, 255>>) - end - - test "decode_xdr/2 with an invalid binary" do - {:error, :not_binary} = BumpFootprintExpirationResult.decode_xdr(123) - end - end -end diff --git a/test/xdr/transactions/operations/bump_footprint_expiration_test.exs b/test/xdr/transactions/operations/bump_footprint_expiration_test.exs deleted file mode 100644 index c773d64..0000000 --- a/test/xdr/transactions/operations/bump_footprint_expiration_test.exs +++ /dev/null @@ -1,51 +0,0 @@ -defmodule StellarBase.XDR.Operations.BumpFootprintExpirationTest do - use ExUnit.Case - - alias StellarBase.XDR.{ - ExtensionPoint, - Operations.BumpFootprintExpiration, - UInt32, - Void - } - - describe "BumpFootprintExpiration Operation" do - setup do - ext = ExtensionPoint.new(Void.new(), 0) - ledgers_to_expire = UInt32.new(105_255) - - %{ - ext: ext, - ledgers_to_expire: ledgers_to_expire, - bump_footprint_exp: BumpFootprintExpiration.new(ext, ledgers_to_expire), - binary: <<0, 0, 0, 0, 0, 1, 155, 39>> - } - end - - test "new/1", %{ext: ext, ledgers_to_expire: ledgers_to_expire} do - %BumpFootprintExpiration{ - ext: ^ext, - ledgers_to_expire: ^ledgers_to_expire - } = BumpFootprintExpiration.new(ext, ledgers_to_expire) - end - - test "encode_xdr/1", %{bump_footprint_exp: bump_footprint_exp, binary: binary} do - {:ok, ^binary} = BumpFootprintExpiration.encode_xdr(bump_footprint_exp) - end - - test "encode_xdr!/1", %{bump_footprint_exp: bump_footprint_exp, binary: binary} do - ^binary = BumpFootprintExpiration.encode_xdr!(bump_footprint_exp) - end - - test "decode_xdr/2", %{bump_footprint_exp: bump_footprint_exp, binary: binary} do - {:ok, {^bump_footprint_exp, ""}} = BumpFootprintExpiration.decode_xdr(binary) - end - - test "decode_xdr/2 with an invalid binary" do - {:error, :not_binary} = BumpFootprintExpiration.decode_xdr(123) - end - - test "decode_xdr!/2", %{bump_footprint_exp: bump_footprint_exp, binary: binary} do - {^bump_footprint_exp, ^binary} = BumpFootprintExpiration.decode_xdr!(binary <> binary) - end - end -end diff --git a/test/xdr/transactions/operations/extend_footprint_ttl_result_code_test.exs b/test/xdr/transactions/operations/extend_footprint_ttl_result_code_test.exs new file mode 100644 index 0000000..95f252d --- /dev/null +++ b/test/xdr/transactions/operations/extend_footprint_ttl_result_code_test.exs @@ -0,0 +1,72 @@ +defmodule StellarBase.XDR.Operations.ExtendFootprintTTLResultCodeTest do + use ExUnit.Case + + alias StellarBase.XDR.Operations.ExtendFootprintTTLResultCode + + @codes [ + :EXTEND_FOOTPRINT_TTL_SUCCESS, + :EXTEND_FOOTPRINT_TTL_MALFORMED, + :EXTEND_FOOTPRINT_TTL_RESOURCE_LIMIT_EXCEEDED + ] + + @binaries [ + <<0, 0, 0, 0>>, + <<255, 255, 255, 255>>, + <<255, 255, 255, 254>> + ] + + describe "ExtendFootprintTTLResultCode" do + setup do + %{ + codes: @codes, + results: @codes |> Enum.map(fn code -> ExtendFootprintTTLResultCode.new(code) end), + binaries: @binaries + } + end + + test "new/1", %{codes: types} do + for type <- types, + do: + %ExtendFootprintTTLResultCode{identifier: ^type} = + ExtendFootprintTTLResultCode.new(type) + end + + test "encode_xdr/1", %{results: results, binaries: binaries} do + for {result, binary} <- Enum.zip(results, binaries), + do: {:ok, ^binary} = ExtendFootprintTTLResultCode.encode_xdr(result) + end + + test "encode_xdr/1 with an invalid code" do + {:error, :invalid_key} = + ExtendFootprintTTLResultCode.encode_xdr(%ExtendFootprintTTLResultCode{ + identifier: :TEST + }) + end + + test "encode_xdr!/1", %{results: results, binaries: binaries} do + for {result, binary} <- Enum.zip(results, binaries), + do: ^binary = ExtendFootprintTTLResultCode.encode_xdr!(result) + end + + test "decode_xdr/2", %{results: results, binaries: binaries} do + for {result, binary} <- Enum.zip(results, binaries), + do: {:ok, {^result, ""}} = ExtendFootprintTTLResultCode.decode_xdr(binary) + end + + test "decode_xdr/2 with an invalid declaration" do + {:error, :invalid_key} = ExtendFootprintTTLResultCode.decode_xdr(<<1, 0, 0, 1>>) + end + + test "decode_xdr!/2", %{results: results, binaries: binaries} do + for {result, binary} <- Enum.zip(results, binaries), + do: {^result, ^binary} = ExtendFootprintTTLResultCode.decode_xdr!(binary <> binary) + end + + test "decode_xdr!/2 with an error code", %{binaries: binaries} do + for binary <- binaries, + do: + {%ExtendFootprintTTLResultCode{identifier: _}, ""} = + ExtendFootprintTTLResultCode.decode_xdr!(binary) + end + end +end diff --git a/test/xdr/transactions/operations/extend_footprint_ttl_result_test.exs b/test/xdr/transactions/operations/extend_footprint_ttl_result_test.exs new file mode 100644 index 0000000..1e542bd --- /dev/null +++ b/test/xdr/transactions/operations/extend_footprint_ttl_result_test.exs @@ -0,0 +1,61 @@ +defmodule StellarBase.XDR.Operations.ExtendFootprintTTLResultTest do + use ExUnit.Case + + alias StellarBase.XDR.Void + + alias StellarBase.XDR.Operations.{ + ExtendFootprintTTLResult, + ExtendFootprintTTLResultCode + } + + describe "ExtendFootprintTTLResult" do + setup do + type = ExtendFootprintTTLResultCode.new(:EXTEND_FOOTPRINT_TTL_SUCCESS) + + %{ + type: type, + value: Void.new(), + result: ExtendFootprintTTLResult.new(Void.new(), type), + binary: <<0, 0, 0, 0>> + } + end + + test "new/1", %{type: type, value: value} do + %ExtendFootprintTTLResult{type: ^type, value: ^value} = + ExtendFootprintTTLResult.new(value, type) + end + + test "encode_xdr/1", %{result: result, binary: binary} do + {:ok, ^binary} = ExtendFootprintTTLResult.encode_xdr(result) + end + + test "encode_xdr!/1", %{result: result, binary: binary} do + ^binary = ExtendFootprintTTLResult.encode_xdr!(result) + end + + test "encode_xdr!/1 with a default value", %{type: type, binary: binary} do + result = ExtendFootprintTTLResult.new("TEST", type) + ^binary = ExtendFootprintTTLResult.encode_xdr!(result) + end + + test "decode_xdr/2", %{result: result, binary: binary} do + {:ok, {^result, ""}} = ExtendFootprintTTLResult.decode_xdr(binary) + end + + test "decode_xdr!/2", %{result: result, binary: binary} do + {^result, ^binary} = ExtendFootprintTTLResult.decode_xdr!(binary <> binary) + end + + test "decode_xdr!/2 an error type" do + {%ExtendFootprintTTLResult{ + type: %ExtendFootprintTTLResultCode{ + identifier: :EXTEND_FOOTPRINT_TTL_MALFORMED + } + }, ""} = ExtendFootprintTTLResult.decode_xdr!(<<255, 255, 255, 255>>) + end + + test "decode_xdr/2 with an invalid binary" do + {:error, :not_binary} = ExtendFootprintTTLResult.decode_xdr(123) + end + end +end diff --git a/test/xdr/transactions/operations/extend_footprint_ttl_test.exs b/test/xdr/transactions/operations/extend_footprint_ttl_test.exs new file mode 100644 index 0000000..599e350 --- /dev/null +++ b/test/xdr/transactions/operations/extend_footprint_ttl_test.exs @@ -0,0 +1,51 @@ +defmodule StellarBase.XDR.Operations.ExtendFootprintTTLTest do + use ExUnit.Case + + alias StellarBase.XDR.{ + ExtensionPoint, + Operations.ExtendFootprintTTL, + UInt32, + Void + } + + describe "ExtendFootprintTTL Operation" do + setup do + ext = ExtensionPoint.new(Void.new(), 0) + extend_to = UInt32.new(105_255) + + %{ + ext: ext, + extend_to: extend_to, + bump_footprint_exp: ExtendFootprintTTL.new(ext, extend_to), + binary: <<0, 0, 0, 0, 0, 1, 155, 39>> + } + end + + test "new/1", %{ext: ext, extend_to: extend_to} do + %ExtendFootprintTTL{ + ext: ^ext, + extend_to: ^extend_to + } = ExtendFootprintTTL.new(ext, extend_to) + end + + test "encode_xdr/1", %{bump_footprint_exp: bump_footprint_exp, binary: binary} do + {:ok, ^binary} = ExtendFootprintTTL.encode_xdr(bump_footprint_exp) + end + + test "encode_xdr!/1", %{bump_footprint_exp: bump_footprint_exp, binary: binary} do + ^binary = ExtendFootprintTTL.encode_xdr!(bump_footprint_exp) + end + + test "decode_xdr/2", %{bump_footprint_exp: bump_footprint_exp, binary: binary} do + {:ok, {^bump_footprint_exp, ""}} = ExtendFootprintTTL.decode_xdr(binary) + end + + test "decode_xdr/2 with an invalid binary" do + {:error, :not_binary} = ExtendFootprintTTL.decode_xdr(123) + end + + test "decode_xdr!/2", %{bump_footprint_exp: bump_footprint_exp, binary: binary} do + {^bump_footprint_exp, ^binary} = ExtendFootprintTTL.decode_xdr!(binary <> binary) + end + end +end diff --git a/test/xdr/transactions/soroban_transaction_data_test.exs b/test/xdr/transactions/soroban_transaction_data_test.exs index 0daed66..3768699 100644 --- a/test/xdr/transactions/soroban_transaction_data_test.exs +++ b/test/xdr/transactions/soroban_transaction_data_test.exs @@ -18,7 +18,7 @@ defmodule StellarBase.XDR.SorobanTransactionDataTest do describe "SorobanResources" do setup do - refundable_fee = Int64.new(10) + resource_fee = Int64.new(10) ext = ExtensionPoint.new(Void.new(), 0) hash = Hash.new("GCIZ3GSM5XL7OUS4UP64THMDZ7CZ3ZWN") type = LedgerEntryType.new(:CONTRACT_CODE) @@ -40,11 +40,11 @@ defmodule StellarBase.XDR.SorobanTransactionDataTest do write_bytes ) - soroban_transaction_data = SorobanTransactionData.new(ext, resources, refundable_fee) + soroban_transaction_data = SorobanTransactionData.new(ext, resources, resource_fee) %{ resources: resources, - refundable_fee: refundable_fee, + resource_fee: resource_fee, ext: ext, soroban_transaction_data: soroban_transaction_data, binary: @@ -58,14 +58,14 @@ defmodule StellarBase.XDR.SorobanTransactionDataTest do test "new/1", %{ resources: resources, - refundable_fee: refundable_fee, + resource_fee: resource_fee, ext: ext } do %SorobanTransactionData{ ext: ^ext, resources: ^resources, - refundable_fee: ^refundable_fee - } = SorobanTransactionData.new(ext, resources, refundable_fee) + resource_fee: ^resource_fee + } = SorobanTransactionData.new(ext, resources, resource_fee) end test "encode_xdr/1", %{soroban_transaction_data: soroban_transaction_data, binary: binary} do