This project is a Rust implementation of a Balances Pallet that simulates a basic account system with support for:
- Setting initial balances
- Transferring funds between accounts
- Charging a fixed transaction fee(2) on each transfer
All balances are stored in memory using a "BTreeMap<String, u128>". Maps are simple key -> value objects,that allow us to define an arbitrary sized storage where we can map some user identifier (key) to their account balance (value).
C:\Users\RAMPOP\Desktop\rust-state-machine>cargo test
Compiling rust-state-machine v0.1.0 (C:\Users\RAMPOP\Desktop\rust-state-machine)
Finished test profile [unoptimized + debuginfo] target(s) in 0.38s
Running unittests src\main.rs (target\debug\deps\rust_state_machine-41091c82b933561c.exe)
running 3 tests test balances::test::init_balances ... ok test balances::test::transfer_fail_when_no_fee ... ok test balances::test::transfer_with_fee ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s