Skip to content

Commit

Permalink
Unit denomination and conversion (#301)
Browse files Browse the repository at this point in the history
* feat: balance utils with conversion and formatting

* feat: balance utils with conversion and formatting

* test: updated formatBalance call and tests

* test: remove deprecated GAS value

* chore: add to index
  • Loading branch information
LeonFLK authored and Dudleyneedham committed Oct 12, 2020
1 parent 3cc920c commit 639c36f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/balance/Balance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,19 @@ describe('Balance', () => {
expect(status).toBeInstanceOf(SubmittableResult)
expect(status.isFinalized).toBeTruthy()
})
it('should make transfer of amount with arbitrary exponent', async () => {
const amount = new BN(10)
const exponent = -6
const expectedAmount = BalanceUtils.convertToTxUnit(
amount,
(exponent >= 0 ? 1 : -1) * Math.floor(Math.abs(exponent))
)
const status = await makeTransfer(alice, bob.address, amount, exponent)
expect(blockchainApi.tx.balances.transfer).toHaveBeenCalledWith(
bob.address,
expectedAmount
)
expect(status).toBeInstanceOf(SubmittableResult)
expect(status.isFinalized).toBeTruthy()
})
})

0 comments on commit 639c36f

Please sign in to comment.