-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and update file names Co-authored-by: norn <keliumJU@users.noreply.github.com>
- Loading branch information
1 parent
8e02832
commit 677bcdc
Showing
11 changed files
with
117 additions
and
114 deletions.
There are no files selected for viewing
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...r/ledger_entries/ledger_key_expiration.ex → lib/xdr/ledger_entries/ledger_key_ttl.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
defmodule StellarBase.XDR.TTLEntry 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 `TTLEntry` type. | ||
""" | ||
|
||
@behaviour XDR.Declaration | ||
|
||
alias StellarBase.XDR.{ | ||
Hash, | ||
UInt32 | ||
} | ||
|
||
@struct_spec XDR.Struct.new( | ||
key_hash: Hash, | ||
live_until_ledger_seq: UInt32 | ||
) | ||
|
||
@type key_hash_type :: Hash.t() | ||
@type live_until_ledger_seq_type :: UInt32.t() | ||
|
||
@type t :: %__MODULE__{ | ||
key_hash: key_hash_type(), | ||
live_until_ledger_seq: live_until_ledger_seq_type() | ||
} | ||
|
||
defstruct [:key_hash, :live_until_ledger_seq] | ||
|
||
@spec new(key_hash :: key_hash_type(), live_until_ledger_seq :: live_until_ledger_seq_type()) :: | ||
t() | ||
def new( | ||
%Hash{} = key_hash, | ||
%UInt32{} = live_until_ledger_seq | ||
), | ||
do: %__MODULE__{key_hash: key_hash, live_until_ledger_seq: live_until_ledger_seq} | ||
|
||
@impl true | ||
def encode_xdr(%__MODULE__{key_hash: key_hash, live_until_ledger_seq: live_until_ledger_seq}) do | ||
[key_hash: key_hash, live_until_ledger_seq: live_until_ledger_seq] | ||
|> XDR.Struct.new() | ||
|> XDR.Struct.encode_xdr() | ||
end | ||
|
||
@impl true | ||
def encode_xdr!(%__MODULE__{key_hash: key_hash, live_until_ledger_seq: live_until_ledger_seq}) do | ||
[key_hash: key_hash, live_until_ledger_seq: live_until_ledger_seq] | ||
|> 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: [key_hash: key_hash, live_until_ledger_seq: live_until_ledger_seq] | ||
}, rest}} -> | ||
{:ok, {new(key_hash, live_until_ledger_seq), rest}} | ||
|
||
error -> | ||
error | ||
end | ||
end | ||
|
||
@impl true | ||
def decode_xdr!(bytes, struct \\ @struct_spec) | ||
|
||
def decode_xdr!(bytes, struct) do | ||
{%XDR.Struct{components: [key_hash: key_hash, live_until_ledger_seq: live_until_ledger_seq]}, | ||
rest} = XDR.Struct.decode_xdr!(bytes, struct) | ||
|
||
{new(key_hash, live_until_ledger_seq), rest} | ||
end | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
...er_entries/ledger_key_expiration_test.exs → ...dr/ledger_entries/ledger_key_ttl_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
defmodule StellarBase.XDR.LedgerKeyExpirationTest do | ||
defmodule StellarBase.XDR.LedgerKeyTTLTest do | ||
use ExUnit.Case | ||
|
||
alias StellarBase.XDR.{Hash, LedgerKeyExpiration} | ||
alias StellarBase.XDR.{Hash, LedgerKeyTTL} | ||
|
||
describe "LedgerKeyExpiration" do | ||
describe "LedgerKeyTTL" do | ||
setup do | ||
hash = Hash.new("GCIZ3GSM5XL7OUS4UP64THMDZ7CZ3ZWN") | ||
|
||
%{ | ||
hash: hash, | ||
ledger_expiration: LedgerKeyExpiration.new(hash), | ||
ledger_expiration: LedgerKeyTTL.new(hash), | ||
binary: "GCIZ3GSM5XL7OUS4UP64THMDZ7CZ3ZWN" | ||
} | ||
end | ||
|
||
test "new/1", %{hash: hash} do | ||
%LedgerKeyExpiration{key_hash: ^hash} = LedgerKeyExpiration.new(hash) | ||
%LedgerKeyTTL{key_hash: ^hash} = LedgerKeyTTL.new(hash) | ||
end | ||
|
||
test "encode_xdr/1", %{ledger_expiration: ledger_expiration, binary: binary} do | ||
{:ok, ^binary} = LedgerKeyExpiration.encode_xdr(ledger_expiration) | ||
{:ok, ^binary} = LedgerKeyTTL.encode_xdr(ledger_expiration) | ||
end | ||
|
||
test "encode_xdr!/1", %{ledger_expiration: ledger_expiration, binary: binary} do | ||
^binary = LedgerKeyExpiration.encode_xdr!(ledger_expiration) | ||
^binary = LedgerKeyTTL.encode_xdr!(ledger_expiration) | ||
end | ||
|
||
test "decode_xdr/2", %{ledger_expiration: ledger_expiration, binary: binary} do | ||
{:ok, {^ledger_expiration, ""}} = LedgerKeyExpiration.decode_xdr(binary) | ||
{:ok, {^ledger_expiration, ""}} = LedgerKeyTTL.decode_xdr(binary) | ||
end | ||
|
||
test "decode_xdr!/2", %{ledger_expiration: ledger_expiration, binary: binary} do | ||
{^ledger_expiration, ^binary} = LedgerKeyExpiration.decode_xdr!(binary <> binary) | ||
{^ledger_expiration, ^binary} = LedgerKeyTTL.decode_xdr!(binary <> binary) | ||
end | ||
|
||
test "decode_xdr/2 with invalid binary" do | ||
{:error, :not_binary} = LedgerKeyExpiration.decode_xdr(123) | ||
{:error, :not_binary} = LedgerKeyTTL.decode_xdr(123) | ||
end | ||
end | ||
end |
30 changes: 15 additions & 15 deletions
30
.../ledger_entries/expiration_entry_test.exs → test/xdr/ledger_entries/ttl_entry_test.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
defmodule StellarBase.XDR.ExpirationEntryTest do | ||
defmodule StellarBase.XDR.TTLEntryTest do | ||
use ExUnit.Case | ||
alias StellarBase.XDR.ExpirationEntry | ||
alias StellarBase.XDR.TTLEntry | ||
alias StellarBase.XDR.{Hash, UInt32} | ||
|
||
describe "ExpirationEntry" do | ||
describe "TTLEntry" do | ||
setup do | ||
key_hash = Hash.new("GCIZ3GSM5XL7OUS4UP64THMDZ7CZ3ZWN") | ||
expiration_ledger_seq = UInt32.new(123) | ||
expiration_entry = ExpirationEntry.new(key_hash, expiration_ledger_seq) | ||
live_until_ledger_seq = UInt32.new(123) | ||
expiration_entry = TTLEntry.new(key_hash, live_until_ledger_seq) | ||
|
||
binary = | ||
<<71, 67, 73, 90, 51, 71, 83, 77, 53, 88, 76, 55, 79, 85, 83, 52, 85, 80, 54, 52, 84, 72, | ||
77, 68, 90, 55, 67, 90, 51, 90, 87, 78, 0, 0, 0, 123>> | ||
|
||
%{ | ||
key_hash: key_hash, | ||
expiration_ledger_seq: expiration_ledger_seq, | ||
live_until_ledger_seq: live_until_ledger_seq, | ||
expiration_entry: expiration_entry, | ||
binary: binary | ||
} | ||
end | ||
|
||
test "new/2", %{key_hash: key_hash, expiration_ledger_seq: expiration_ledger_seq} do | ||
%StellarBase.XDR.ExpirationEntry{ | ||
test "new/2", %{key_hash: key_hash, live_until_ledger_seq: live_until_ledger_seq} do | ||
%StellarBase.XDR.TTLEntry{ | ||
key_hash: ^key_hash, | ||
expiration_ledger_seq: ^expiration_ledger_seq | ||
} = ExpirationEntry.new(key_hash, expiration_ledger_seq) | ||
live_until_ledger_seq: ^live_until_ledger_seq | ||
} = TTLEntry.new(key_hash, live_until_ledger_seq) | ||
end | ||
|
||
test "encode_xdr/1", %{expiration_entry: expiration_entry, binary: binary} do | ||
{:ok, ^binary} = ExpirationEntry.encode_xdr(expiration_entry) | ||
{:ok, ^binary} = TTLEntry.encode_xdr(expiration_entry) | ||
end | ||
|
||
test "encode_xdr!/1", %{expiration_entry: expiration_entry, binary: binary} do | ||
^binary = ExpirationEntry.encode_xdr!(expiration_entry) | ||
^binary = TTLEntry.encode_xdr!(expiration_entry) | ||
end | ||
|
||
test "decode_xdr/2", %{binary: binary, expiration_entry: expiration_entry} do | ||
{:ok, {^expiration_entry, ""}} = ExpirationEntry.decode_xdr(binary) | ||
{:ok, {^expiration_entry, ""}} = TTLEntry.decode_xdr(binary) | ||
end | ||
|
||
test "decode_xdr!/2", %{binary: binary, expiration_entry: expiration_entry} do | ||
{^expiration_entry, ""} = ExpirationEntry.decode_xdr!(binary) | ||
{^expiration_entry, ""} = TTLEntry.decode_xdr!(binary) | ||
end | ||
|
||
test "decode_xdr/2 with an invalid binary" do | ||
{:error, :not_binary} = ExpirationEntry.decode_xdr(123) | ||
{:error, :not_binary} = TTLEntry.decode_xdr(123) | ||
end | ||
end | ||
end |