https://github.com/jaeyson/ex_banking
test from yolo
https://github.com/jaeyson/ex_banking
elixir
Last synced: 9 months ago
JSON representation
test from yolo
- Host: GitHub
- URL: https://github.com/jaeyson/ex_banking
- Owner: jaeyson
- Created: 2022-07-19T09:23:49.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-25T23:56:19.000Z (over 3 years ago)
- Last Synced: 2025-02-09T19:19:25.806Z (11 months ago)
- Topics: elixir
- Language: Elixir
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ExBanking
[//]: # "Badges"
[![Actions Status][actions badge]][actions]
[//]: # "Links"
[actions]: https://github.com/jaeyson/ex_banking/actions
[//]: # "Image sources"
[actions badge]: https://github.com/jaeyson/ex_banking/actions/workflows/ci.yml/badge.svg
To simulate local nodes talking to each other and making transactions:
```elixir
# node1
# iex --sname node1@localhost -S mix
# then add users
iex> ExBanking.create_user("test")
:ok
iex> ExBanking.deposit("test", 1.2589, "usd")
{:ok, 1.26}
```
Then another node connects:
```elixir
# node2 (new)
# iex --sname node2@localhost -S mix
# connects to node1
iex> State.connect_node(:node1@localhost)
iex> ExBanking.create_user("node2")
:ok
iex> ExBanking.deposit("node2", 10, "usd")
{:ok, 10.0}
iex> ExBanking.send("node2", "test", 10, "usd")
{:ok 0.0, 11.26}
iex> ExBanking.get_balance("test", "usd")
{:ok, 11.26}
iex> ExBanking.get_balance("node2", "usd")
{:ok, 0.0}
```