Skip to content
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

feat(mu): Top Up Http Message from AO #1127

Open
twilson63 opened this issue Jan 28, 2025 · 1 comment
Open

feat(mu): Top Up Http Message from AO #1127

twilson63 opened this issue Jan 28, 2025 · 1 comment

Comments

@twilson63
Copy link
Contributor

twilson63 commented Jan 28, 2025

The MU configuration will have a map of address -> nodes, that can be matched when pushing outbox messages.

When a credit-notice is part of the outbox that matches a set of hyperBEAM processes, then the MU should POST a http signed message to the HyperBEAM node endpoint `/[email protected]/topup'

@twilson63
Copy link
Contributor Author

get_balance_and_top_up_test() ->
    {Address, Wallet, Opts} = test_opts(),
    Node = hb_http_server:start_test_node(Opts),
    {ok, Res} =
        hb_http:get(
            Node,
            hb_message:attest(
                #{<<"path">> => <<"/[email protected]/balance">>},
                Wallet
            ),
            #{}
        ),
    ?assertEqual(70, hb_converge:get(<<"body">>, Res, #{})),
    {ok, NewBalance} =
        hb_http:post(
            Node,
            hb_message:attest(
                #{
                    <<"path">> => <<"/[email protected]/topup">>,
                    <<"amount">> => 100,
                    <<"recipient">> => Address
                },
                Wallet
            ),
            #{}
        ),
    ?assertEqual(140, hb_converge:get(<<"body">>, NewBalance, #{})),
    {ok, Res2} =
        hb_http:get(
            Node,
            hb_message:attest(
                #{<<"path">> => <<"/[email protected]/balance">>},
                Wallet
            ),
            #{}
        ),
    ?assertEqual(110, hb_converge:get(<<"body">>, Res2, #{})).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant