Skip to content
This repository was archived by the owner on Jul 31, 2019. It is now read-only.

Commit d3cf2e3

Browse files
authored
return actual ledger fees as mock from sdk. Wrapper can accept partial ledger fees (#311)
1 parent b706e0f commit d3cf2e3

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

vcx/libvcx/src/utils/libindy/payments.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use settings;
1818

1919
static NULL_PAYMENT: &str = "null";
2020
static EMPTY_CONFIG: &str = "{}";
21-
static FEES: &str = r#"{"1":1, "101":2, "102":42, "9999":1999998889}"#;
21+
static FEES: &str = r#"{"0":1, "1":1, "101":2, "102":42, "103":1999998889, "104":0, "105":0, "106":0, "107":0, "108":0, "109":0, "110":0, "111":0, "112":0, "113":0, "114":0, "115":0, "116":0, "117":0, "118":0, "119":0}"#;
2222
static PARSED_TXN_PAYMENT_RESPONSE: &str = r#"[{"amount":4,"extra":null,"input":"["pov:null:1","pov:null:2"]"}]"#;
2323

2424
static PAYMENT_INIT: Once = ONCE_INIT;
@@ -492,7 +492,7 @@ pub mod tests {
492492
let create_schema_req = ::utils::constants::SCHEMA_REQ.to_string();
493493
let start_wallet = get_wallet_token_info().unwrap();
494494

495-
let rc= pay_for_txn(&create_schema_req, "9999");
495+
let rc= pay_for_txn(&create_schema_req, "103");
496496

497497
tests::cleanup_dev_env(name);
498498
assert_eq!(rc, Err(error::INSUFFICIENT_TOKEN_AMOUNT.code_num));

vcx/wrappers/node/src/api/utils.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export function getVersion (): string {
6363
export type ILedgerFees = {
6464
[P in IndyTransactions]: number
6565
}
66-
export async function getLedgerFees (): Promise<ILedgerFees> {
66+
export async function getLedgerFees (): Promise<Partial<ILedgerFees>> {
6767
try {
6868
const ledgerFeesStr = await createFFICallbackPromise<string>(
6969
(resolve, reject, cb) => {
@@ -83,8 +83,7 @@ export async function getLedgerFees (): Promise<ILedgerFees> {
8383
resolve(fees)
8484
})
8585
)
86-
const ledgerFees: ILedgerFees = JSON.parse(ledgerFeesStr)
87-
return ledgerFees
86+
if (ledgerFeesStr) { return JSON.parse(ledgerFeesStr) } else { return JSON.parse('{}') }
8887
} catch (err) {
8988
throw new VCXInternalError(err, VCXBase.errorMessage(err), 'vcx_ledger_get_fees')
9089
}

vcx/wrappers/node/test/utilsTest.js

+5
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ describe('provisioning and updating agents and updating configs', function () {
4343
let rc = vcx.updateInstitutionConfigs('new name', 'http://www.google.com')
4444
assert.equal(rc, 0)
4545
})
46+
47+
it('can retrieve ledger fees', async () => {
48+
let fees = await vcx.getLedgerFees()
49+
assert.equal(JSON.stringify(fees), '{"0":1,"1":1,"101":2,"102":42,"103":1999998889,"104":0,"105":0,"106":0,"107":0,"108":0,"109":0,"110":0,"111":0,"112":0,"113":0,"114":0,"115":0,"116":0,"117":0,"118":0,"119":0}')
50+
})
4651
})

0 commit comments

Comments
 (0)