-
Notifications
You must be signed in to change notification settings - Fork 1
/
CustomToken.test.ts
43 lines (36 loc) · 1.56 KB
/
CustomToken.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { assert } from 'chai'
import { Nevermined } from '../../src/nevermined/Nevermined'
import { NvmAccount } from '../../src/models/NvmAccount'
import config from '../../test/config'
import { CustomToken } from '../../src/keeper/contracts/CustomToken'
describe('CustomToken', () => {
let account: NvmAccount
let nevermined: Nevermined
let erc20TokenAddress: string
let customErc20Token: CustomToken
before(async () => {
nevermined = await Nevermined.getInstance(config)
;[account] = nevermined.accounts.list()
erc20TokenAddress = process.env.TOKEN_ADDRESS || nevermined.utils.token.getAddress()
})
it('should get a custom token instance', async () => {
customErc20Token = await nevermined.contracts.loadErc20(erc20TokenAddress)
assert.isDefined(customErc20Token)
})
it('should get the token symbol', async () => {
const tokenSymbol = await customErc20Token.symbol()
assert.equal(tokenSymbol, await nevermined.keeper.token.symbol())
})
it('should get the token name', async () => {
const tokenName = await customErc20Token.name()
assert.equal(tokenName, await nevermined.keeper.token.name())
})
it('should get the token decimals', async () => {
const tokenDecimals = await customErc20Token.decimals()
assert.equal(tokenDecimals, await nevermined.keeper.token.decimals())
})
it('should get the token balance of an account', async () => {
const tokenBalance = await customErc20Token.balanceOf(account.getId())
assert.deepEqual(tokenBalance, await nevermined.keeper.token.balanceOf(account.getId()))
})
})