-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read
bank
genesis from a file. (#961)
* Read bank genesis from a file * fix lint * add read_json_file * make lint fix * fix lint
- Loading branch information
Showing
4 changed files
with
77 additions
and
29 deletions.
There are no files selected for viewing
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,10 @@ | ||
{ | ||
"tokens":[ | ||
{ | ||
"token_name":"sov-demo-token", | ||
"address_and_balances":[["sov1l6n2cku82yfqld30lanm2nfw43n2auc8clw7r5u5m6s7p8jrm4zqrr8r94",100000000]], | ||
"authorized_minters":["sov1l6n2cku82yfqld30lanm2nfw43n2auc8clw7r5u5m6s7p8jrm4zqrr8r94"] | ||
,"salt":0 | ||
} | ||
] | ||
} |
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
39 changes: 39 additions & 0 deletions
39
module-system/module-implementations/sov-bank/src/tests.rs
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,39 @@ | ||
use std::str::FromStr; | ||
|
||
use sov_modules_api::default_context::DefaultContext; | ||
use sov_modules_api::{AddressBech32, Spec}; | ||
|
||
use crate::{BankConfig, TokenConfig}; | ||
|
||
#[test] | ||
fn test_config_serialization() { | ||
let address: <DefaultContext as Spec>::Address = | ||
AddressBech32::from_str("sov1l6n2cku82yfqld30lanm2nfw43n2auc8clw7r5u5m6s7p8jrm4zqrr8r94") | ||
.unwrap() | ||
.into(); | ||
|
||
let config = BankConfig::<DefaultContext> { | ||
tokens: vec![TokenConfig { | ||
token_name: "sov-demo-token".to_owned(), | ||
address_and_balances: vec![(address, 100000000)], | ||
authorized_minters: vec![address], | ||
salt: 0, | ||
}], | ||
}; | ||
|
||
let data = r#" | ||
{ | ||
"tokens":[ | ||
{ | ||
"token_name":"sov-demo-token", | ||
"address_and_balances":[["sov1l6n2cku82yfqld30lanm2nfw43n2auc8clw7r5u5m6s7p8jrm4zqrr8r94",100000000]], | ||
"authorized_minters":["sov1l6n2cku82yfqld30lanm2nfw43n2auc8clw7r5u5m6s7p8jrm4zqrr8r94"] | ||
,"salt":0 | ||
} | ||
] | ||
}"#; | ||
|
||
let parsed_config: BankConfig<DefaultContext> = serde_json::from_str(data).unwrap(); | ||
|
||
assert_eq!(config, parsed_config) | ||
} |