41-types (#44)
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in -4m28s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in -4m28s
Reviewed-on: #44 Co-authored-by: Craig Everett <zxq9@zxq9.com> Co-committed-by: Craig Everett <zxq9@zxq9.com>
This commit is contained in:
parent
969a845203
commit
a6f09d24c0
@ -1,37 +0,0 @@
|
||||
version: 2.1
|
||||
|
||||
executors:
|
||||
aebuilder:
|
||||
docker:
|
||||
- image: aeternity/builder:bionic-otp23
|
||||
user: builder
|
||||
working_directory: ~/src
|
||||
|
||||
jobs:
|
||||
build:
|
||||
executor: aebuilder
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- dialyzer-cache-v1-{{ .Branch }}-{{ .Revision }}
|
||||
- dialyzer-cache-v1-{{ .Branch }}-
|
||||
- dialyzer-cache-v1-
|
||||
- run:
|
||||
name: Build
|
||||
command: rebar3 compile
|
||||
- run:
|
||||
name: Static Analysis
|
||||
command: rebar3 dialyzer
|
||||
- run:
|
||||
name: Eunit
|
||||
command: rebar3 eunit
|
||||
- run:
|
||||
name: Common Tests
|
||||
command: rebar3 ct
|
||||
- save_cache:
|
||||
key: dialyzer-cache-v1-{{ .Branch }}-{{ .Revision }}
|
||||
paths:
|
||||
- _build/default/rebar3_20.3.8_plt
|
||||
- store_artifacts:
|
||||
path: _build/test/logs
|
19
.gitea/workflows/demo.yaml
Normal file
19
.gitea/workflows/demo.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: linux_amd64
|
||||
steps:
|
||||
- run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- run: echo "The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- run: echo "The workflow is now ready to test your code on the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- run: echo "This job's status is ${{ job.status }}."
|
1
LICENSE
1
LICENSE
@ -1,5 +1,6 @@
|
||||
ISC License
|
||||
|
||||
Copyright (c) 2025, QPQ AG
|
||||
Copyright (c) 2017, aeternity developers
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
|
10
README.md
10
README.md
@ -1,9 +1,15 @@
|
||||
aeserialization
|
||||
GM Serialization
|
||||
=====
|
||||
|
||||
Serialization helpers for Aeternity node.
|
||||
Serialization helpers for the Gajumaru.
|
||||
|
||||
Build
|
||||
-----
|
||||
|
||||
$ rebar3 compile
|
||||
|
||||
|
||||
Test
|
||||
----
|
||||
|
||||
$ rebar3 eunit
|
||||
|
@ -1,10 +1,11 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2017, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% API encoding for the Aeternity node.
|
||||
%%% API encoding for the Gajumaru
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(aeser_api_encoder).
|
||||
-module(gmser_api_encoder).
|
||||
|
||||
-export([encode/2,
|
||||
decode/1,
|
||||
@ -52,9 +53,9 @@
|
||||
-define(BASE58, 1).
|
||||
-define(BASE64, 2).
|
||||
|
||||
-spec encode(known_type(), payload() | aeser_id:id()) -> encoded().
|
||||
-spec encode(known_type(), payload() | gmser_id:id()) -> encoded().
|
||||
encode(id_hash, Payload) ->
|
||||
{IdType, Val} = aeser_id:specialize(Payload),
|
||||
{IdType, Val} = gmser_id:specialize(Payload),
|
||||
encode(id2type(IdType), Val);
|
||||
encode(Type, Payload) ->
|
||||
Pfx = type2pfx(Type),
|
||||
@ -90,14 +91,14 @@ type_size_check(Type, Bin) ->
|
||||
end
|
||||
end.
|
||||
|
||||
-spec safe_decode(extended_type(), encoded()) -> {'ok', payload() | aeser_id:id()}
|
||||
-spec safe_decode(extended_type(), encoded()) -> {'ok', payload() | gmser_id:id()}
|
||||
| {'error', atom()}.
|
||||
safe_decode({id_hash, AllowedTypes}, Enc) ->
|
||||
try decode(Enc) of
|
||||
{ActualType, Dec} ->
|
||||
case lists:member(ActualType, AllowedTypes) of
|
||||
true ->
|
||||
try {ok, aeser_id:create(type2id(ActualType), Dec)}
|
||||
try {ok, gmser_id:create(type2id(ActualType), Dec)}
|
||||
catch error:_ -> {error, invalid_prefix}
|
||||
end;
|
||||
false ->
|
@ -1,20 +1,21 @@
|
||||
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% Functions for serializing chain objects to binary format.
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(aeser_chain_objects).
|
||||
-module(gmser_chain_objects).
|
||||
|
||||
-export([ serialize/4
|
||||
, deserialize/4
|
||||
, deserialize_type_and_vsn/1
|
||||
]).
|
||||
|
||||
-type template() :: aeserialization:template().
|
||||
-type fields() :: aeserialization:fields().
|
||||
-type template() :: gmserialization:template().
|
||||
-type fields() :: gmserialization:fields().
|
||||
|
||||
%%%===================================================================
|
||||
%%% API
|
||||
@ -22,15 +23,15 @@
|
||||
|
||||
-spec serialize(atom(), non_neg_integer(), template(), fields()) -> binary().
|
||||
serialize(Type, Vsn, Template, Fields) ->
|
||||
aeserialization:serialize(tag(Type), Vsn, Template, Fields).
|
||||
gmserialization:serialize(tag(Type), Vsn, Template, Fields).
|
||||
|
||||
deserialize_type_and_vsn(Binary) ->
|
||||
{Tag, Vsn, Fields} = aeserialization:deserialize_tag_and_vsn(Binary),
|
||||
{Tag, Vsn, Fields} = gmserialization:deserialize_tag_and_vsn(Binary),
|
||||
{rev_tag(Tag), Vsn, Fields}.
|
||||
|
||||
-spec deserialize(atom(), non_neg_integer(), template(), binary()) -> fields().
|
||||
deserialize(Type, Vsn, Template, Binary) ->
|
||||
aeserialization:deserialize(Type, tag(Type), Vsn, Template, Binary).
|
||||
gmserialization:deserialize(Type, tag(Type), Vsn, Template, Binary).
|
||||
|
||||
%%%===================================================================
|
||||
%%% Internal functions
|
@ -1,12 +1,13 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2019, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% Serialization of contract code
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(aeser_contract_code).
|
||||
-module(gmser_contract_code).
|
||||
|
||||
-include("aeser_contract_code.hrl").
|
||||
-include("gmser_contract_code.hrl").
|
||||
|
||||
-export([ deserialize/1
|
||||
, serialize/1
|
||||
@ -42,20 +43,20 @@ serialize(CodeMap = #{ byte_code := ByteCode
|
||||
|| SophiaContractVersion > ?SOPHIA_CONTRACT_VSN_1 ] ++
|
||||
[ {payable, Payable}
|
||||
|| SophiaContractVersion > ?SOPHIA_CONTRACT_VSN_2 ],
|
||||
aeser_chain_objects:serialize(compiler_sophia,
|
||||
gmser_chain_objects:serialize(compiler_sophia,
|
||||
SophiaContractVersion,
|
||||
serialization_template(SophiaContractVersion),
|
||||
Fields).
|
||||
|
||||
-spec deserialize(binary()) -> map().
|
||||
deserialize(Binary) ->
|
||||
case aeser_chain_objects:deserialize_type_and_vsn(Binary) of
|
||||
case gmser_chain_objects:deserialize_type_and_vsn(Binary) of
|
||||
{compiler_sophia = Type, ?SOPHIA_CONTRACT_VSN_1 = Vsn, _Rest} ->
|
||||
Template = serialization_template(Vsn),
|
||||
[ {source_hash, Hash}
|
||||
, {type_info, TypeInfo}
|
||||
, {byte_code, ByteCode}
|
||||
] = aeser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||
] = gmser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||
#{ source_hash => Hash
|
||||
, type_info => TypeInfo
|
||||
, byte_code => ByteCode
|
||||
@ -68,7 +69,7 @@ deserialize(Binary) ->
|
||||
, {type_info, TypeInfo}
|
||||
, {byte_code, ByteCode}
|
||||
, {compiler_version, CompilerVersion}
|
||||
] = aeser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||
] = gmser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||
#{ source_hash => Hash
|
||||
, type_info => TypeInfo
|
||||
, byte_code => ByteCode
|
||||
@ -83,7 +84,7 @@ deserialize(Binary) ->
|
||||
, {byte_code, ByteCode}
|
||||
, {compiler_version, CompilerVersion}
|
||||
, {payable, Payable}
|
||||
] = aeser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||
] = gmser_chain_objects:deserialize(Type, Vsn, Template, Binary),
|
||||
#{ source_hash => Hash
|
||||
, type_info => TypeInfo
|
||||
, byte_code => ByteCode
|
@ -1,10 +1,11 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2023, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% Serialization of delegation signatures
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(aeser_delegation).
|
||||
-module(gmser_delegation).
|
||||
|
||||
-export([ aens_preclaim_sig/3
|
||||
, aens_name_sig/4
|
||||
@ -25,7 +26,7 @@
|
||||
|
||||
-type sig_data() :: binary().
|
||||
|
||||
-spec aens_preclaim_sig(binary(), aeser_id:id(), aeser_id:id()) -> sig_data().
|
||||
-spec aens_preclaim_sig(binary(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||
aens_preclaim_sig(NetworkId, Account, Contract) ->
|
||||
assert_id(account, Account),
|
||||
assert_id(contract, Contract),
|
||||
@ -33,7 +34,7 @@ aens_preclaim_sig(NetworkId, Account, Contract) ->
|
||||
Fields = [{account, Account}, {contract, Contract}],
|
||||
serialize(?TYPE_AENS_PRECLAIM, NetworkId, Template, Fields).
|
||||
|
||||
-spec aens_name_sig(binary(), aeser_id:id(), aeser_id:id(), aeser_id:id()) -> sig_data().
|
||||
-spec aens_name_sig(binary(), gmser_id:id(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||
aens_name_sig(NetworkId, Account, Name, Contract) ->
|
||||
assert_id(account, Account),
|
||||
assert_id(name, Name),
|
||||
@ -42,7 +43,7 @@ aens_name_sig(NetworkId, Account, Name, Contract) ->
|
||||
Fields = [{account, Account}, {name, Name}, {contract, Contract}],
|
||||
serialize(?TYPE_AENS_NAME, NetworkId, Template, Fields).
|
||||
|
||||
-spec aens_sig(binary(), aeser_id:id(), aeser_id:id()) -> sig_data().
|
||||
-spec aens_sig(binary(), gmser_id:id(), gmser_id:id()) -> sig_data().
|
||||
aens_sig(NetworkId, Account, Contract) ->
|
||||
assert_id(account, Account),
|
||||
assert_id(contract, Contract),
|
||||
@ -56,8 +57,8 @@ aens_sig(NetworkId, Account, Contract) ->
|
||||
%% ------------------------------------------------------------------------
|
||||
|
||||
serialize(Type, NetworkId, Template, Fields) ->
|
||||
Data = aeserialization:serialize(Type, ?VSN, Template, Fields),
|
||||
Data = gmserialization:serialize(Type, ?VSN, Template, Fields),
|
||||
<<?DELEGATION_TAG:16, NetworkId/binary, Data/binary>>.
|
||||
|
||||
assert_id(Type, AeserId) ->
|
||||
Type = aeser_id:specialize_type(AeserId).
|
||||
Type = gmser_id:specialize_type(AeserId).
|
@ -1,12 +1,13 @@
|
||||
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% ADT for identifiers
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(aeser_id).
|
||||
-module(gmser_id).
|
||||
|
||||
-export([ create/2
|
||||
, specialize/1
|
@ -1,4 +1,5 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2017, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% Implementation of the Recursive Length Prefix.
|
||||
@ -8,7 +9,7 @@
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(aeser_rlp).
|
||||
-module(gmser_rlp).
|
||||
-export([ decode/1
|
||||
, decode_one/1
|
||||
, encode/1
|
@ -1,5 +1,5 @@
|
||||
{application, aeserialization,
|
||||
[{description, "Serialization of data for Aeternity"},
|
||||
{application, gmserialization,
|
||||
[{description, "Serialization of data for the Gajumaru"},
|
||||
{vsn, "0.1.0"},
|
||||
{registered, []},
|
||||
{applications,
|
@ -1,11 +1,12 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% Functions for serializing generic objects to/from binary format.
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(aeserialization).
|
||||
-module(gmserialization).
|
||||
|
||||
-export([ decode_fields/2
|
||||
, deserialize/5
|
||||
@ -37,7 +38,7 @@
|
||||
| [encodable_term()] %% Of any length
|
||||
| #{atom() => encodable_term()}
|
||||
| tuple() %% Any arity, containing encodable_term().
|
||||
| aeser_id:id().
|
||||
| gmser_id:id().
|
||||
|
||||
-type fields() :: [{field_name(), encodable_term()}].
|
||||
|
||||
@ -49,13 +50,13 @@
|
||||
serialize(Tag, Vsn, Template, Fields) ->
|
||||
List = encode_fields([{tag, int}, {vsn, int}|Template],
|
||||
[{tag, Tag}, {vsn, Vsn}|Fields]),
|
||||
aeser_rlp:encode(List).
|
||||
gmser_rlp:encode(List).
|
||||
|
||||
%% Type isn't strictly necessary, but will give a better error reason
|
||||
-spec deserialize(atom(), non_neg_integer(), non_neg_integer(),
|
||||
template(), binary()) -> fields().
|
||||
deserialize(Type, Tag, Vsn, Template0, Binary) ->
|
||||
Decoded = aeser_rlp:decode(Binary),
|
||||
Decoded = gmser_rlp:decode(Binary),
|
||||
Template = [{tag, int}, {vsn, int}|Template0],
|
||||
case decode_fields(Template, Decoded) of
|
||||
[{tag, Tag}, {vsn, Vsn}|Left] ->
|
||||
@ -68,7 +69,7 @@ deserialize(Type, Tag, Vsn, Template0, Binary) ->
|
||||
-spec deserialize_tag_and_vsn(binary()) ->
|
||||
{non_neg_integer(), non_neg_integer(), fields()}.
|
||||
deserialize_tag_and_vsn(Binary) ->
|
||||
[TagBin, VsnBin|Fields] = aeser_rlp:decode(Binary),
|
||||
[TagBin, VsnBin|Fields] = gmser_rlp:decode(Binary),
|
||||
Template = [{tag, int}, {vsn, int}],
|
||||
[{tag, Tag}, {vsn, Vsn}] = decode_fields(Template, [TagBin, VsnBin]),
|
||||
{Tag, Vsn, Fields}.
|
||||
@ -118,7 +119,7 @@ encode_field(binary, X) when is_binary(X) -> X;
|
||||
encode_field(bool, true) -> <<1:8>>;
|
||||
encode_field(bool, false) -> <<0:8>>;
|
||||
encode_field(id, Val) ->
|
||||
try aeser_id:encode(Val)
|
||||
try gmser_id:encode(Val)
|
||||
catch _:_ -> error({illegal, id, Val})
|
||||
end;
|
||||
encode_field(Type, Val) -> error({illegal, Type, Val}).
|
||||
@ -142,7 +143,7 @@ decode_field(binary, X) when is_binary(X) -> X;
|
||||
decode_field(bool, <<1:8>>) -> true;
|
||||
decode_field(bool, <<0:8>>) -> false;
|
||||
decode_field(id, Val) ->
|
||||
try aeser_id:decode(Val)
|
||||
try gmser_id:decode(Val)
|
||||
catch _:_ -> error({illegal, id, Val})
|
||||
end;
|
||||
decode_field(Type, X) -> error({illegal, Type, X}).
|
@ -1,12 +1,13 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(aeser_api_encoder_tests).
|
||||
-module(gmser_api_encoder_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-define(TEST_MODULE, aeser_api_encoder).
|
||||
-define(TEST_MODULE, gmser_api_encoder).
|
||||
-define(TYPES, [ {key_block_hash , 32}
|
||||
, {micro_block_hash , 32}
|
||||
, {block_tx_hash , 32}
|
@ -1,11 +1,12 @@
|
||||
%%% -*- erlang-indent-level:4; indent-tabs-mode: nil -*-
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2018, Aeternity Anstalt
|
||||
%%% @doc
|
||||
%%% EUnit tests for aeser_chain_objects
|
||||
%%% EUnit tests for gmser_chain_objects
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(aeser_chain_objects_tests).
|
||||
-module(gmser_chain_objects_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
@ -78,10 +79,10 @@ deserialize(Template, Bin) ->
|
||||
deserialize(Template, Bin, ?DEFAULT_TAG, ?DEFAULT_VERSION).
|
||||
|
||||
deserialize(Template, Bin, Tag, Vsn) ->
|
||||
aeser_chain_objects:deserialize(Tag, Vsn, Template, Bin).
|
||||
gmser_chain_objects:deserialize(Tag, Vsn, Template, Bin).
|
||||
|
||||
serialize(Template, Bin) ->
|
||||
serialize(Template, Bin, ?DEFAULT_TAG, ?DEFAULT_VERSION).
|
||||
|
||||
serialize(Template, Bin, Tag, Vsn) ->
|
||||
aeser_chain_objects:serialize(Tag, Vsn, Template, Bin).
|
||||
gmser_chain_objects:serialize(Tag, Vsn, Template, Bin).
|
@ -1,7 +1,11 @@
|
||||
-module(aeser_contract_code_tests).
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(gmser_contract_code_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include("aeser_contract_code.hrl").
|
||||
-include("gmser_contract_code.hrl").
|
||||
|
||||
-define(DUMMY_CODE_MAP_1,
|
||||
#{ byte_code => <<"DUMMY CODE">>
|
||||
@ -22,14 +26,14 @@
|
||||
, payable => true} ).
|
||||
|
||||
vsn_1_test() ->
|
||||
aeser_contract_code:deserialize(
|
||||
aeser_contract_code:serialize(?DUMMY_CODE_MAP_1, ?SOPHIA_CONTRACT_VSN_1)).
|
||||
gmser_contract_code:deserialize(
|
||||
gmser_contract_code:serialize(?DUMMY_CODE_MAP_1, ?SOPHIA_CONTRACT_VSN_1)).
|
||||
|
||||
vsn_2_test() ->
|
||||
aeser_contract_code:deserialize(
|
||||
aeser_contract_code:serialize(?DUMMY_CODE_MAP_2, ?SOPHIA_CONTRACT_VSN_2)).
|
||||
gmser_contract_code:deserialize(
|
||||
gmser_contract_code:serialize(?DUMMY_CODE_MAP_2, ?SOPHIA_CONTRACT_VSN_2)).
|
||||
|
||||
vsn_3_test() ->
|
||||
aeser_contract_code:deserialize(
|
||||
aeser_contract_code:serialize(?DUMMY_CODE_MAP_3, ?SOPHIA_CONTRACT_VSN_3)).
|
||||
gmser_contract_code:deserialize(
|
||||
gmser_contract_code:serialize(?DUMMY_CODE_MAP_3, ?SOPHIA_CONTRACT_VSN_3)).
|
||||
|
@ -1,48 +1,49 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2023, Aeternity Anstalt
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(aeser_delegation_tests).
|
||||
-module(gmser_delegation_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
-define(TEST_MODULE, aeser_delegation).
|
||||
-define(TEST_MODULE, gmser_delegation).
|
||||
|
||||
-define(ACCOUNT, aeser_id:create(account, <<1:256>>)).
|
||||
-define(CONTRACT, aeser_id:create(contract, <<2:256>>)).
|
||||
-define(NAME, aeser_id:create(name, <<3:256>>)).
|
||||
-define(ACCOUNT, gmser_id:create(account, <<1:256>>)).
|
||||
-define(CONTRACT, gmser_id:create(contract, <<2:256>>)).
|
||||
-define(NAME, gmser_id:create(name, <<3:256>>)).
|
||||
|
||||
-define(NETWORK_ID, <<"my_fancy_network"/utf8>>).
|
||||
|
||||
encode_correct_test_() ->
|
||||
[{"Encode preclaim sig",
|
||||
fun() ->
|
||||
aeser_delegation:aens_preclaim_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
||||
gmser_delegation:aens_preclaim_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
||||
end},
|
||||
{"Encode name sig",
|
||||
fun() ->
|
||||
aeser_delegation:aens_name_sig(?NETWORK_ID, ?ACCOUNT, ?NAME, ?CONTRACT)
|
||||
gmser_delegation:aens_name_sig(?NETWORK_ID, ?ACCOUNT, ?NAME, ?CONTRACT)
|
||||
end},
|
||||
{"Encode aens wildcard sig",
|
||||
fun() ->
|
||||
aeser_delegation:aens_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
||||
gmser_delegation:aens_sig(?NETWORK_ID, ?ACCOUNT, ?CONTRACT)
|
||||
end}
|
||||
].
|
||||
|
||||
encode_fail_test_() ->
|
||||
[{"Bad encoding preclaim sig",
|
||||
fun() ->
|
||||
?assertError(_, aeser_delegation:aens_preclaim_sig(?NETWORK_ID, <<42:256>>, ?CONTRACT)),
|
||||
?assertError(_, aeser_delegation:aens_preclaim_sig(?NETWORK_ID, ?CONTRACT, ?ACCOUNT))
|
||||
?assertError(_, gmser_delegation:aens_preclaim_sig(?NETWORK_ID, <<42:256>>, ?CONTRACT)),
|
||||
?assertError(_, gmser_delegation:aens_preclaim_sig(?NETWORK_ID, ?CONTRACT, ?ACCOUNT))
|
||||
end},
|
||||
{"Bad encoding name sig",
|
||||
fun() ->
|
||||
?assertError(_, aeser_delegation:aens_name_sig(?NETWORK_ID, ?ACCOUNT, <<42:256>>, ?CONTRACT)),
|
||||
?assertError(_, aeser_delegation:aens_name_sig(?NETWORK_ID, ?NAME, ?ACCOUNT, ?CONTRACT))
|
||||
?assertError(_, gmser_delegation:aens_name_sig(?NETWORK_ID, ?ACCOUNT, <<42:256>>, ?CONTRACT)),
|
||||
?assertError(_, gmser_delegation:aens_name_sig(?NETWORK_ID, ?NAME, ?ACCOUNT, ?CONTRACT))
|
||||
end},
|
||||
{"Bad encoding aens wildcard sig",
|
||||
fun() ->
|
||||
?assertError(_, aeser_delegation:aens_sig(?NETWORK_ID, ?ACCOUNT, <<42:256>>)),
|
||||
?assertError(_, aeser_delegation:aens_sig(?NETWORK_ID, ?CONTRACT, ?CONTRACT))
|
||||
?assertError(_, gmser_delegation:aens_sig(?NETWORK_ID, ?ACCOUNT, <<42:256>>)),
|
||||
?assertError(_, gmser_delegation:aens_sig(?NETWORK_ID, ?CONTRACT, ?CONTRACT))
|
||||
end}
|
||||
].
|
@ -1,10 +1,11 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @copyright (C) 2025, QPQ AG
|
||||
%%% @copyright (C) 2017, Aeternity Anstalt
|
||||
%%% @doc Tests for Recursive Length Prefix
|
||||
%%% @end
|
||||
%%%-------------------------------------------------------------------
|
||||
|
||||
-module(aeser_rlp_tests).
|
||||
-module(gmser_rlp_tests).
|
||||
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
@ -13,7 +14,7 @@
|
||||
-define(BYTE_ARRAY_OFFSET , 128).
|
||||
-define(LIST_OFFSET , 192).
|
||||
|
||||
-define(TEST_MODULE, aeser_rlp).
|
||||
-define(TEST_MODULE, gmser_rlp).
|
||||
|
||||
rlp_one_byte_test() ->
|
||||
B = <<42>>,
|
Loading…
x
Reference in New Issue
Block a user